GPU Architectures. A CPU Perspective. Data Parallelism: What is it, and how to exploit it? Workload characteristics



Similar documents
Introduction to GP-GPUs. Advanced Computer Architectures, Cristina Silvano, Politecnico di Milano 1

Lecture 11: Multi-Core and GPU. Multithreading. Integration of multiple processor cores on a single chip.

Introduction to GPU Architecture

Introduction to GPU hardware and to CUDA

Intro to GPU computing. Spring 2015 Mark Silberstein, , Technion 1

Next Generation GPU Architecture Code-named Fermi

GPU Parallel Computing Architecture and CUDA Programming Model

Introduction to GPU Programming Languages

AMD GPU Architecture. OpenCL Tutorial, PPAM Dominik Behr September 13th, 2009

Graphics Cards and Graphics Processing Units. Ben Johnstone Russ Martin November 15, 2011

Lecture 3: Modern GPUs A Hardware Perspective Mohamed Zahran (aka Z) mzahran@cs.nyu.edu

Parallel Programming Survey

GPU Architecture. An OpenCL Programmer s Introduction. Lee Howes November 3, 2010

OpenCL Optimization. San Jose 10/2/2009 Peng Wang, NVIDIA

GPUs for Scientific Computing

GPU System Architecture. Alan Gray EPCC The University of Edinburgh

OpenCL Programming for the CUDA Architecture. Version 2.3

Introduction to Cloud Computing

Introduction to GPGPU. Tiziano Diamanti

FLOATING-POINT ARITHMETIC IN AMD PROCESSORS MICHAEL SCHULTE AMD RESEARCH JUNE 2015

CUDA Optimization with NVIDIA Tools. Julien Demouth, NVIDIA

The Evolution of Computer Graphics. SVP, Content & Technology, NVIDIA

Introducing PgOpenCL A New PostgreSQL Procedural Language Unlocking the Power of the GPU! By Tim Child

GPU Computing with CUDA Lecture 2 - CUDA Memories. Christopher Cooper Boston University August, 2011 UTFSM, Valparaíso, Chile

GPU Hardware Performance. Fall 2015

Introduction to GPU Computing

NVIDIA GeForce GTX 580 GPU Datasheet

Overview. Lecture 1: an introduction to CUDA. Hardware view. Hardware view. hardware view software view CUDA programming

GPGPU Computing. Yong Cao

Introduction GPU Hardware GPU Computing Today GPU Computing Example Outlook Summary. GPU Computing. Numerical Simulation - from Models to Software

CUDA programming on NVIDIA GPUs

GPU Architecture. Michael Doggett ATI

Introduction to Numerical General Purpose GPU Computing with NVIDIA CUDA. Part 1: Hardware design and programming model

HPC with Multicore and GPUs

Thread level parallelism

GPGPU for Real-Time Data Analytics: Introduction. Nanyang Technological University, Singapore 2

Multi-core architectures. Jernej Barbic , Spring 2007 May 3, 2007

Radeon GPU Architecture and the Radeon 4800 series. Michael Doggett Graphics Architecture Group June 27, 2008

Radeon HD 2900 and Geometry Generation. Michael Doggett

GPU Computing with CUDA Lecture 4 - Optimizations. Christopher Cooper Boston University August, 2011 UTFSM, Valparaíso, Chile

NVIDIA Tools For Profiling And Monitoring. David Goodwin

This Unit: Putting It All Together. CIS 501 Computer Architecture. Sources. What is Computer Architecture?

GPU Hardware and Programming Models. Jeremy Appleyard, September 2015

Rethinking SIMD Vectorization for In-Memory Databases

Performance Evaluation of NAS Parallel Benchmarks on Intel Xeon Phi

E6895 Advanced Big Data Analytics Lecture 14:! NVIDIA GPU Examples and GPU on ios devices

Chapter 2 Parallel Architecture, Software And Performance

Programming models for heterogeneous computing. Manuel Ujaldón Nvidia CUDA Fellow and A/Prof. Computer Architecture Department University of Malaga

CUDA SKILLS. Yu-Hang Tang. June 23-26, 2015 CSRC, Beijing

Multicore Processor and GPU. Jia Rao Assistant Professor in CS

OpenACC 2.0 and the PGI Accelerator Compilers

~ Greetings from WSU CAPPLab ~

Software Pipelining. for (i=1, i<100, i++) { x := A[i]; x := x+1; A[i] := x

Optimizing Parallel Reduction in CUDA. Mark Harris NVIDIA Developer Technology

ATI Radeon 4800 series Graphics. Michael Doggett Graphics Architecture Group Graphics Product Group

Enterprise Applications

Choosing a Computer for Running SLX, P3D, and P5


Accelerating sequential computer vision algorithms using OpenMP and OpenCL on commodity parallel hardware

Improving GPU Performance via Large Warps and Two-Level Warp Scheduling

Parallel programming: Introduction to GPU architecture. Sylvain Collange Inria Rennes Bretagne Atlantique

GPU Performance Analysis and Optimisation

Multi-Threading Performance on Commodity Multi-Core Processors

Optimizing Application Performance with CUDA Profiling Tools

Maximize Application Performance On the Go and In the Cloud with OpenCL* on Intel Architecture

L20: GPU Architecture and Models

Hardware support for Local Memory Transactions on GPU Architectures

Generations of the computer. processors.

GPU Computing - CUDA

BEAGLEBONE BLACK ARCHITECTURE MADELEINE DAIGNEAU MICHELLE ADVENA

10- High Performance Compu5ng

White Paper AMD GRAPHICS CORES NEXT (GCN) ARCHITECTURE

Real-Time Realistic Rendering. Michael Doggett Docent Department of Computer Science Lund university

Hardware design for ray tracing

IBM CELL CELL INTRODUCTION. Project made by: Origgi Alessandro matr Teruzzi Roberto matr IBM CELL. Politecnico di Milano Como Campus

Slide Set 8. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng

LSN 2 Computer Processors

361 Computer Architecture Lecture 14: Cache Memory

Accelerating Intensity Layer Based Pencil Filter Algorithm using CUDA

IP Video Rendering Basics

SGRT: A Scalable Mobile GPU Architecture based on Ray Tracing

GPGPUs, CUDA and OpenCL

GPU architecture II: Scheduling the graphics pipeline

INSTRUCTION LEVEL PARALLELISM PART VII: REORDER BUFFER

SPARC64 VIIIfx: CPU for the K computer

Intel Pentium 4 Processor on 90nm Technology

HETEROGENEOUS SYSTEM COHERENCE FOR INTEGRATED CPU-GPU SYSTEMS

FPGA-based Multithreading for In-Memory Hash Joins

CUDA Basics. Murphy Stein New York University

OC By Arsene Fansi T. POLIMI

Binary search tree with SIMD bandwidth optimization using SSE

CUDA. Multicore machines

How To Use An Amd Ramfire R7 With A 4Gb Memory Card With A 2Gb Memory Chip With A 3D Graphics Card With An 8Gb Card With 2Gb Graphics Card (With 2D) And A 2D Video Card With

Understanding Hardware Transactional Memory

Transcription:

GPU Architectures A CPU Perspective Derek Hower AMD Research 5/21/2013 Goals Data Parallelism: What is it, and how to exploit it? Workload characteristics Execution Models / GPU Architectures MIMD (SPMD), SIMD, GPU Programming Models Terminology translations: CPU AMD GPU Nvidia GPU Intro to OpenCL Modern GPU Microarchitectures i.e., programmable GPU pipelines, not their fixed-function predecessors Advanced Topics: (Time permitting) The Limits of GPUs: What they can and cannot do The Future of GPUs: Where do we go from here? GPU ARCHITECTURES: A CPU PERSPECTIVE 2 1

Data Parallel Execution on GPUs Data Parallelism, Programming Models, GPU ARCHITECTURES: A CPU PERSPECTIVE 3 Graphics Workloads Streaming computation GPU GPU ARCHITECTURES: A CPU PERSPECTIVE 4 2

Graphics Workloads Streaming computation on pixels GPU GPU ARCHITECTURES: A CPU PERSPECTIVE 5 Graphics Workloads Identical, Streaming computation on pixels GPU GPU ARCHITECTURES: A CPU PERSPECTIVE 6 3

Graphics Workloads Identical, Independent, Streaming computation on pixels GPU GPU ARCHITECTURES: A CPU PERSPECTIVE 7 Architecture Spelling Bee P-A-R-A-L-L-E-L Spell Independent GPU ARCHITECTURES: A CPU PERSPECTIVE 8 4

Generalize: Data Parallel Workloads Identical, Independent computation on multiple data inputs 0,7 color out = f(color in ) 7,0 1,7 color out = f(color in ) 6,0 2,7 color out = f(color in ) 5,0 3,7 color out = f(color in ) 4,0 GPU ARCHITECTURES: A CPU PERSPECTIVE 9 Naïve Approach Split independent work over multiple processors CPU0 0,7 color out = f(color in ) 7,0 1,7 CPU1 color out = f(color in ) 6,0 2,7 CPU2 color out = f(color in ) 5,0 3,7 CPU3 color out = f(color in ) 4,0 GPU ARCHITECTURES: A CPU PERSPECTIVE 10 5

Data Parallelism: A MIMD Approach Program color out = f(color in ) Program color out = f(color in ) Program color out = f(color in ) Program color out = f(color in ) Multiple Instruction Multiple Data Split independent work over multiple processors 0,7 CPU0 Fetch Decode Execute Memory Writeback 1,7 CPU1 Fetch Decode Execute Memory Writeback 2,7 CPU2 Fetch Decode Execute Memory Writeback 3,7 CPU3 Fetch Decode Execute Memory Writeback 7,0 6,0 5,0 4,0 GPU ARCHITECTURES: A CPU PERSPECTIVE 11 Data Parallelism: A MIMD Approach Multiple Instruction Multiple Data Split independent work over multiple processors Program color out = f(color in ) Program color out = f(color in ) Program color out = f(color in ) Program color out = f(color in ) 0,7 CPU0 When Fetch work Decode is identical Execute Memory (same Writeback program): 1,7 2,7 CPU1 Single Program Multiple Data (SPMD) Fetch Decode Execute Memory Writeback (Subcategory of MIMD) CPU2 Fetch Decode Execute Memory Writeback 3,7 CPU3 Fetch Decode Execute Memory Writeback 7,0 6,0 5,0 4,0 GPU ARCHITECTURES: A CPU PERSPECTIVE 12 6

Data Parallelism: An SPMD Approach Program color out = f(color in ) Program color out = f(color in ) Program color out = f(color in ) Program color out = f(color in ) Single Program Multiple Data Split identical, independent work over multiple processors 0,7 CPU0 Fetch Decode Execute Memory Writeback 1,7 CPU1 Fetch Decode Execute Memory Writeback 2,7 CPU2 Fetch Decode Execute Memory Writeback 3,7 CPU3 Fetch Decode Execute Memory Writeback 7,0 6,0 5,0 4,0 GPU ARCHITECTURES: A CPU PERSPECTIVE 13 Data Parallelism: A SIMD Approach Single Instruction Multiple Data Split identical, independent work over multiple execution units (lanes) More efficient: Eliminate redundant fetch/decode 0,7 1,7 Program color out = f(color in ) 2,7 3,7 Fetch Decode CPU0 Execute Memory Writeback Execute Memory Writeback Execute Memory Writeback Execute Memory Writeback 7,0 6,0 5,0 4,0 GPU ARCHITECTURES: A CPU PERSPECTIVE 14 7

SIMD: A Closer Look One Thread + Data Parallel Ops Single PC, single register file 0,7 1,7 Program color out = f(color in ) 2,7 3,7 Fetch Decode CPU0 Execute Memory Writeback Execute Memory Writeback Execute Memory Writeback Execute Memory Writeback 7,0 6,0 5,0 4,0 Register File GPU ARCHITECTURES: A CPU PERSPECTIVE 15 Data Parallelism: A Approach Program color out = f(color in ) Single Instruction Multiple Thread Split identical, independent work over multiple lockstep threads Multiple Threads + Scalar Ops One PC, Multiple register files 0,7 1,7 2,7 3,7 Fetch Decode WF0 Execute Memory Writeback Execute Execute Memory Memory Writeback Writeback 7,0 6,0 5,0 4,0 Execute Memory Writeback GPU ARCHITECTURES: A CPU PERSPECTIVE 16 8

Terminology Headache #1 It s common to interchange SIMD and GPU ARCHITECTURES: A CPU PERSPECTIVE 17 Data Parallel Execution Models MIMD/SPMD SIMD/Vector Multiple independent threads One thread with wide execution datapath Multiple lockstep threads GPU ARCHITECTURES: A CPU PERSPECTIVE 18 9

Execution Model Comparison MIMD/SPMD SIMD/Vector Example Architecture Multicore CPUs x86 SSE/AVX GPUs Pros More general: supports TLP Can mix sequential & parallel code Easier to program Gather/Scatter operations Cons Inefficient for data parallelism Gather/Scatter can be awkward Divergence kills performance GPU ARCHITECTURES: A CPU PERSPECTIVE 19 GPUs and Memory Recall: GPUs perform Streaming computation Streaming memory access GPU DRAM latency: 100s of GPU cycles How do we keep the GPU busy (hide memory latency)? GPU ARCHITECTURES: A CPU PERSPECTIVE 20 10

Hiding Memory Latency Options from the CPU world: Caches Need spatial/temporal locality OoO/Dynamic Scheduling Need ILP Multicore/Multithreading/SMT Need independent threads GPU ARCHITECTURES: A CPU PERSPECTIVE 21 Multicore Multithreaded Many threads grouped together into GPU Core threads in a group SMT threads in a CPU core Unlike CPU, groups are exposed to programmers Multiple GPU Cores GPU GPU Core GPU Core GPU ARCHITECTURES: A CPU PERSPECTIVE 22 11

Multicore Multithreaded Many threads grouped together into GPU Core threads in a group SMT threads in a CPU core Unlike CPU, groups are exposed to programmers Multiple GPU Cores This is a GPU Architecture (Whew!) GPU GPU Core GPU Core GPU ARCHITECTURES: A CPU PERSPECTIVE 23 Terminology Headaches #2-5 Nvidia/CUDA AMD/OpenCL Derek s CPU Analogy CUDA Processor Processing Element Lane CUDA Core SIMD Unit Pipeline GPU Core Streaming Multiprocessor Compute Unit Core GPU Device GPU Device Device GPU ARCHITECTURES: A CPU PERSPECTIVE 24 12

GPU Programming Models OpenCL GPU ARCHITECTURES: A CPU PERSPECTIVE 25 GPU Programming Models CUDA Compute Unified Device Architecture Developed by Nvidia -- proprietary First serious GPGPU language/environment OpenCL Open Computing Language From makers of OpenGL Wide industry support: AMD, Apple, Qualcomm, Nvidia (begrudgingly), etc. C++ AMP C++ Accelerated Massive Parallelism Microsoft Much higher abstraction that CUDA/OpenCL OpenACC Open Accelerator Like OpenMP for GPUs (semi-auto-parallelize serial code) Much higher abstraction than CUDA/OpenCL 26 13

GPU Programming Models CUDA Compute Unified Device Architecture Developed by Nvidia -- proprietary First serious GPGPU language/environment OpenCL Open Computing Language From makers of OpenGL Wide industry support: AMD, Apple, Qualcomm, Nvidia (begrudgingly), etc. C++ AMP C++ Accelerated Massive Parallelism Microsoft Much higher abstraction that CUDA/OpenCL OpenACC Open Accelerator Like OpenMP for GPUs (semi-auto-parallelize serial code) Much higher abstraction than CUDA/OpenCL 27 OpenCL Early CPU languages were light abstractions of physical hardware E.g., C Early GPU languages are light abstractions of physical hardware OpenCL + CUDA GPU ARCHITECTURES: A CPU PERSPECTIVE 28 14

OpenCL Early CPU languages were light abstractions of physical hardware E.g., C Early GPU languages are light abstractions of physical hardware OpenCL + CUDA GPU Architecture GPU GPU Core GPU Core GPU ARCHITECTURES: A CPU PERSPECTIVE 29 OpenCL Early CPU languages were light abstractions of physical hardware E.g., C Early GPU languages are light abstractions of physical hardware OpenCL + CUDA GPU Architecture GPU OpenCL Model NDRange GPU Core GPU Core Workgroup Workgroup Work-item Wavefront GPU ARCHITECTURES: A CPU PERSPECTIVE 30 15

NDRange N-Dimensional (N = 1, 2, or 3) index space Partitioned into workgroups, wavefronts, and work-items NDRange Workgroup Workgroup GPU ARCHITECTURES: A CPU PERSPECTIVE 31 Kernel Run an NDRange on a kernel (i.e., a function) Same kernel executes for each work-item Smells like MIMD/SPMD Kernel Workitem Workitem Workitem Workitem 0,7 color out = f(color in ) 7,0 1,7 color out = f(color in ) 6,0 2,7 color out = f(color in ) 5,0 3,7 color out = f(color in ) 4,0 GPU ARCHITECTURES: A CPU PERSPECTIVE 32 16

Workgroup Wavefront Wavefront 5/21/2013 Kernel Run an NDRange on a kernel (i.e., a function) Same kernel executes for each work-item Smells like MIMD/SPMD but beware, it s not! Kernel Workitem Workitem Workitem Workitem 0,7 color out = f(color in ) 7,0 1,7 color out = f(color in ) 6,0 2,7 color out = f(color in ) 5,0 3,7 color out = f(color in ) 4,0 GPU ARCHITECTURES: A CPU PERSPECTIVE 33 OpenCL Code kernel void flip_and_recolor( global float3 **in_image, global float3 **out_image, int img_dim_x, int img_dim_y) { int x = get_global_id(1); // get work-item id in dim 1 int y = get_global_id(2); // get work-item id in dim 2 } out_image[img_dim_x - x][img_dim_y - y] = recolor(in_image[x][y]); GPU ARCHITECTURES: A CPU PERSPECTIVE 34 17

Terminology Headaches #6-9 CUDA/Nvidia OpenCL/AMD Henn&Patt Thread Work-item Sequence of SIMD Lane Operations Warp Wavefront Thread of SIMD Instructions Group Block Workgroup Body of vectorized loop Grid NDRange Vectorized loop GPU ARCHITECTURES: A CPU PERSPECTIVE 35 GPU Microarchitecture AMD Graphics Core Next GPU ARCHITECTURES: A CPU PERSPECTIVE 36 18

5/21/2013 GPU Hardware Overview GPU GPU Core GPU GPU Core GDDR5 L2 Cache L1 Cache L1 Cache Local Memory Local Memory GPU ARCHITECTURES: A CPU PERSPECTIVE 37 Compute Unit A GPU Core Compute Unit (CU) Runs Workgroups Contains 4 Units Picks one Unit per cycle for scheduling Unit Runs Wavefronts Each Unit has 10 wavefront instruction buffer Takes 4 cycles to execute one wavefront L1 Cache 10 Wavefront x 4 Units = 40 Active Wavefronts / CU 64 work-items / wavefront x 40 active wavefronts = 2560 Active Work-items / CU Local Memory GPU ARCHITECTURES: A CPU PERSPECTIVE 38 19

Time Registers Registers Registers Registers Registers Registers Registers Registers Registers Registers Registers Registers Registers Registers Registers Registers 5/21/2013 CU Timing Diagram On average: fetch & commit one wavefront / cycle 0 1 2 3 WF1_0 WF1_1 WF1_2 WF1_3 WF4_0 WF4_1 WF4_2 WF4_3 WF8_0 WF8_1 WF8_2 WF8_3 WF2_0 WF2_1 WF2_2 WF2_3 WF5_0 WF5_1 WF5_2 WF5_3 WF9_0 WF9_1 WF9_2 WF3_0 WF3_1 WF3_2 WF3_3 WF6_0 WF6_1 WF6_2 WF6_3 WF10_0 WF10_1 WF3_0 WF3_1 WF3_2 WF3_3 WF7_0 WF7_1 WF7_2 WF7_3 WF11_3 GPU ARCHITECTURES: A CPU PERSPECTIVE 39 Unit A GPU Pipeline Like a wide CPU pipeline except one fetch for entire width 16-wide physical ALU Executes 64-wavefront over 4 cycles. Why?? 64KB register state / Unit Compare to x86 (Bulldozer): ~1KB of physical register file state (~1/64 size) Address Coalescing Unit A key to good memory performance Address Coalescing Unit GPU ARCHITECTURES: A CPU PERSPECTIVE 40 20

Address Coalescing Wavefront: Issue 64 memory requests NDRange Workgroup Workgroup GPU ARCHITECTURES: A CPU PERSPECTIVE 41 Address Coalescing Wavefront: Issue 64 memory requests Common case: work-items in same wavefront touch same cache block Coalescing: Merge many work-items requests into single cache block request Important for performance: Reduces bandwidth to DRAM GPU ARCHITECTURES: A CPU PERSPECTIVE 42 21

GPU Memory GPUs have caches. GPU ARCHITECTURES: A CPU PERSPECTIVE 43 Not Your CPU s Cache By the numbers: Bulldozer FX-8170 vs. GCN Radeon HD 7970 CPU (Bulldozer) GPU (GCN) L1 data cache capacity 16KB 16 KB Active threads (work-items) sharing L1 D Cache 1 2560 L1 dcache capacity / thread 16KB 6.4 bytes Last level cache (LLC) capacity 8MB 768KB Active threads (work-items) sharing LLC 8 81,920 LLC capacity / thread 1MB 9.6 bytes GPU ARCHITECTURES: A CPU PERSPECTIVE 44 22

5/21/2013 GPU Caches Maximize throughput, not hide latency Not there for either spatial or temporal locality L1 Cache: Coalesce requests to same cache block by different work-items i.e., streaming thread locality? Keep block around just long enough for each work-item to hit once Ultimate goal: Reduce bandwidth to DRAM L2 Cache: DRAM staging buffer + some instruction reuse Ultimate goal: Tolerate spikes in DRAM bandwidth If there is any spatial/temporal locality: Use local memory (scratchpad) GPU ARCHITECTURES: A CPU PERSPECTIVE 45 Scratchpad Memory GPUs have scratchpads (Local Memory) Separate address space Managed by software: Rename address Manage capacity manual fill/eviction L1 Cache Allocated to a workgroup i.e., shared by wavefronts in workgroup Local Memory GPU ARCHITECTURES: A CPU PERSPECTIVE 46 23

5/21/2013 Terminology Headache #10 GPUs have scratchpads (Local Memory) Separate address space Managed by software: Rename address Manage capacity manual fill/eviction L1 Cache Allocated to a workgroup i.e., shared by wavefronts in workgroup Local Memory Nvidia calls Local Memory Shared Memory. AMD sometimes calls it Group Memory. GPU ARCHITECTURES: A CPU PERSPECTIVE 47 Example System: Radeon HD 7970 High-end part 32 Compute Units: 81,920 Active work-items 32 CUs * 4 Units * 16 ALUs = 2048 Max FP ops/cycle 264 GB/s Max memory bandwidth 925 MHz engine clock 3.79 TFLOPS single precision (accounting trickery: FMA) 210W Max Power (Chip) >350W Max Power (card) 100W idle power (card) GPU ARCHITECTURES: A CPU PERSPECTIVE 48 24

Radeon HD 7990 - Cooking Two 7970s on one card: 375W (AMD Official) 450W (OEM) GPU ARCHITECTURES: A CPU PERSPECTIVE 49 Recap Data Parallelism: Identical, Independent work over multiple data inputs GPU version: Add streaming access pattern Data Parallel Execution Models: MIMD, SIMD, GPU Execution Model: Multicore Multithreaded OpenCL Programming Model NDRange over workgroup/wavefront Modern GPU Microarchitecture: AMD Graphics Core Next (GCN) Compute Unit ( GPU Core ): 4 Units Unit ( GPU Pipeline ): 16-wide ALU pipe (16x4 execution) Memory: designed to stream GPUs: Great for data parallelism. Bad for everything else. GPU ARCHITECTURES: A CPU PERSPECTIVE 50 25

Advanced Topics GPU Limitations, Future of GPGPU 51 Choose Your Own Adventure! Control Flow & Branch Divergence Memory Divergence When GPUs talk Wavefront communication GPU coherence GPU consistency Future of GPUs: What s next? 52 26

Control Flow Consider conditional branch: One PC Multiple data (i.e., multiple conditions) if (x <= 0) y = 0; else y = x;? 53 Control Flow Work-items in wavefront run in lockstep Don t all have to commit Branching through predication Active lane: commit result Inactive lane: throw away result All lanes active at start: 1111 if (x <= 0) y = 0; else y = x; Branch set execution mask: 1000 Else invert execution mask: 0111 Converge Reset execution mask: 1111 54 27

Control Flow Work-items in wavefront run in lockstep Don t all have to commit Branching through predication Active lane: commit result Inactive lane: throw away result if (x <= 0) y = 0; else y = x; Branch divergence All lanes active at start: 1111 Branch set execution mask: 1000 Else invert execution mask: 0111 Converge Reset execution mask: 1111 55 Branch Divergence When control flow diverges, all lanes take all paths Divergence Kills Performance GPU ARCHITECTURES: A CPU PERSPECTIVE 56 28

Beware! Divergence isn t just a performance problem: global int lock = false; kernel void spinlock_lock( ) { // acquire lock while (lock == false) { // cas = compare and swap: // atomically { // if (lock == false) // lock = true; // } atomic_cas(lock, false, true); } } GPU ARCHITECTURES: A CPU PERSPECTIVE 57 Memory Bandwidth Lane 0 Lane 1 Lane 2 Lane 3 DRAM Bank 0 Bank 1 Bank 2 Bank 3 -- Parallel Access GPU ARCHITECTURES: A CPU PERSPECTIVE 58 29

Memory Bandwidth Lane 0 Lane 1 Lane 2 Lane 3 DRAM Bank 0 Bank 1 Bank 2 Bank 3 -- Sequential Access GPU ARCHITECTURES: A CPU PERSPECTIVE 59 Memory Bandwidth Lane 0 Lane 1 Lane 2 Lane 3 Memory divergence DRAM Bank 0 Bank 1 Bank 2 Bank 3 -- Sequential Access GPU ARCHITECTURES: A CPU PERSPECTIVE 60 30

Memory Divergence One work-item stalls entire wavefront must stall Cause: Bank conflicts, cache misses Data layout & partitioning is important GPU ARCHITECTURES: A CPU PERSPECTIVE 61 Memory Divergence One work-item stalls entire wavefront must stall Cause: Bank conflicts, cache misses Data layout & partitioning is important Divergence Kills Performance GPU ARCHITECTURES: A CPU PERSPECTIVE 62 31

Communication and Synchronization Work-items can communicate with: Work-items in same wavefront No special sync needed they are lockstep! Work-items in different wavefront, same workgroup Local barrier Work-items in different wavefront, different workgroup OpenCL 1.x: Nope CUDA 4.x: Yes, but complicated GPU ARCHITECTURES: A CPU PERSPECTIVE 63 GPU Consistency Models Very weak guarantee: Program order respected within single work-item All other bets are off Safety net: Fence make sure all previous accesses are visible before proceeding Built-in barriers are also fences A wrench: GPU fences are scoped only apply to subset of work-items in system E.g., local barrier Take-away: confusion abounds GPU ARCHITECTURES: A CPU PERSPECTIVE 64 32

GPU Coherence? Notice: GPU consistency model does not require coherence i.e., Single Writer, Multiple Reader Marketing claims they are coherent GPU Coherence : Nvidia: disable private caches AMD: flush/invalidate entire cache at fences GPU ARCHITECTURES: A CPU PERSPECTIVE 65 GPU Architecture Research Blending with CPU architecture: Dynamic scheduling / dynamic wavefront re-org Work-items have more locality than we think Tighter integration with CPU on SOC: Fast kernel launch Exploit fine-grained parallel region: Remember Amdahl s law Common shared memory Reliability: Historically: Who notices a bad pixel? Future: GPU compute demands correctness Power: Mobile, mobile mobile!!! GPU ARCHITECTURES: A CPU PERSPECTIVE 66 33

Computer Economics 101 GPU Compute is cool + gaining steam, but Is a 0 billion dollar industry (to quote Mark Hill) GPU design priorities: 1. Graphics 2. Graphics N-1. Graphics N. GPU Compute Moral of the story: GPU won t become a CPU (nor should it) GPU ARCHITECTURES: A CPU PERSPECTIVE 67 34