CS6963 L4: Hardware Execution Model and Overview January 26, 2009.

Slides:



Advertisements
Similar presentations
Vectors, SIMD Extensions and GPUs COMP 4611 Tutorial 11 Nov. 26,
Advertisements

Computer Organization and Architecture
Lecture 38: Chapter 7: Multiprocessors Today’s topic –Vector processors –GPUs –An example 1.
Instructor Notes We describe motivation for talking about underlying device architecture because device architecture is often avoided in conventional.
Optimization on Kepler Zehuan Wang
The University of Adelaide, School of Computer Science
1 Threading Hardware in G80. 2 Sources Slides by ECE 498 AL : Programming Massively Parallel Processors : Wen-Mei Hwu John Nickolls, NVIDIA.
L15: Review for Midterm. Administrative Project proposals due today at 5PM (hard deadline) – handin cs6963 prop March 31, MIDTERM in class L15: Review.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 Structuring Parallel Algorithms.
L9: Control Flow CS6963. Administrative Project proposals Due 5PM, Friday, March 13 (hard deadline) MPM Sequential code and information posted on website.
L8: Memory Hierarchy Optimization, Bandwidth CS6963.
CS6963 L2: Hardware Execution Model and Overview January 25, 2010.
1 Lecture 10: ILP Innovations Today: ILP innovations and SMT (Section 3.5)
L8: Control Flow CS6963. Administrative Next assignment on the website – Description at end of class – Due Wednesday, Feb. 17, 5PM (done?) – Use handin.
1 Threading Hardware in G80. 2 Sources Slides by ECE 498 AL : Programming Massively Parallel Processors : Wen-Mei Hwu John Nickolls, NVIDIA.
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Lectures 7: Threading Hardware in G80.
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Lectures 8: Memory Hardware in G80.
1 Chapter 04 Authors: John Hennessy & David Patterson.
CS6963 L18: Introduction to CUDA November 5, 2009.
Introduction to CUDA (1 of 2) Patrick Cozzi University of Pennsylvania CIS Spring 2012.
Introduction to CUDA 1 of 2 Patrick Cozzi University of Pennsylvania CIS Fall 2012.
© David Kirk/NVIDIA and Wen-mei W. Hwu Taiwan, June 30-July 2, Taiwan 2008 CUDA Course Programming Massively Parallel Processors: the CUDA experience.
L19: Advanced CUDA Issues November 10, Administrative CLASS CANCELLED, TUESDAY, NOVEMBER 17 Guest Lecture, November 19, Ganesh Gopalakrishnan Thursday,
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE498AL, University of Illinois, Urbana-Champaign 1 Programming Massively Parallel Processors CUDA Threads.
© David Kirk/NVIDIA and Wen-mei W. Hwu Urbana, Illinois, August 10-14, VSCSE Summer School 2009 Many-core processors for Science and Engineering.
L8: Writing Correct Programs, cont. and Control Flow L8: Control Flow CS6235.
GPU in HPC Scott A. Friedman ATS Research Computing Technologies.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 CS 395 Winter 2014 Lecture 17 Introduction to Accelerator.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Lectures 9: Memory Hardware in G80.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 Control Flow/ Thread Execution.
CUDA Performance Patrick Cozzi University of Pennsylvania CIS Fall
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 Basic Parallel Programming Concepts Computational.
CUDA - 2.
ME964 High Performance Computing for Engineering Applications
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE498AL, University of Illinois, Urbana-Champaign 1 Programming Massively Parallel Processors Lecture.
CUDA Performance Considerations (1 of 2) Patrick Cozzi University of Pennsylvania CIS Spring 2011.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Lectures 8: Threading Hardware in G80.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE498AL, University of Illinois, Urbana-Champaign 1 ECE498AL Lecture 4: CUDA Threads – Part 2.
L17: CUDA, cont. Execution Model and Memory Hierarchy November 6, 2012.
1)Leverage raw computational power of GPU  Magnitude performance gains possible.
Introduction to CUDA (1 of n*) Patrick Cozzi University of Pennsylvania CIS Spring 2011 * Where n is 2 or 3.
Efficient Parallel CKY Parsing on GPUs Youngmin Yi (University of Seoul) Chao-Yue Lai (UC Berkeley) Slav Petrov (Google Research) Kurt Keutzer (UC Berkeley)
ME964 High Performance Computing for Engineering Applications Execution Model and Its Hardware Support Sept. 25, 2008.
L8: Control Flow CS6235. Administrative Next assignment available – Goals of assignment: – simple memory hierarchy management – block-thread decomposition.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 408, University of Illinois, Urbana-Champaign 1 Programming Massively Parallel Processors Lecture.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 408, University of Illinois, Urbana-Champaign 1 Programming Massively Parallel Processors Performance.
Introduction to CUDA 1 of 2 Patrick Cozzi University of Pennsylvania CIS Fall 2014.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Spring 2010 Programming Massively Parallel.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE498AL, University of Illinois, Urbana-Champaign 1 CUDA Threads.
Sunpyo Hong, Hyesoon Kim
Computer Architecture Lecture 24 Parallel Processing Ralph Grishman November 2015 NYU.
L14: CUDA, cont. Execution Model and Memory Hierarchy October 27, 2011.
L17: CUDA, cont. October 28, Final Project Purpose: -A chance to dig in deeper into a parallel programming model and explore concepts. -Present.
My Coordinates Office EM G.27 contact time:
CS427 Multicore Architecture and Parallel Computing
ECE 498AL Spring 2010 Lectures 8: Threading & Memory Hardware in G80
L2: Hardware Execution Model and Overview
Mattan Erez The University of Texas at Austin
© David Kirk/NVIDIA and Wen-mei W. Hwu,
© David Kirk/NVIDIA and Wen-mei W. Hwu,
Programming Massively Parallel Processors Performance Considerations
Mattan Erez The University of Texas at Austin
ECE498AL Spring 2010 Lecture 4: CUDA Threads – Part 2
Mattan Erez The University of Texas at Austin
ECE 498AL Lecture 10: Control Flow
© David Kirk/NVIDIA and Wen-mei W. Hwu,
Mattan Erez The University of Texas at Austin
ECE 498AL Spring 2010 Lecture 10: Control Flow
6- General Purpose GPU Programming
CIS 6930: Chip Multiprocessor: Parallel Architecture and Programming
Presentation transcript:

CS6963 L4: Hardware Execution Model and Overview January 26, 2009

Administrative First assignment out, due Friday at 5PM – Any questions? New mailing list: – – Please use for all questions suitable for the whole class – Feel free to answer your classmates questions! 2 L4: Hardware Overview CS6963

Outline Single Instruction Multiple Data (SIMD) Multithreading Scheduling instructions for SIMD, multithreaded multiprocessor How it comes together Reading: Ch 2.3 in Grama et al. 3 L4: Hardware Overview CS6963

Recall Execution Model I. SIMD Execution of warpsize=M threads (from single block) – Result is a set of instruction streams roughly equal to # blocks in thread divided by warpsize II. Multithreaded Execution across different instruction streams within block – Also possibly across different blocks if there are more blocks than SMs III. Each block mapped to single SM – No direct interaction across SMs Device Multiprocessor N Multiprocessor 2 Multiprocessor 1 Device memory Shared Memory Instruction Unit Processor 1 Registers … Processor 2 Registers Processor M Registers Constant Cache Texture Cache 4 L4: Hardware Overview CS6963

5 L4: Hardware Overview Predominant Control Mechanisms: Some definitions NameMeaningExamples Single Instruction, Multiple Data (SIMD) A single thread of control, same computation applied across “vector” elts Array notation as in Fortran 95: A[1:n] = A[1:n] + B[1:n] Kernel fns w/in block: compute >> Multiple Instruction, Multiple Data (MIMD) Multiple threads of control, processors periodically synch OpenMP parallel loop: forall (i=0; i<n; i++) Kernel fns across blocks compute >> Single Program, Multiple Data (SPMD) Multiple threads of control, but each processor executes same code Processor-specific code: if ($threadIdx == 0) { }

Slide source: Ananth Grama 6 L4: Hardware Overview SIMD vs. MIMD Processors

I. SIMD Motivation: – Data-parallel computations map well to architectures that apply the same computation repeatedly to different data – Conserve control units and simplify coordination Analogy to light switch 7 L4: Hardware Overview

Example SIMD Execution “Count 6” kernel function d_out[threadIdx.x] = 0; for (int i=0; i<SIZE/BLOCKSIZE; i++) { int val = d_in[i*BLOCKSIZE + threadIdx.x]; d_out[threadIdx.x] += compare(val, 6); } P0P0 P0P0 Instruction Unit Instruction Unit P!P! P!P! P M-1 Reg... Memory Reg 8 L4: Hardware Overview

threadIdx Example SIMD Execution “Count 6” kernel function d_out[threadIdx.x] = 0; for (int i=0; i<SIZE/BLOCKSIZE; i++) { int val = d_in[i*BLOCKSIZE + threadIdx.x]; d_out[threadIdx.x] += compare(val, 6); } P0P0 P0P0 Instruction Unit Instruction Unit P!P! P!P! P M-1... Memory Reg LDC 0, &(dout+ threadIdx) threadIdx + ++ &dout Each “core” initializes data from addr based on its own threadIdx 9 L4: Hardware Overview CS6963

Example SIMD Execution “Count 6” kernel function d_out[threadIdx.x] = 0; for (int i=0; i<SIZE/BLOCKSIZE; i++) { int val = d_in[i*BLOCKSIZE + threadIdx.x]; d_out[threadIdx.x] += compare(val, 6); } P0P0 P0P0 Instruction Unit Instruction Unit P!P! P!P! P M-1... Memory Reg /* int i=0; */ LDC 0, R3 Each “core” initializes its own R L4: Hardware Overview CS6963

Example SIMD Execution “Count 6” kernel function d_out[threadIdx.x] = 0; for (int i=0; i<SIZE/BLOCKSIZE; i++) { int val = d_in[i*BLOCKSIZE + threadIdx.x]; d_out[threadIdx.x] += compare(val, 6); } P0P0 P0P0 Instruction Unit Instruction Unit P!P! P!P! P M-1 Reg... Memory Reg /* i*BLOCKSIZE + threadIdx */ LDC BLOCKSIZE,R2 MUL R1, R3, R2 ADD R4, R1, RO Each “core” performs same operations from its own registers Etc. 11 L4: Hardware Overview

CS L4: Hardware Overview 12 Overview of SIMD Programming Vector architectures Early examples of SIMD supercomputers TODAY Mostly – Multimedia extensions such as SSE-3 – Graphics and games processors (example, IBM Cell) – Accelerators (e.g., ClearSpeed) Is there a dominant SIMD programming model? – Unfortunately, NO!!! Why not? – Vector architectures were programmed by scientists – Multimedia extension architectures are programmed by systems programmers (almost assembly language!) or code is automatically generated by a compiler – GPUs are programmed by games developers (domain- specific) – Accelerators typically use their own proprietary tools

Slide source: Jaewook Shin 13 L4: Hardware Overview 13 Aside: Multimedia Extensions like SSE-3 COMPLETELY DIFFERENT ARCHITECTURE! At the core of multimedia extensions – SIMD parallelism – Variable-sized data fields: Vector length = register width / type size V V0 V1 V2 V3 V4 V5 Sixteen 8-bit Operands Eight 16-bit Operands Four 32-bit Operands Example: PowerPC AltiVec WIDE UNIT

Slide source: Jaewook Shin 14 L4: Hardware Overview Aside: Multimedia Extensions Scalar vs. SIMD Operation Scalar: add r1,r2,r r3 r2 r1 SIMD: vadd v1,v2,v v3 v2 v1 lanes

II. Multithreading: Motivation Each arithmetic instruction includes the following sequence Memory latency, the time in cycles to access memory, limits utilization of compute engines ActivityCostNote Load operandsAs much as O(100) cyclesDepends on location ComputeO(1) cyclesAccesses registers Store resultAs much as O(100) cyclesDepends on location 15 L4: Hardware Overview CS6963

Thread-Level Parallelism Motivation: – a single thread leaves a processor under-utilized for most of the time – by doubling processor area, single thread performance barely improves Strategies for thread-level parallelism: – multiple threads share the same large processor reduces under-utilization, efficient resource allocation Multi-Threading – each thread executes on its own mini processor simple design, low interference between threads Multi-Processing Slide source: Al Davis 16 L4: Hardware Overview

What Resources are Shared? Multiple threads are simultaneously active (in other words, a new thread can start without a context switch) For correctness, each thread needs its own program counter (PC), and its own logical regs (on this hardware, each gets its own physical regs) Functional units, instruction unit, i-cache shared by all threads Warp (Instruction Stream) Instructions Issued CS L4: Hardware Overview

Aside: Multithreading Historically, supercomputers targeting non- numeric computation HEP, Tera MTA Now common in commodity microprocessors – Simultaneous multithreading: Multiple threads may come from different streams, can issue from multiple streams in single issue slot Alpha and Pentium 4 are examples CUDA somewhat simplified: – A full warp scheduled at a time 18 L4: Hardware Overview CS6963

© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign Thread Scheduling/Execution Each Thread Blocks is divided in 32- thread Warps –This is an implementation decision, not part of the CUDA programming model Warps are scheduling units in SM If 3 blocks are assigned to an SM and each Block has 256 threads, how many Warps are there in an SM? –Each Block is divided into 256/32 = 8 Warps –There are 8 * 3 = 24 Warps –At any point in time, only one of the 24 Warps will be selected for instruction fetch and execution. … t0 t1 t2 … t31 … … … Block 1 WarpsBlock 2 Warps SP SFU SP SFU Instruction Fetch/Dispatch Instruction L1Data L1 Streaming Multiprocessor Shared Memory 19 L4: Hardware Overview

© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign SM Warp Scheduling SM hardware implements zero- overhead Warp scheduling – Warps whose next instruction has its operands ready for consumption are eligible for execution – Eligible Warps are selected for execution on a prioritized scheduling policy – All threads in a Warp execute the same instruction when selected 4 clock cycles needed to dispatch the same instruction for all threads in a Warp in G80 – If one global memory access is needed for every 4 instructions – A minimal of 13 Warps are needed to fully tolerate 200-cycle memory latency warp 8 instruction 11 SM multithreaded Warp scheduler warp 1 instruction 42 warp 3 instruction 95 warp 8 instruction time warp 3 instruction L4: Hardware Overview

© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign SM Instruction Buffer – Warp Scheduling Fetch one warp instruction/cycle – from instruction L1 cache – into any instruction buffer slot Issue one “ready-to-go” warp instruction/cycle – from any warp - instruction buffer slot – operand scoreboarding used to prevent hazards Issue selection based on round- robin/age of warp SM broadcasts the same instruction to 32 Threads of a Warp I$ L1 Multithreaded Instruction Buffer R F C$ L1 Shared Mem Operand Select MADSFU 21 L4: Hardware Overview

Scoreboarding How to determine if a thread is ready to execute? A scoreboard is a table in hardware that tracks – instructions being fetched, issued, executed – resources (functional units and operands) they need – which instructions modify which registers Old concept from CDC 6600 (1960s) to separate memory and computation 22 L4: Hardware Overview CS6963

Scoreboarding from Example Consider three separate instruction streams: warp1, warp3 and warp8 warp 8 instruction 11 warp 1 instruction 42 warp 3 instruction 95 warp 8 instruction warp 3 instruction 96 t=k t=k+1 t=k+2 t=l>k t=l+1 WarpCurrent Instruction State Warp 142Computing Warp 395Computing Warp 811Operands ready to go … Schedule at time k 23 L4: Hardware Overview CS6963

Scoreboarding from Example Consider three separate instruction streams: warp1, warp3 and warp8 warp 8 instruction 11 warp 1 instruction 42 warp 3 instruction 95 warp 8 instruction warp 3 instruction 96 t=k t=k+1 t=k+2 t=l>k t=l+1 WarpCurrent Instruction State Warp 142Ready to write result Warp 395Computing Warp 811Computing … Schedule at time k+1 24 L4: Hardware Overview CS6963

© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign Scoreboarding All register operands of all instructions in the Instruction Buffer are scoreboarded – Status becomes ready after the needed values are deposited – prevents hazards – cleared instructions are eligible for issue Decoupled Memory/Processor pipelines – any thread can continue to issue instructions until scoreboarding prevents issue – allows Memory/Processor ops to proceed in shadow of Memory/Processor ops 25 L4: Hardware Overview

III. How it Comes Together Each block mapped to different SM If #blocks in a grid exceeds number of SMs, – multiple blocks mapped to an SM – treated independently – provides more warps to scheduler so good as long as resources not exceeded Within a block, threads observe SIMD model, and synchronize using __syncthreads() Across blocks, interaction through global memory 26 L4: Hardware Overview CS6963

© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign Streaming Multiprocessor (SM) –8 Streaming Processors (SP) –2 Super Function Units (SFU) Multi-threaded instruction dispatch –1 to 512 threads active –Shared instruction fetch per 32 threads –Cover latency of texture/memory loads 20+ GFLOPS 16 KB shared memory DRAM texture and memory access SP SFU SP SFU Instruction Fetch/Dispatch Instruction L1Data L1 Streaming Multiprocessor Shared Memory 27 L4: Hardware Overview

Summary of Lecture SIMD execution model within a warp, and conceptually within a block MIMD execution model across blocks Multithreading of SMs used to hide memory latency Motivation for lots of threads to be concurrently active Scoreboarding used to track warps ready to execute 28 L4: Hardware Overview CS6963

What’s Coming Next time: – Correctness of parallelization (deferred from today) Next week: – Managing the shared memories February 18: – Presentation on MPM by Jim Guilkey 29 L4: Hardware Overview CS6963