Docsity

GPGPU Programming: Understanding Data-Parallel Computing with GPUs, Study notes of Computer Science

Partial preview of the text

Download GPGPU Programming: Understanding Data-Parallel Computing with GPUs and more Study notes Computer Science in PDF only on Docsity!

The The GPGPU

GPGPU Programming

Programming Model

Model

John Owens John Owens

University of California, Davis University of California, Davis

Overview Overview •

Data-parallel programming basics

The GPU as a data-parallel computer

“Hello World” GPGPU Example

Stream Programming Basics Stream Programming Basics

SAD

Image 1

convolve

convolve

Image 0

convolve

convolve

Depth Map

Computation is expressedas kernels (ovals).

Data is expressed asstreams (arrows).

Kernels exploit both instruction(ILP) and data (SIMD) levelparallelism. They should havesimple control and higharithmetic intensity.

The stream model exploitsparallelism without thecomplexity of traditionalparallel programming.

Modern Graphics Pipeline Modern Graphics Pipeline

Vertex Buffer

Vertex

Processor

Rasterizer

Fragment Processor

Texture Buffer

Frame

Buffer(s)

VS3.0 GPUs

GPU as a Stream Processor GPU as a Stream Processor

Draw a screen-sizedquad (creates stream offragments)

Run kernel (fragmentprogram) over stream offragments

Read stream data fromtextures

Write stream of resultsto frame buffer

Write Data To

Texture

Load

Fragment

Program

Configure

OpenGL for

1:1 Rendering

Draw Large

Quad

Bind Textures Bind Fragment

Program

Write

results to

texture

GPU as a Stream Processor GPU as a Stream Processor •

Streams

Æ

Textures

Kernels

Æ

Fragment program

forEach

execution

Æ

Draw single large quad

“Hello

Hello World

World“

“ GPGPU

GPGPU Example

Example

GPU Version

  1. Load

image

into texture

Figure courtesy of Mark Harris

  1. Create

blurImage

texture to hold result

“Hello

Hello World

World“

“ GPGPU

GPGPU Example

Example

GPU Version

Load fragment program (kernel)

Example shown in Cg

float4 blurKernel( uniform samplerRECT image,

float

winPos : WPOS,

out float

blurImage )

{

blurImage = float4(0,0,0,0);for (i=-1; i <= 1; i++) {

for (j=-1; j <= 1; j++) {

float2 texCoord = winPos + float2(i,j);float

w

= computeWeight(i,j);

blurImage += w * texRECT( image, texCoord );

}

}

}

“Hello World

Hello World“

“ GPGPU Example

GPGPU Example

GPU Version

  1. Execute kernel on each stream element

Draw quad of size [

WIDTH

x

HEIGHT]

glBegin( GL_TRIANGLES );

glVertex2f(0, 0);glVertex2f(2, 0);glVertex2f(0, 2);

glEnd();

0

2

2 1

1

“Hello World

Hello World“

“ GPGPU Example

GPGPU Example

What happened?

blurKernel

executed on each element of

image

Rendering replaced outer two loops of CPU version

blurKernel

performed

gather

operation at each element

Result (

blurImage

) was written to framebuffer / texture

Questions?

Questions? •

GPU as stream processor?

Stream programming model?

“Hello World” example?

References References •

ATI Developer web site, http://www.ati.com/developer/

GPGPU Developer web site, http://www.gpgpu.org/developer

N. Goodnight, C. Woolley, G. Lewin, D. Luebke, G. Humphreys, “AMultigrid Solver for Boundary Value Problems Using ProgrammableGraphics Hardware,” Graphics Hardware 2003, pp. 102–

M. Harris, W. Baxter, T. Scheuermann, A. Lastra, “Simulation of CloudDynamics on Graphics Hardware,“ Graphics Hardware 2003, pp. 92–

W.D. Hillis and G. Steele Jr., “Data Parallel Algorithms,” Comm. ACM,29(12), December 1986, pp. 1170–

U. Kapasi, W. Dally, S. Rixner, P. Mattson, J. Owens, B. Khailany,“Efficient Conditional Operations for Data-parallel Architectures”. InProc. of the 33rd Ann. Int'l Symp. on Microarchitecture (2000), pp. 159– 170

A. Lefohn, J. Kniss, C. Hansen, R. Whitaker, “A Streaming Narrow-BandAlgorithm: Interactive Deformation and Visualization of Level Sets,”IEEE Transactions on Visualization and Computer Graphics, Jul./Aug.2004 , pp. 422–

NVIDIA Developer web site, http://developer.nvidia.com/page/home