DESIGNING PHYSICS ALGORITHMS FOR GPU ARCHITECTURE Takahiro HARADA







![WORK GROUP(WG), WORK ITEM(WI) Particle[0 -63] Work Group 0 Particle[64 -127] Work Group 1 WORK GROUP(WG), WORK ITEM(WI) Particle[0 -63] Work Group 0 Particle[64 -127] Work Group 1](https://slidetodoc.com/presentation_image/2d51ac5c9c50194f96b58245536a34ae/image-8.jpg)












- Slides: 20
DESIGNING PHYSICS ALGORITHMS FOR GPU ARCHITECTURE Takahiro HARADA AMD
NARROW PHASE ON GPU § Narrow phase is parallel – How to solve each pair? § Design it for a specific architecture 2 | Designing Physics Algorithms for GPU Architecture | March 1, 2011
GPU ARCHITECTURE § Radeon HD 5870 – 2. 72 TFLOPS(S), 544 GFLOPS(D), 153. 6 GB/sec – Many cores § 20 SIMDs x 64 wide SIMD § CPU SSE 4 wide SIMD § Program of a work item is packed in VLIW, then executed Radeon HD 5870 Phenom II X 4 SIMD SIMD Core SIMD SIMD SIMD SIMD 20(SIMDs)x 16(Thread processors) x 5(Stream cores) = 1600 3 | Designing Physics Algorithms for GPU Architecture | March 1, 2011 SIMD Core
MEMORY § Register § Global memory Global Memory > 1 GB – “Main memory” – Large – High latency § Local Data Store(LDS) 156. 3 GB/s – Low latency – High bandwidth – Like a user managed cache – Key to get high performance SIMD Local Data Share 32 KB GPU SIMD SIMD SIMD SIMD SIMD 4 | Designing Physics Algorithms for GPU Architecture | March 1, 2011
NARROW PHASE ON CPU 0 § Methods on CPUs(GJK) – Any convex shapes switch() { case A: { execute. A(); break; } case B: { execute. B(); break; } case C: { execute. C(); break; } } finish(); – Possible to implement on the GPU – Complicated for GPU – Divergence => Low use of ALUs § GPU prefer simpler algorithm with less logic § Why GPU is not good at complicated logic? – Wide SIMD architecture } 5 | Designing Physics Algorithms for GPU Architecture | March 1, 2011 1 2 3 4 5 6 7 Void Kernel() { execute. X(); 25% 50%
NARROW PHASE ON GPU 0 § Particles – Search for neighboring particle Void Kernel() { prepare(); – Collide to all – Accurate shape representation needs collide(p 0); § Increase resolution collide(p 1); § Acceleration structure in each shape collide(p 2); collide(p 3); – Increase complexity collide(p 4); § Explode number of contacts collide(p 5); § Etc. . collide(p 6); § Can we make it better but keep it simple? collide(p 7); } 6 | Designing Physics Algorithms for GPU Architecture | March 1, 2011 1 2 3 4 5 6 7
A GOOD APPROACH FOR GPUS, FROM ARCHITECTURE § Have to know what GPUs likes – Less branch § Less divergence – Use LDS on SIMD – Latency hiding § Why latency? 7 | Designing Physics Algorithms for GPU Architecture | March 1, 2011
WORK GROUP(WG), WORK ITEM(WI) Particle[0 -63] Work Group 0 Particle[64 -127] Work Group 1 Particle[128 -191] Work Group 2 Radeon HD 5870 SIMD SIMD SIMD SIMD SIMD SIMD lane(64 lanes) Work item(64 items) 8 | Designing Physics Algorithms for GPU Architecture | March 1, 2011
HOW GPU HIDES LATENCY? § Memory access latency – Not rely on cache § SIMD hides latency by switching WGs § The more WGs/SIMD is the better – 1 WG/SIMD cannot hide latency – Overlap work to memory request § What determines # of WGs/SIMD? – Local resource usage 9 | Designing Physics Algorithms for GPU Architecture | March 1, 2011 Work Group 0 Void Kernel() { read. Global. Mem(); compute(); } Work Group 1 Work Group 2 Work Group 3
WHY REDUCE RESOURCE USAGE? § Regs are limited resource § # of WGs/SIMD Engine (8 regs) – SIMD regs/(kernel regs use) – LDS/(kernel LDS use) § Less # of regs – More WGs 1 Kernel. A Regs: 8 1 Kernel. B Regs: 4 2 – Hide latency § Register overflow -> global memory 10 | Designing Physics Algorithms for GPU Architecture | March 1, 2011 Kernel. C Regs: 2 1 2 3 4
0 § 1 WG processes 1 pair § Reduce resource usage Void Kernel() { fetch. To. LDS(); BARRIER; 1 2 3 4 5 6 7 Global Mem PREVIEW OF CURRENT APPROACH compute(); § Less branch – Compute is branch free LDS – No dependency § Use of LDS BARRIER; work. Together(); – No global mem access on compute() BARRIER; Writeback(); § Latency hiding – Pair data for a WG not per WI § WIs work together § Unified method for all the shapes 11 | Designing Physics Algorithms for GPU Architecture | March 1, 2011 } Global Mem – Random access to LDS
SOLVER
13 | Designing Physics Algorithms for GPU Architecture | March 1, 2011
14 | Designing Physics Algorithms for GPU Architecture | March 1, 2011
FUSION
CHOOSING A PROCESSOR § CPU can do everything – Not good for highly parallel computations as GPU § GPU is very powerful processor – Only for parallel computation § Real problem has both § GPU is far from CPU 16 | Designing Physics Algorithms for GPU Architecture | March 1, 2011
FUSION § GPU and CPU are close § Faster communication between GPU and CPU § Use both GPU and CPU – Parallel workload -> GPU – Serial workload -> CPU 17 | Designing Physics Algorithms for GPU Architecture | March 1, 2011
COLLISION BETWEEN LARGE AND SMALL PARTICLES 0 § Granularity of computation – Large particle collide more – Inefficient use of the GPU 18 | Designing Physics Algorithms for GPU Architecture | March 1, 2011 1 2 3 4 5 6 7
19 | Designing Physics Algorithms for GPU Architecture | March 1, 2011
Q&A 20 | Designing Physics Algorithms for GPU Architecture | March 1, 2011




















