Speakers Biography Databases & GPUs Problem Definition SQL Data Types SQL Stored Procedures System Overview Solution Architecture Image Processing File Formats


Compression/Decompression GPU Image Support Image Processing Techniques

Speakers Bio
CEO 3DMashUp Start-Up focused on GPU Accelerated DBMS

4+ years GPU and HPC Programming Developed large databases • Navteq Street Maps • NASA EOSDIS Climate Research DBMS • LINZ ( Land Info New Zealand)
Formerly • VP Engineering Oracle • VP Engineering BEA Systems • VP Engineering Informix

What are we Solving For?

Database & GPU’s
Internal Operations
– GPU Accelerated Applications

Query Planning/ Optimizer

Image Processing

Medical Remote Sensing Climate Research

Fastest Route

Relational Operations

Select Project Join

In-Database Analytics

Predictive Analytics

Risk Management

3D Content Management



Sorting Group By

Additive Printing Artificial Reality

SQL Data Types


GPU Types (22)

Set of Columns



Uchar N, Integer16 N, Integer 32 N, Double N, Float N, …


Set of Rows

TimeSeries, Image2D, JPEG

Columns Types


N D Range, Image Sampler, LocalStorage

Standard types

Numbers, Text, Boolean, URL, XML, Date Time ….


Binary File Stream ( Read/Write, Seek operations )

SQL Type Examples
Create Table Images ( Id Name Path Image Thumbnail WorkImage Histogram … serial not null, text not null, uri not null, OpenCL.jpeg not null, OpenCL.jpeg, OpenCL.Image2D, TimeSeries,

Database Image Storage Options

– –

Opaque Binary File Stream Unlogged/Logged

– – –

Byte Areas Logged Unlogged Tables

External Files
– –

Store File Path SQL Server Filestream

Image Storage Comparison
ACID SMART BLOB BLOB Logged Table Unlogged Table External File FileStream Yes No Yes No No Yes Size SoD SoD ~1G ~1G SoD SoD Integrated Queryable Back-Up Yes No Yes Yes No ?? Yes Yes Yes Yes No Yes Encryption Manual Manual Optional Optional Manual No GPU Replication Query ?? No No Yes Yes No No No Yes No No No

SQL UDFs (User Defined Functions)

Functions called by SQL Queries or Triggers Many SQL UDF Language Bindings

TSQL, PLSQL, SQL, C/C++, Perl, Ruby, R, Java, ..

Implements natural Map-Reduce paradigm Can implement Internal DB operations

Views, Sorts, Joins, …

GPU Language Bindings


SQL UDF Examples
-An OpenCL UDF Histogram256( Input image image2d, Create Function output histogram256 Timeseries ) as $body$ Kernel void Histogram256( read_only image2d_t write_only { … } $body$ language pgopencl; -A CUDA UDF image integer[], * image,

Timeseries * histogram )

Create Function CudaHistogram256 ( input output histogram integer[] )

As ‘PTX file name’ language pgcuda;

-Insert New Data Insert into images ( image, name, path) values ( … ); -Query Creates Histogram and a Thumbnail

Update Images set histogram = histogram256( imaged::image2d, histogram )::Timeseries, thumbnail = scale( image::image2d, 64, 64) :: jpeg where id = … ; -Query Images for display

Select * from images where id = … ;

SQL GPU Execution Model

Image Processing Goals
Secure  Multi-User  Shared  Managed  Scalable  Integrated  Fast

Image Processing Operations

Geometric Operations

Scale, Rotate, Transform

Point Operations

Contrast, Brightness, ..


Linear, Non-Linear

Histograms Edge & Contours

Edge Detection, Curve Detection

Region Processing Color/Spectra Processing FFT/DCT

System Architecture Overview

File Formats

• • • •

Complex Multi-Layered Metadata Opaque

OpenCL GPU Image Support


1D, 2D, 3D Geometries

– –

Set of sample values (1,2,3,4 per Pixel) Data Types

Byte, Int16, Int32, Float, Half Float, Short_555, …

Channel Order

RGBA, ARGB, Intensity, Luminance,…

80+ Combinations

Queryable from the Device Driver

Impedance Mismatch

Impedance Mismatch
– – –

GPU Raw Format Files Compressed (mostly) JPEG 24 bit (3x8) RGB vs 32 bit (4 x 8) Vector

Conversion Required
– –

Extract Relevant Sections Decompress/Compress

DCT, LZW, Huffman, ….

Color Model Transformation


Align to GPU Memory Formats


Image Processing Memory Optimization Techniques

Convert 24 bit RGB Pixel to UChar 4 Vectors

Image Striding

Alignment of Pixels Rows to GPU Memory Banks

Z- Ordering
– –

Spatial location of Pixels Alignment of Pixels to GPU Memory Banks

Host Converts 24 Bit JPEG RGB to 32 Bit Unsigned Char_4 Vector Wastes 25% RAM for ~3X Speed-Up

3x3, 5x5, … Pixels processed per Output Pixel

GPU Memory Access Patterns
Un-Coalesced (misaligned)

Bank Conflict (same Bank) Coalesced

Image Striding

Stride Length is an Exact Multiple of 16 Words

Padding Words

Pixel Access Patterns
Linear Access • Poor Access Pattern • Bank Conflicts • Misalignment Z-Order Access • Good Access Pattern • No Bank Conflicts • Coalesced Access

Morton Z Ordering
Access Order (0,0) (1,0) (1,1) (1,1) (2,0) (3,0) (2,1) (3,1) ….

Optimizing Memory Access on GPU Using Morton Order Indexing A.E. Nocentio, P.J. Rhodes, ACM SE ‘10

Integer Dilation
Z Order Coordinates • Dilation & Shifting

Dilation • Shifting • Look-Up • Magic Arithmetic

Integer Dilation and Contraction for Quadtrees and Octrees, L Stocco, G Schrack, IEEE 1995


GPU Accelerated Databases

Bridges Impedance Mismatch

Persistence of Image File Format GPU Memory Access patterns Minimal Data Movement

Supports Image Processing Capabilities

CUDA and OpenCL Kernel functions Support Multiple Image Formats Content Based Queries

GPUs Offload Image Processing Computations

Future Directions

More Image Types
– –


Computer Vision Functions ( OpenCV )
 

Face Detection Face Recognition Query by Content

 GPU Side Compress/Decompress Feature Extraction


DCT, Quantization, Huffman