The Cray 1 a vector supercomputer The first

  • Slides: 36
Download presentation
The Cray 1, a vector supercomputer. The first model ran at 80 MHz but

The Cray 1, a vector supercomputer. The first model ran at 80 MHz but could retire 2 instructions/cycle for a peak of 160 MIPS. However, it could reach 250 MFLOPS using vectors. 1

COMP 740: Computer Architecture and Implementation Montek Singh Apr 13, 2015 Topic: Vector Processing

COMP 740: Computer Architecture and Implementation Montek Singh Apr 13, 2015 Topic: Vector Processing 2

Traditional Supercomputer Applications ã Typical application areas l Military research (nuclear weapons, cryptography) l

Traditional Supercomputer Applications ã Typical application areas l Military research (nuclear weapons, cryptography) l Scientific research l Weather forecasting l Oil exploration l Industrial design (car crash simulation) ã All involve huge computations on large data sets ã In 70 s-80 s, Supercomputer Vector Machine 3

Vector Supercomputers ã Epitomized by Cray-1, 1976: l Scalar Unit + Vector Extensions Ø

Vector Supercomputers ã Epitomized by Cray-1, 1976: l Scalar Unit + Vector Extensions Ø Load/Store Architecture Ø Vector Registers Ø Vector Instructions Ø Hardwired Control Ø Highly Pipelined Functional Units Ø Interleaved Memory System Ø No Data Caches Ø No Virtual Memory 4

Cray-1 (1976) 5

Cray-1 (1976) 5

Vector Programming Model Scalar Registers Vector Registers r 15 v 15 r 0 v

Vector Programming Model Scalar Registers Vector Registers r 15 v 15 r 0 v 0 [0] [1] [2] [VLRMAX-1] Vector Length Register Vector Arithmetic Instructions ADDV v 3, v 1, v 2 v 1 v 2 + + [0] [1] + + v 3 Vector Load/Store instr LVWS v 1, (r 1, r 2) LV v 1, r 1 Base, r 1 VLR Stride, r 2 v 1 [VLR-1] Vector Register Memory 6

Vector Code Example # Vector Code # Scalar Code # C code LI VLR,

Vector Code Example # Vector Code # Scalar Code # C code LI VLR, 64 LI R 4, 64 for (i=0; i<64; i++) LV V 1, R 1 C[i] = A[i] + B[i]; loop: LV V 2, R 2 L. D F 0, 0(R 1) ADDV. D V 3, V 1, V 2 L. D F 2, 0(R 2) SV V 3, R 3 ADD. D F 4, F 2, F 0 S. D F 4, 0(R 3) DADDIU R 1, 8 DADDIU R 2, 8 DADDIU R 3, 8 DSUBIU R 4, 1 BNEZ R 4, loop 7

Vector Arithmetic Execution • Use deep pipeline (=> fast clock) to execute element operations

Vector Arithmetic Execution • Use deep pipeline (=> fast clock) to execute element operations • Simplifies control of deep pipeline because elements in vector are independent (=> no hazards!) V 1 V 2 V 3 Six stage multiply pipeline V 3 <- v 1 * v 2 8

Vector Instruction Execution ADDV C, A, B Execution using one pipelined functional unit Execution

Vector Instruction Execution ADDV C, A, B Execution using one pipelined functional unit Execution using four pipelined functional units A[6] B[6] A[24] B[24] A[25] B[25] A[26] B[26] A[27] B[27] A[5] A[4] A[3] B[5] B[4] B[3] A[20] B[20] A[21] B[21] A[22] B[22] A[23] B[23] A[16] B[16] A[17] B[17] A[18] B[18] A[19] B[19] A[12] B[12] A[13] B[13] A[14] B[14] A[15] B[15] C[2] C[8] C[9] C[10] C[11] C[4] C[5] C[6] C[7] C[0] C[1] C[2] C[3] 9

Vector Unit Structure Functional Unit (e. g. , adders) Vector Registers Lane Elements 0,

Vector Unit Structure Functional Unit (e. g. , adders) Vector Registers Lane Elements 0, 4, 8, … Elements 1, 5, 9, … Elements 2, 6, 10, … Elements 3, 7, 11, … Functional Unit (e. g. , multipliers) Vector load-store unit (Memory Subsystem) 10

Vector Memory-Memory vs. Vector Register ã Vector memory-memory instructions hold all vector operands in

Vector Memory-Memory vs. Vector Register ã Vector memory-memory instructions hold all vector operands in main memory ã The first vector machines, CDC Star-100 (‘ 73) and TI ASC (‘ 71), were memory-memory machines ã Cray-1 (’ 76) was first vector register machine Vector Memory-Memory Code Example Source Code for (i=0; i<N; i++) { C[i] = A[i] + B[i]; D[i] = A[i] - B[i]; } ADDV C, A, B SUBV D, A, B Vector Register Code LV V 1, A LV V 2, B ADDV V 3, V 1, V 2 SV V 3, C SUBV V 4, V 1, V 2 SV V 4, D 11

Vector Memory-Memory vs. Vector Register ã Vector memory-memory architectures (VMMA) require greater main memory

Vector Memory-Memory vs. Vector Register ã Vector memory-memory architectures (VMMA) require greater main memory bandwidth, why? l All operands must be read in and out of memory ã VMMAs make if difficult to overlap execution of multiple vector operations, why? l Must check dependencies on memory addresses � Apart from CDC follow-ons (Cyber-205, ETA-10) all major vector machines since Cray-1 have had vector register architectures (we ignore vector memory-memory from now on) 12

Automatic Code Vectorization for (i=0; i < N; i++) C[i] = A[i] + B[i];

Automatic Code Vectorization for (i=0; i < N; i++) C[i] = A[i] + B[i]; Vectorized Code Scalar Sequential Code load Iter. 1 add store load Iter. 2 add store load Time load Iter. 1 load add store Iter. 2 Vector Instruction Vectorization is a massive compile-time reordering of operation sequencing requires extensive loop dependence 13 analysis

Vector Strip Mining Problem: Vector registers have finite length Solution: Break loops into pieces

Vector Strip Mining Problem: Vector registers have finite length Solution: Break loops into pieces that fit into vector registers, “Strip mining” ANDI R 1, N, 63 # N mod 64 MTC 1 VLR, R 1 # Do remainder for (i=0; i<N; i++) C[i] = A[i]+B[i]; loop: LV V 1, RA A B C DSLL R 2, R 1, 3 # Multiply by 8 Remainder DADDU RA, R 2 # Bump pointer + LV V 2, RB DADDU RB, R 2 64 elements ADDV. D V 3, V 1, V 2 + SV V 3, RC DADDU RC, R 2 DSUBU N, N, R 1 # Subtract elements + LI R 1, 64 MTC 1 VLR, R 1 # Reset full length BGTZ N, loop # Any more to do? 14

Vector Instruction Parallelism Can overlap execution of multiple vector instructions l example machine has

Vector Instruction Parallelism Can overlap execution of multiple vector instructions l example machine has 32 elements per vector register and 8 lanes Load Unit load Multiply Unit Add Unit mul add time load mul add Instruction issue Complete 24 operations/cycle while issuing 1 short instruction/cycle 15

Vector Chaining ã Vector version of register bypassing l introduced with Cray-1 LV v

Vector Chaining ã Vector version of register bypassing l introduced with Cray-1 LV v 1 V 2 V 1 V 3 V 4 V 5 MULV v 3, v 1, v 2 ADDV v 5, v 3, v 4 Chain Load Unit Chain Mult. Add Memory 16

Vector Chaining Advantage • Without chaining, must wait for last element of result to

Vector Chaining Advantage • Without chaining, must wait for last element of result to be written before starting dependent instruction Load Mul Time Add ã With chaining, can start dependent instruction as soon as first result appears Load Mul Add 17

Memory operations ã Load/store operations move groups of data between registers and memory ã

Memory operations ã Load/store operations move groups of data between registers and memory ã Types of addressing l Unit stride Ø Contiguous block of information in memory Ø Fastest: always possible to optimize this – LV v 1, r 1 l Non-unit (constant) stride Ø Harder to optimize memory system for all possible strides Ø Prime number of data banks makes it easier to support different strides at full bandwidth – LVWS v 1, (r 1, r 2) 32 18

Vector Memory System Cray-1, 16 banks, 4 cycle bank busy time, 12 cycle latency

Vector Memory System Cray-1, 16 banks, 4 cycle bank busy time, 12 cycle latency • Bank busy time: Cycles between accesses to same bank Base Stride Vector Registers Address Generator + 0 1 2 3 4 5 6 7 8 9 A B C D E F Memory Banks 19

Interleaved Memory Layout ã Great for unit stride: l Contiguous elements in different DRAMs

Interleaved Memory Layout ã Great for unit stride: l Contiguous elements in different DRAMs l Startup time for vector operation is latency of single read ã What about non-unit stride? l Above good for strides that are relatively prime to 16 l Bad for: 2, 4, 8 l Better: prime number of banks…! 20

Vector Conditional Execution Problem: Want to vectorize loops with conditional code: for (i=0; i<N;

Vector Conditional Execution Problem: Want to vectorize loops with conditional code: for (i=0; i<N; i++) if (A[i]>0) then A[i] = B[i]; Solution: Add vector mask (or flag) registers l vector version of predicate registers, 1 bit per element …and maskable vector instructions l vector operation becomes NOP at elements where mask bit is clear 22

Masked Vector Instructions Simple Implementation – execute all N operations, turn off result writeback

Masked Vector Instructions Simple Implementation – execute all N operations, turn off result writeback according to mask Density-Time Implementation l scan mask vector and only execute elements with non-zero masks M[7]=1 A[7] B[7] M[7]=1 M[6]=0 A[6] B[6] M[6]=0 M[5]=1 A[5] B[5] M[4]=1 A[4] B[4] M[3]=0 A[3] B[3] M[5]=1 M[4]=1 M[3]=0 M[2]=0 M[1]=1 M[2]=0 C[2] M[1]=1 C[1] M[0]=0 A[7] B[7] C[5] C[4] C[1] Write data port M[0]=0 C[0] Write Enable Write data port 23

Compress/Expand Operations ã Compress packs non-masked elements from one vector register contiguously at start

Compress/Expand Operations ã Compress packs non-masked elements from one vector register contiguously at start of destination vector register l population count of mask vector gives packed vector length ã Expand performs inverse operation M[7]=1 M[6]=0 M[5]=1 M[4]=1 M[3]=0 M[2]=0 M[1]=1 M[0]=0 A[7] A[6] A[5] A[4] A[3] A[2] A[1] A[0] A[7] A[5] A[4] A[1] Compress A[7] B[6] A[5] A[4] B[3] B[2] A[1] B[0] M[7]=1 M[6]=0 M[5]=1 M[4]=1 M[3]=0 M[2]=0 M[1]=1 M[0]=0 Expand 24

Vector Reductions Problem: Loop-carried dependence on reduction variables sum = 0; for (i=0; i<N;

Vector Reductions Problem: Loop-carried dependence on reduction variables sum = 0; for (i=0; i<N; i++) sum += A[i]; # Loop-carried dependence on sum Solution: Re-associate operations if possible, use binary tree to perform reduction # Rearrange as: sum[0: VL-1] = 0 # for(i=0; i<N; i+=VL) # sum[0: VL-1] += A[i: i+VL-1]; # # Now have VL partial sums in one do { VL = VL/2; sum[0: VL-1] += sum[VL: 2*VL-1] } while (VL>1) Vector of VL partial sums Stripmine VL-sized chunks Vector sum vector register # Halve vector length # Halve no. of partials 25

Vector Execution Time ã Time = f(vector length, data dependencies, struct. hazards) ã Initiation

Vector Execution Time ã Time = f(vector length, data dependencies, struct. hazards) ã Initiation rate: rate that FU consumes vector elements ã ã ã 1: LV (= number of lanes; usually 1 or 2 on Cray T-90) Convoy: set of vector instructions that can begin execution in same clock (no struct. or data hazards) Chime: approx. time for a vector operation m convoys take m chimes; if each vector length is n, then they take approx. m x n clock cycles (ignores overhead; good approximization for long vectors) V 1, Rx ; load vector X 2: MULV V 2, F 0, V 1 ; vector-scalar mult. LV V 3, Ry ; load vector Y 3: ADDV V 4, V 2, V 3 ; add 4: SV Ry, V 4 4 convoys, 1 lane, VL=64 => 4 x 64 = 256 clocks (or 4 clocks per result) ; store the result 26

Older Vector Machines Machine Cray 1 Cray XMP Cray YMP Cray C-90 Cray T-90

Older Vector Machines Machine Cray 1 Cray XMP Cray YMP Cray C-90 Cray T-90 Convex C-1 Convex C-4 Fuj. VP 200 Fuj. VP 300 NEC SX/2 NEC SX/3 Year Clock 1976 80 MHz 1983 120 MHz 1988 166 MHz 1991 240 MHz 1996 455 MHz 1984 10 MHz 1994 133 MHz 1982 133 MHz 1996 100 MHz 1984 160 MHz 1995 400 MHz Regs Elements 8 64 8 128 16 128 8 -256 32 -1024 8+8 K 256+var FUs 6 8 8 4 3 3 3 16 16 27

Newer Vector Computers ã Cray X 1 & X 1 E l MIPS like

Newer Vector Computers ã Cray X 1 & X 1 E l MIPS like ISA + Vector in CMOS ã NEC Earth Simulator l Fastest computer in world for 3 years; 40 TFLOPS l 640 CMOS vector nodes 28

Key Architectural Features of X 1 ã New vector instruction set architecture (ISA) l

Key Architectural Features of X 1 ã New vector instruction set architecture (ISA) l Much larger register set (32 x 64 vector, 64+64 scalar) l 64 - and 32 -bit memory and IEEE arithmetic l Based on 25 years of experience compiling with Cray 1 ISA ã Decoupled Execution l Scalar unit runs ahead of vector unit, doing addressing and control l Hardware dynamically unrolls loops, and issues multiple loops concurrently l Special sync operations keep pipeline full, even across barriers l Allows the processor to perform well on short nested loops ã Scalable, distributed shared memory (DSM) architecture l Memory hierarchy: caches, local memory, remote memory l Low latency, load/store access to entire machine (tens of TBs) l Processors support 1000’s of outstanding refs with flexible addressing l Very high bandwidth network l Coherence protocol, addressing and synchronization optimized for DM 29

Cray X 1 E Mid-life Enhancement ã Technology refresh of the X 1 (0.

Cray X 1 E Mid-life Enhancement ã Technology refresh of the X 1 (0. 13 m) l ~50% faster processors l Scalar performance enhancements l Doubling processor density l Modest increase in memory system bandwidth l Same interconnect and I/O ã Machine upgradeable l Can replace Cray X 1 nodes with X 1 E nodes 30

Multimedia Extensions ã Very short vectors added to existing ISAs for micros ã Usually

Multimedia Extensions ã Very short vectors added to existing ISAs for micros ã Usually 64 -bit registers split into 2 x 32 b or 4 x 16 b or 8 x 8 b ã ã Newer designs have 128 -bit registers (Altivec, SSE 2) Limited instruction set: l no vector length control l no strided load/store or scatter/gather l unit-stride loads must be aligned to 64/128 -bit boundary ã Limited vector register length: l requires superscalar dispatch to keep multiply/add/load units busy l loop unrolling to hide latencies increases register pressure ã Trend towards fuller vector support in microprocessors 35

Vector Instruction Set Advantages ã Compact l one short instruction encodes N operations ã

Vector Instruction Set Advantages ã Compact l one short instruction encodes N operations ã Expressive, tells hardware that these N operations: l are independent l use the same functional unit l access disjoint registers l access registers in the same pattern as previous instructions l access a contiguous block of memory (unit-stride load/store) l access memory in a known pattern (strided load/store) ã Scalable l can run same object code on more parallel pipelines or lanes 36

Operation & Instruction Count: RISC v. Vector Processor Spec 92 fp Program swim 256

Operation & Instruction Count: RISC v. Vector Processor Spec 92 fp Program swim 256 hydro 2 d nasa 7 su 2 cor tomcatv wave 5 mdljdp 2 Operations (Millions) Instructions (Millions) RISC Vector R/V RISC Vector 115 95 1. 1 x 115 0. 8 58 40 1. 4 x 58 0. 8 69 41 1. 7 x 69 2. 2 51 35 1. 4 x 51 1. 8 15 10 1. 4 x 15 1. 3 27 25 1. 1 x 27 7. 2 32 52 0. 6 x 32 15. 8 R/V 142 x 71 x 31 x 29 x 11 x 4 x 2 x Vector reduces ops by 1. 2 X, instructions by 20 X (from F. Quintana, U. Barcelona. ) 37

Vectors Lower Power Single-issue Scalar • • • One instruction fetch, decode, dispatch per

Vectors Lower Power Single-issue Scalar • • • One instruction fetch, decode, dispatch per operation Arbitrary register accesses, adds area and power Loop unrolling and software pipelining for high performance increases instruction cache footprint All data passes through cache; waste power if no temporal locality One TLB lookup per load or store Off-chip access in whole cache lines Vector ã One inst fetch, decode, dispatch per vector ã Structured register accesses ã Smaller code for high performance, less power in instruction cache misses ã Bypass cache ã One TLB lookup per group of loads or stores ã Move only necessary data across chip boundary 38

Superscalar: Worse Energy Efficiency Superscalar • • • Control logic grows quadratically with issue

Superscalar: Worse Energy Efficiency Superscalar • • • Control logic grows quadratically with issue width Control logic consumes energy regardless of available parallelism Speculation to increase visible parallelism wastes energy Vector ã Control logic grows linearly with issue width ã Vector unit switches off when not in use ã Vector instructions expose parallelism without speculation ã Software control of speculation when desired: l Whether to use vector mask or compress/expand for conditionals 39

Vector Applications ã Limited to scientific computing? No! l Multimedia Processing (compress. , graphics,

Vector Applications ã Limited to scientific computing? No! l Multimedia Processing (compress. , graphics, audio synth, image proc. ) l Standard benchmark kernels (Matrix Multiply, FFT, Convolution, Sort) l Lossy Compression (JPEG, MPEG video and audio) l Lossless Compression (Zero removal, RLE, Differencing, LZW) l Cryptography (RSA, DES/IDEA, SHA/MD 5) l Speech and handwriting recognition l Operating systems/Networking (memcpy, memset, parity, checksum) l Databases (hash/join, data mining, image/video serving) l Language run-time support (stdlib, garbage collection) l even SPECint 95 40

Vector Summary ã Vector is alternative model for exploiting ILP ã If code is

Vector Summary ã Vector is alternative model for exploiting ILP ã If code is vectorizable, then simpler hardware, more ã ã ã energy efficient, and better real-time model than Out -of-order machines Design issues include number of lanes, number of functional units, number of vector registers, length of vector registers, exception handling, conditional operations Fundamental design issue is memory bandwidth Will multimedia popularity revive vector architectures? 41