• No results found

GPU Programming and Computing

N/A
N/A
Protected

Academic year: 2022

Share "GPU Programming and Computing"

Copied!
27
0
0

Laster.... (Se fulltekst nå)

Fulltekst

(1)GPU Programming and Computing Johan Seland [email protected]. Workshop on High-Performance and Parallel Computing Simula Research Laboratory October 24, 2007. Applied Mathematics. 1/26.

(2) Offline rendering five years ago. Shrek (Dreamworks/PGI) Applied Mathematics. 2/26.

(3) Interactive Rendering five years ago. Quake 3 (id Software) Applied Mathematics. 3/26.

(4) Offline Rendering today. Madagascar (Dreamworks/PGI) Applied Mathematics. 4/26.

(5) Interactive Rendering today. Project Gotham Racing Applied Mathematics. 5/26.

(6) Enter the GPU. This is because of the Graphical Processing Unit(GPU). Fall 2002: Intel Pentium IV. Fall 2002: Nvidia GeForce 4. 3.06 GhZ. Fall 2007: Intel Core 2 Ext.. 250 MhZ. Fall 2007: Nvidia Geforce 8. 4 × 3.00GhZ 582 million transistors (Follows Moores Law). 1.35 GhZ 680 million transistors (Follows Moores Law). Applied Mathematics. 6/26.

(7) The PC of 2007. 4 core CPU 96 Gflops(peak) 7750,- NOK. GPU 330 Gflops (observed) 4299,- NOK. Interconnects 1 GiB/s CPU ↔ GPU 21 GiB/s CPU ↔ system memory (peak) 55.2 GiB/s GPU ↔ graphics memory (observed). It is quite clear where performance is located.. Applied Mathematics. 7/26.

(8) Outline. 1. Capabilities of GPUs. 2. GPU Programming. 3. Successful Applications. Applied Mathematics. 8/26.

(9) Why are GPUs fast?. Traditional CPU designs use ≈ 50% of transistors for cache and control logic, not computations The nature of GPUs makes it easier to use additional transistors for computation This comes at the cost of flexibility. CPU industry is moving from “instructions per second” to “instructions per watt” “Power wall” is now all important We can not scale voltage like we used to We can not scale clock as we used to. Video game market drives innovation. Applied Mathematics. 9/26.

(10) Characteristics of a GPU Nvidia G80 - Released fall 2006 128 Stream Processors Fused Multiply And Add Trigonometric functions in once cycle (almost) IEEE 754 Single-precision (32 bit) Scalar processor. Core clock up to 1.35GhZ Up to 2GiB Memory 680 million transistors Two can be run in parallel ≈ 300 Watt (under load) → ≈ 1.1 Flops/Watt ≈ 0.7 Flops/Watt for Quad core CPU. Applied Mathematics. 10/26.

(11) Floating point on GPUs (as of 2007). Only 32-bit (single precision) Announced 64-bit precision at half speed Possible remedy: Correction steps in 64-bit precision. Lacks denormalized numbers Lacks signalling of NaNs Rounding mode can not be changed Lower precision for division and square root Floating point → integer conversion not fully IEEE-754 compliant. Applied Mathematics. 11/26.

(12) Nvidia G80 block diagram. Very little of this is graphic specific ...but, assumes threads are independent. Applied Mathematics. 12/26.

(13) Limitations of GPUs If the GPU is so great, why are we still using the CPU? You can not simply “port” existing code and algorithms! Data-stream mindset required Parallel algorithms New data structures (dynamic data structures are troublesome). Not suitable to all problems Pointer chasing impossible or inefficient Recursion. Debugging is hard Hardware is designed without debug bus Driver is closed. Huge performance cliffs No standard API More about this later.... Applied Mathematics. 13/26.

(14) “Hyper-Core” computers Speculation about the computer of the next decade: 10s of CPU cores Use for scheduling Use for “irregular” part of problem Maybe higher precision (correction steps). 100s of GPU cores Use for “regular” part of problem. NUMA (Non-Uniform Memory Access) for both Programming languages must expose this Runtime systems? Always out-of-(some)-core. Clusters of these? OpenMP/MPI not sufficient. Applied Mathematics. 14/26.

(15) Outline. 1. Capabilities of GPUs. 2. GPU Programming. 3. Successful Applications. Applied Mathematics. 15/26.

(16) GPU Programming GPUs have traditionally been closed architectures. Must program them through closed-source graphics driver Driver is like an OS (threads, scheduling, protected memory). OpenGL/DirectX are standard, but Designed for graphics, not general purpose computations Many revisions of each standard New revisions for each HW-generation. Allows for “capabilities” Large variations between vendors. Both vendors now have dedicated GPGPU APIs Nvidia CUDA (Compute Unified Device Architecture) AMD CTM (Close To Metal). GPGPU “version” of hardware as well. Applied Mathematics. 16/26.

(17) Computer graphics 101. CPU Geometry Rasterize. Pre-2007: Hardware mimicked graphics APIs It is possible to formulate many problems in this framework Uses graphics APIs “Classical GPGPU”. Shade pixels Display. Applied Mathematics. 17/26.

(18) Computer graphics 101. CPU Geometry Rasterize Shade pixels Display. Pre-2007: Hardware mimicked graphics APIs It is possible to formulate many problems in this framework Uses graphics APIs “Classical GPGPU”. DO NOT DO THIS ANYMORE! (Unless for graphics). Applied Mathematics. 17/26.

(19) Nvidia CUDA (Compute Unified Device Architechure) C-like API for programming newer Nvidia GPUs Computation kernels are written in C Compiles with dedicated compiler, nvcc. Kernels are executed as threads, threads organized into blocks Programmer decides #threads, #threads/block, and mem/block. Exposes different kinds of memory Thread-local (register) Shared per block Global (not cached, write everywhere) Texture (cached read only memory) Constant(cached read only memory). Some synchronization primitives cudaMalloc, cudaMemcpy for allocating and copying memory Applied Mathematics. 18/26.

(20) Flexibility. Properties of APIs. Nvidia CUDA AMD CTM Sh. ad. ing. La. ng ua. ge s. Fixed Function. Vendor Specific. Portability. Applied Mathematics. 19/26.

(21) Outline. 1. Capabilities of GPUs. 2. GPU Programming. 3. Successful Applications. Applied Mathematics. 20/26.

(22) Hyperbolic Conservations Laws. Most high-resolution schemes for conservations laws are explicit Explicit schemes are embarrassingly (pleasantly?) parallel Algorithm is numerically stable, suitable for single-precision Complex schemes → High number of arithmetic operations per memory operation Finite speed of wave propagation → Easy to decompose computational domain into subdomains Overcomes lack of memory on GPUs Obvious potential for cluster implementations. Applied Mathematics. 21/26.

(23) Hyperbolic Conservations Laws Cont. Scheme with low arithmetic intensity Grid size 128 × 128 256 × 256 512 × 512 1024 × 1024. CPU ms1 2.22 9.09 37.10 1248.00. GPU ms 0.23 0.46 1.47 5.54. Speedup 9.5 19.8 25.2 26.7. Scheme with high arithmetic intensity Grid size 128 × 128 256 × 256 512 × 512 1024 × 1024 1. CPU ms 30.6 122.0 486.0 2050.0. GPU ms 1.27 4.19 16.80 68.30. Speedup 24.2 29.1 28.9 30.0. Per time step Applied Mathematics. 22/26.

(24) 3D Euler Equations Images show a circular explosion inside a cubic container. Runtimes per time step in seconds of the Rayleigh-Taylor instability on a N × N × N grid. Grid Size 493 643 813. CPU ms 5.23e-1 1.14e-0 1.98e-0. GPU ms 4.16e-2 8.2e-2 1.72e-1. Applied Mathematics. Speedup 12.6 13.9 11.5. 23/26.

(25) Matrix Multiplication G80 G70 P IV. G80 G70 P IV. 10. Time (seconds). Time (seconds). 10. 1. 1. 0.1. 0.1. 0.01 500. 1000. 2000. 4000. 500. 1000. 2000. 4000. Matrix size. Matrix size. Single Pass. Multi Pass. Speedup is around 30× for dense matrix multiply 7× for PLU factorization. Applied Mathematics. 24/26.

(26) Geometry Processing. Self intersections. Dynamic silhouette refinement. Algebraic Geometry. Preparation of FEM grids. Applied Mathematics. 25/26.

(27) Conclusion. The GPU is the only parallel processor that has seen widespread success Allows us to experiment with 100s of cores today Not just a toy anymore Future is definitively parallel, but what kind of parallel? Memory management is a very open problem. Applied Mathematics. 26/26.

(28)

Referanser

RELATERTE DOKUMENTER

We further- more discuss texturing of head models and rendering of skin and hair, addressing problems related to texture synthesis, bump mapping with graphics hardware, and dynamics

We have presented a framework for computing distance transforms, Voronoi diagrams, and skeletons of generalized metrics using graphics hardware. When compared to the most

ATI’s prototype Ashli compiler [BP03], for example, uses RDS to partition its input RenderMan and GL Shading Language shader programs into multiple passes for use on graphics

1999-2000: Transform and lighting 2001: Programmable vertex shader 2002-2003: Programmable pixel shader 2004: Shader model 3.0 and 64-bit color support PC graphics

GPUs designed for and driven by graphics Programming model is unusual & tied to graphics Programming environment is tightly constrained Underlying architectures are:.

Voronoi rasterization uses modern programmable graphics hardware to generate occluding surface representa- tions from sparse, oriented point sets without preprocessing.. In

In the following, we present an interactive GPU-based illustrative framework, called VolFlies- GPU, for rendering volume data, exploiting parallelism in both graphics hardware

OpenGL ES is a low-level API, that can be used as a building block for higher level APIs such as M3G, or Mobile 3D Graphics API for J2ME, also known as JSR-184 (JSR =