1 / 20

general Purpose GPU computing

general Purpose GPU computing. Image Processing & CUDA Programming. Jared Barnes Chris Jackson. Graphics Processing Unit. Originally created to calculate pixel values Each core executes the same set of instructions. Mario projected onto several 2D planes. Graphics Processing Unit.

laszlo
Télécharger la présentation

general Purpose GPU computing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. general Purpose GPU computing Image Processing & CUDA Programming Jared Barnes Chris Jackson

  2. Graphics Processing Unit • Originally created to calculate pixel values • Each core executes the same set of instructions Mario projected onto several 2D planes

  3. Graphics Processing Unit • Chip is designed and manufactured by NVIDIA and AMD • Card bought by consumer is manufactured by various other companies

  4. Image Processing • What does image processing try to accomplish? • Edit an image • Detect faces in an image • Find object edges in an image • Anything you can imagine • Too computationally intensive for a CPU? • Use a GPU!

  5. Image Processing: Brightness

  6. Image Processing: Color

  7. Image Processing • Simple changes • Crop an image • Recolor an image • Move an image • Harder changes • Scale an image • Compress an image • Filter an image

  8. Image Processing Serial Example // Iterate over all pixels in the image for( int x = 0; x < image.width; x++ ) { for( int y = 0; y < image.height; y++ ) { // Get the value of the current pixel Pixel pixel = image.getPixel(x, y); // Check that Red is more intense than Green if( pixel.red > pixel.green ) { // Check that Red is more intense than Blue if( pixel.red > pixel.blue ) { pixel.red = 0; pixel.green = 0; pixel.blue = 255; } } } }

  9. Image Processing Parallel Example // Use the ID of this thread to calculate which // pixel to operate on intx = thread.Id % image.width; inty = thread.Id/ image.height; // Get the value of this thread’s pixel Pixel pixel = image.getPixel(x, y); // Check that Red is more intense than Green if( pixel.red > pixel.green ) { // Check that Red is more intense than Blue if( pixel.red > pixel.blue ) { pixel.red = 0; pixel.green= 0; pixel.blue= 255; } }

  10. CUDA • Compute Unified Device Architecture • GPU programming language developed by NVIDIA • GPUs have CUDA cores • more cores = more parallel performance

  11. CUDA

  12. How to write a CUDA program • Have a graphics card with an NVIDIA GPU capable of running CUDA programs • Install CUDA tools and compiler for Visual Studio 2008, 2010, or 2012 • Create a new CUDA project in Visual Studio

  13. Vector Addition in CUDA

  14. Vector Addition in CUDA

  15. Vector Addition in CUDA

  16. 3 Steps for Parallelization • Parallelize VectorAdd() • Allocate GPU memory & copy data to it • Modify call to VectorAdd() to launch on GPU

  17. Parallelize VectorAdd()

  18. GPU Memory: Allocate & Copy

  19. GPU Memory: Copy & Free

  20. Modify Call to VectorAdd()

More Related