1 / 38

CIS 700/010: GPU Programming and Architecture

CIS 700/010: GPU Programming and Architecture. Suresh Venkatasubramanian ( suvenkat@saul.cis.upenn.edu ). ATI Animusic Demo. CPU performance growth is slowing. Why Program on the GPU ?. From ‘ Stream Programming Environments ’ – Hanrahan, 2004. How has this come about ?.

papina
Download Presentation

CIS 700/010: GPU Programming and Architecture

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. CIS 700/010: GPU Programming and Architecture Suresh Venkatasubramanian (suvenkat@saul.cis.upenn.edu) http://www.cis.upenn.edu/~suvenkat/700/

  2. ATI Animusic Demo http://www.cis.upenn.edu/~suvenkat/700/

  3. CPU performance growth is slowing http://www.cis.upenn.edu/~suvenkat/700/

  4. Why Program on the GPU ? From ‘Stream Programming Environments’ – Hanrahan, 2004. http://www.cis.upenn.edu/~suvenkat/700/

  5. How has this come about ? • Game design has become ever more sophisticated. • Fast GPUs are used to implement complex shader and rendering operations for real-time effects. • In turn, the demand for speed has led to ever-increasing innovation in card design. • The NV40 architecture has 225 million transistors, compared to about 175 million for the Pentium 4 EE 3.2 Ghz chip. http://www.cis.upenn.edu/~suvenkat/700/

  6. GPU = Fast co-processor ? • GPU speed increasing at cubed-Moore’s Law. • This is a consequence of the data-parallelstreaming aspects of the GPU. • GPUs are cheap ! Put enough together, and you can get a super-computer. So can we use the GPU for general-purpose computing ? NYT May 26, 2003: TECHNOLOGY; From PlayStation to Supercomputer for $50,000: National Center for Supercomputing Applications at University of Illinois at Urbana-Champaign builds supercomputer using 70 individual Sony Playstation 2 machines; project required no hardware engineering other than mounting Playstations in a rack and connecting them with high-speed network switch http://www.cis.upenn.edu/~suvenkat/700/

  7. Yes ! Wealth of applications Data Analysis Motion Planning Particle Systems Voronoi Diagrams Force-field simulation Geometric Optimization Graph Drawing Molecular Dynamics Physical Simulation Matrix Multiplication Database queries Conjugate Gradient Sorting and Searching Range queries Signal Processing … and graphics too !! http://www.cis.upenn.edu/~suvenkat/700/

  8. When does “GPU=fast co-processor” work ? Real-time visualization of complex phenomena The GPU (like a fast parallel processor) can simulate physical processes like fluid flow, n-body systems, molecular dynamics http://www.cis.upenn.edu/~suvenkat/700/

  9. When does “GPU=fast co-processor” work ? Interactive data analysis For effective visualization of data, interactivity is key http://www.cis.upenn.edu/~suvenkat/700/

  10. When does “GPU=fast co-processor” work ? Rendering complex scenes (like the Animusic demo) Procedural shaders can offload much of the expensive rendering work to the GPU. Still not the Holy Grail of “80 million triangles at 30 frames/sec*”, but it helps. * Alvy Ray Smith, Pixar. http://www.cis.upenn.edu/~suvenkat/700/

  11. General-purpose Programming on the GPU: What do you need ? In the abstract: • A model of the processor • A high level language In practical terms: • Programming tools (compiler/debugger/optimizer/) • Benchmarking http://www.cis.upenn.edu/~suvenkat/700/

  12. Follow the language • GPU architecture details hidden (unlike CPUs). • OpenGL (or DirectX) provides a state machine that represents the rendering pipeline. • Early GPU programs used properties of the state machine to “program” the GPU. • Tools like Renderman provided sophisticated shader languages, but these were not part of the rendering pipeline. http://www.cis.upenn.edu/~suvenkat/700/

  13. Programming using OpenGL state • One “programmed” in OpenGL using state variables like blend functions, depth tests and stencil tests glEnable( GL_BLEND ) ; glBlendEquationEXT ( GL_MIN_EXT ) ; glBlendFunc( GL_ONE, GL_ONE ) ; http://www.cis.upenn.edu/~suvenkat/700/

  14. Follow the language • As the rendering pipeline became more complex, new functionality was added to the state machine (via extensions) • With the introduction of vertex and fragment programs, full programmability was introduced to the pipeline. http://www.cis.upenn.edu/~suvenkat/700/

  15. Follow the language • With fragment programs, one could write general programs at each fragment MUL tmp, fragment.texcoord[0], size.x; FLR intg, tmp; FRC frac, tmp; SUB frac_1, frac, 1.0; But writing (pseudo)-assembly code is clumsy and error-prone. http://www.cis.upenn.edu/~suvenkat/700/

  16. Follow the language • Finally, with the advent of high level languages like Cg, BrookGPU, and Sh, general purpose programming has become easy: float4 main( in float2 texcoords : TEXCOORD0, in float2 wpos : WPOS, uniform samplerRECT pbuffer, uniform sampler2D nvlogo) : COLOR { float4 currentColor = texRECT(pbuffer, wpos); float4 logo = tex2D(nvlogo, texcoords); return currentColor + (logo * 0.0003); } http://www.cis.upenn.edu/~suvenkat/700/

  17. A Unifying theme: Streaming All the language models share basic properties: • They view the frame buffer as an array of “pixel computers”, with the same program running at each pixel (SIMD) • Fragments are streamed to each pixel computer • The pixel programs have limited state. http://www.cis.upenn.edu/~suvenkat/700/

  18. What is stream programming? • A stream is a sequence of data (could be numbers, colors, RGBA vectors,…) • A kernel is a (fragment) program that runs on each element of a stream, generating an output stream (pixel buffer). http://www.cis.upenn.edu/~suvenkat/700/

  19. Stream Program => GPU • Kernel = vertex/fragment program • Input stream = stream of fragments or vertices or texture data • Output stream = frame buffer or pixel buffer or texture. • Multiple kernels = multi-pass rendering sequence on the GPU. http://www.cis.upenn.edu/~suvenkat/700/

  20. To program the GPU, one must think of it as a (parallel) stream processor. http://www.cis.upenn.edu/~suvenkat/700/

  21. What is the cost of a program ? • Each kernel represents one pass of a multi-pass computation on the GPU. • Readbacks from the GPU to main memory are expensive, and so is transferring data to the GPU. • Thus, the number of kernels in a stream program is one measure of how expensive a computation is. http://www.cis.upenn.edu/~suvenkat/700/

  22. What is the cost of a program ? • Each kernel is a vertex/fragment program. The more complex the program, the longer a fragment takes to move through a rendering pipeline. • Complexity of kernel is another measure of cost in a stream program. http://www.cis.upenn.edu/~suvenkat/700/

  23. What is the cost of a program ? • Texture accesses on the GPU can be expensive if accesses are non-local • Number of memory accesses is also a measure of complexity in a stream program. http://www.cis.upenn.edu/~suvenkat/700/

  24. The GPGPU Challenge • Be cognizant of the stream nature of the GPU. • Design algorithms that minimize cost under streaming measures of complexity rather than traditional measures. • Implement these algorithms efficiently on the GPU, keeping in mind the limited resources (memory, program length) and various bottlenecks (geometry, fill rate) on the card. http://www.cis.upenn.edu/~suvenkat/700/

  25. What will this course cover ? http://www.cis.upenn.edu/~suvenkat/700/

  26. Stream Programming Principles • OpenGL, the fixed-function pipeline and the programmable pipeline • The principles of stream hardware • Viewing the GPU as a realization of a stream programming abstraction • How do we program with streams ? How should one think in terms of streams ? http://www.cis.upenn.edu/~suvenkat/700/

  27. Basic Building Blocks • How do we sort numbers ? • Use ideas from parallel algorithms (“bitonic sort”) • How do we compute the median of a stream of numbers ? • QuickSelect (like Quicksort) • RadixSelect (like Radixsort) http://www.cis.upenn.edu/~suvenkat/700/

  28. Basic Building Blocks • Numerical methods and linear algebra: • Inner products • Matrix-vector operations • Matrix-Matrix operations • At what point does the GPU become faster than the CPU for matrix operations ? For other operations ? http://www.cis.upenn.edu/~suvenkat/700/

  29. Basic Building Blocks • Computational Geometry Operators: • Voronoi Diagrams • Distance fields • Collision Detection • Geometric Optimization • How do we guarantee precision in our answers ? http://www.cis.upenn.edu/~suvenkat/700/

  30. Applying these basic blocks • Scientific computing and simulation • Graph operations • Robotics/vision • And yes… Graphics too ! This part of the class is flexible: I want to hear what your interests are ! http://www.cis.upenn.edu/~suvenkat/700/

  31. Tools we will encounter along the way • Programming tools: Cg (and maybe BrookGPU) • Benchmarking tools: GPUBench • Debugging tools: Shadesmith, others ? • Precision tools: GPUParanoia. http://www.cis.upenn.edu/~suvenkat/700/

  32. What this course will NOT cover • Elements of computer graphics: shading, lighting, transformations. • Basics of computer architecture • Techniques for special graphics effects (recent SIGGRAPH papers, etc) http://www.cis.upenn.edu/~suvenkat/700/

  33. Course Administration http://www.cis.upenn.edu/~suvenkat/700/

  34. Staff • Suresh Venkatasubramanian (suvenkat@saul.cis.upenn.edu) • TA: Paul Kanyuk (pkanyuk@seas.upenn.edu) • Guest Lecturer: Milo Martin (milom@cis.upenn.edu) • Other guest lecturers… • Office hours: by appointment (email us) http://www.cis.upenn.edu/~suvenkat/700/

  35. Class URLs • Course website: All lectures will be archived here. http://www.cis.upenn.edu/~suvenkat/700/ • Blackboard site: check here for assignments and announcements. http://www.cis.upenn.edu/~suvenkat/700/

  36. Assignments • 2-3 assignments consisting of programming projects within Cg. • Paul will run a tutorial session helping people to work with Cg. Assignment 0: Fill out the survey on the class Blackboard site ! Worth 1% of your final grade Please sign up for this class. http://www.cis.upenn.edu/~suvenkat/700/

  37. Project • The major component of a class grade will be a large project (1-2 people each) • Most projects will be programming projects, but this is negotiable if you have an interesting idea. • I will provide a list of project ideas: you are free to come up with your own. • The project will highlight some aspect of general-purpose computing – it will NOT be “write a game” unless the game itself requires nontrivial algorithms. http://www.cis.upenn.edu/~suvenkat/700/

  38. Next class: Thu 01/13/05 • PLEASE fill out the survey, and sign up for the class if you plan to attend. • We will recap the fixed-function pipeline as described in the OpenGL Red Book. Reading material will be on the course web page. http://www.cis.upenn.edu/~suvenkat/700/

More Related