













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














1
1/11/2005 Hiroaki Kobayashi 2
A supercomputer is a hardware and software system
that provides close to the maximum performance that
can currently be achieved.
First Supercomputer 160MFlop/s
Emergence of supercomputers 1/11/2005 Hiroaki Kobayashi 3
Accelerators
1/11/2005 Hiroaki Kobayashi 4
Source: J.Dongarra
1/11/2005 Hiroaki Kobayashi 7
Basic Idea z Extend the instruction set and architecture of the system to support the execution of commonly used vector operations in hardware.
z Vector Operations work on vectors, linear arrays of numbers. Ā Typical vector operation might add two 64-element, floating- point vectors to obtain a single 64-element vector results.
Ā Example: A[i] = B[i] + C[i], i=1,
are represented by a vector instruction of the type
VOP V3, V1, V
where VOP represents a vector operation , and V1, V2, V3 indicate specific vector registers.
The operation performed is: V3 = V1 VOP V
for all register values within each vector registers.
1/11/2005 Hiroaki Kobayashi 8
z A single vector instruction specifies a great deal of work Ā It is equivalent to executing an entire loop. z By using a vector instruction, the compiler or programmer indicates that the computation of each result in the vector is independent of the computation of other results in the same vector and so hardware does not have to check for data hazards within a vector instruction.
z Hardware needs only check for data hazards between two vector instructions once per vector operand, not once for every element within the vectors. z Vector instructions that access memory have a known access pattern. Ā If the vectorās elements are all adjacent, then fetching the vector from a set of heavily interleaved memory banks works very well. z Because an entire loop is replaced by a vector instruction whose behavior is predetermined, control hazards that would normally arise from the loop branch are nonexistent
For these reason, vector operations can be made faster than a sequence of scalar operations on the same number of data items.
1/11/2005 Hiroaki Kobayashi 9
Ā Each vector register is a fixed-length bank holding a single vector and must have at least two read ports and one write port.
Ā Each unit is fully pipelined and can start a new operation on every clock cycle. A control unit is needed to detect hazards, both from conflicts for the functional unit and from conflicts for register accesses.
Ā This is a vector memory unit that loads or stores a vector to or from memory. Vector loads and stores are fully pipelined, so that words can be moved between the vector registers and memory with a bandwidth of 1 word per clock cycle, after an initial latency.
From VR &VR2 (^) To VR
Pre-normalizeFraction addPost-normalizeRound
Pipelined FP ADD Unit
1/11/2005 Hiroaki Kobayashi 10
Remarks:
1/11/2005 Hiroaki Kobayashi 13
z SAXPY (Single-precision a X plus Y) and DAXPY (Double-precision a X plus Y)
¾Many scientific applications include this type of problems.
How is SAXPY/DAXPY translated into scalar and vector codes?
(Assume that the number of elements, or length, of a vector register (64) matches the length of the vector operation)
1/11/2005 Hiroaki Kobayashi 14
This reduction occurs both
MIPS code LD F0,a ;load scalar a DADDIU R4,Rx,#512 ;last address to load Loop LD F2,0(Rx) ;load X(i) MUL.D F2,F2,F0 ;a X(i) LD F4,0(Ry) ;load Y(i) ADD.D F4,F4,F2 ;a X(i) + Y(i) SD 0(Ry),F4 ;store into Y(i) DADDIU Rx,Rx,#8; ;increment index to X DADDIU Ry,Ry,#8 ;increment index to Y DSUBU R20,R4,Rx ;compute bound BNEZ R20, Loop ; check if done
The vector processor greatly reduces the dynamic instruction bandwidth. Executing only 6 instructions versus almost 600 for MIPS.
Vector code LD F0,a ;load scalar a LV V1,Rx ;load vector X MULV.D V2,V1,F0 ;vector-scalar multiply LV V3,Ry ;load vector Y ADDV.D V4,V2,V3 ;add SV Ry,V4 ;store the result
1/11/2005 Hiroaki Kobayashi 15
MIPS code LD F0,a ;load scalar a DADDIU R4,Rx,#512 ;last address to load Loop LD F2,0(Rx) ;load X(i) MUL.D F2,F2,F0 ;a X(i) LD F4,0(Ry) ;load Y(i) ADD.D F4,F4,F2 ;a X(i) + Y(i) SD 0(Ry),F4 ;store into Y(i) DADDIU Rx,Rx,#8; ;increment index to X DADDIU Ry,Ry,#8 ;increment index to Y DSUBU R20,R4,Rx ;compute bound BNEZ R20, Loop ; check if done
Vector code LD F0,a ;load scalar a LV V1,Rx ;load vector X MULV.D V2,V1,F0 ;vector-scalar multiply LV V3,Ry ;load vector Y ADDV.D V4,V2,V3 ;add SV Ry,V4 ;store the result
' In the straightforward MIPS code, every ADD.D must wait for a MUL.D and every S.D must wait for the ADD.D & On the vector processor, each vector instruction will only stall for the first element in each vector, and then subsequent elements will flow smoothly down the pipeline.
Pipeline stalls: only once per vector operation vs. once per vector element!
A large decrease in the frequency of pipeline interlock in vector processing
1/11/2005 Hiroaki Kobayashi 16
Ā Length of the operand vectors Ā Structural hazards among the operations Ā Data dependency
Ā Initiation rate: the rate at which a vector unit consumes new operands, and produces new results.
Ā One lane with an initiation rate of one element per clock cycle for individual operations Ā Notion of a convoy and a chime Ā A convoy is a set of vector instructions that could potentially begin execution together in one clock period. Ā The instructions in a convoy must not contain any structural hazards or data hazards Ā A timing metric, called chime , can be used for estimating the performance of a vector sequence consisting of convoys. Ā A chime is the unit of time taken to execute one convoy.
1/11/2005 Hiroaki Kobayashi 19
Question: If the startup overhead is assumed as shown in the table, Show the time that each convoy can begin and total number of cycles needed, and how does the time compare to the chime approximation for a vector length of length 64?
Add unit 6
Multiply unit 7
Load and store unit 12
Start-up overhead (cycles)
Unit
Start-up overhead
Convoy Starting time First-result time Last-result time
Answer
Time per result for a vector of length 64 is 4+(41/64)=4.64 clock cycles
Start-up time add a 16% overhead to the execution time!
1/11/2005 Hiroaki Kobayashi 20
z The start-up time for a load is the time to get the first word from memory into a register Ā If the rest of the vector can be supplied without stalling, then the vector initiation rate is equal to the rate at which new words are fetched or stored. Ā Unlike simpler functional units, the initiation rate may not necessarily be 1 clock because memory bank stalls can reduce effective throughput.
Vector load 12
Vector divide 20
Vector multiply 7
Vector add 6
Start-up penalty
Operation
Startup-penalties of Cray 1
To maintain an initiation rate of 1 word fetched or stored per clock, the memory system must be capable of producing or accepting this much data
Banked Memory System
1/11/2005 Hiroaki Kobayashi 21
Three primary reasons for use of memory banks for vector processing, rather than simple interleaving.
Memory System
Vector Processors
Banks
Time
Pipeline Memory latency cycle
Memory transaction
1/11/2005 Hiroaki Kobayashi 22
Cray T z 2.167 ns CPU clock cycle z 32 processors, each capable of four loads and two stores per CPU clock cycle z SRAM memory cycle of 15ns
Calculate the minimum number of memory banks required to allow all CPU to run at full memory bandwidth
192 7 = 1344 memory Banks! But actually, 1024 memory banks are adopted (later model introduce synchronous DRAM for providing sufficient bandwidth).
1/11/2005 Hiroaki Kobayashi 25
do 10 I = 1,n 10 Y(i) = a * X(i) + Y(i)
Strip mining
low = VL = (nmod MVL) /* find the odd-size piece / do 1 j = 0, (n / MVL) / outer loop / do 10 i = low, low + VL ā 1 / runs for length VL / Y(i) = a * X(i) + Y(i) / main operation / 10 continue low = low + VL / start of next vector / VL = MVL / reset the length to max */ 1 continue The inner loop of the code is vectorizable with length VL.
The variablem is used for the expression (n mod MVL)
1/11/2005 Hiroaki Kobayashi 26
z There are two key factors that contribute to the running time of a strip-mined loop consisting of a sequence of convoys:
z Total running time for a vector sequence operating on a vector of length n , called T n :
T n = ┠n / MVL⤠(T (^) loop + T (^) start ) + n T (^) chime
T (^) start , T (^) loop and T (^) chime are compiler and processor dependent Ā The register allocation and scheduling of the instructions affect both what goes in a convoy and the start-up overhead of each convoy
1/11/2005 Hiroaki Kobayashi 27
z What is the execution time for the vector operation A = B s, where s is a scalar and the length of the vector A and B is 200?
Assume z The addresses of A and B are initially in Ra and Rb , s is in Fs, and R always holds 0. z T (^) loop is a constant value of 15 from Cray-1 data.
1/11/2005 Hiroaki Kobayashi 28
Generated Code:
DADDUI R2,R0,#1600 ;total # of bytes in vector DADDU R2,R2,Ra ;address of the end of A vector DADDUI R1,R0,#8 ;loads length of 1 st^ segment MTC1 VLR,R1 ;load vector length in VLR DADDUI R1,R0,#64 ;length in bytes of 1 st^ segments DADDUI R3,R0,#64 ;vector length of other segments Loop:LV V1,Rb ;load B MULVS.D V2,V1,Fs ;vector * scalar SV Ra,V2 ;store A DADDU Ra,Ra,R1 ;address of next segment of A DADDU Rb,Rb,R1 ;address of next segment of B DADDUI R1,R0,#512 ;load byte offset next segment MTC1 VLR,R3 ;set length to 64 elements DSUBU R4,R2,Ra ;at the end of A? BNEZ R4,Loop ;if not, go back
The execution time per element with all start-up costs is 784/200=3.9, compared with a chime approximation of 3.
1/11/2005 Hiroaki Kobayashi 31
Suppose z 8 memory banks z A total memory latency of 12 cycles Ā The time from when the address arrives at the bank until the bank returns a data value. The latency includes the start-up cost of fetching a vector from memory. z A bank busy time of 6 cycles Ā The time the bank is occupied with one request. A processor cannot issue a second request to the same bank until the bank busy time has elapsed
Ā How long will it take to complete a 64-element vector load with a stride of 1? Ā With a stride of 32?
Case of 1-Stride: z Since the number of banks is larger than the bank busy time, for a stride of 1, no conflict on memory banks ¾ The load will take 76 (=12+64) clock cycles, 1.2 clocks per element
Case of 32-Stride: z Every access to memory (after the first one) will collide with the previous access and will have to wait for the 6-clock-cycle bank busy time. ¾ The load will take 391 (=12+1+6*63) cycles, 6.1 clocks per element
1/11/2005 Hiroaki Kobayashi 32
Increasing the number of memory banks to a number greater than the minimum to prevent stalls with a stride of length 1 will decrease the stall frequency for some other strides.
Programming for avoiding conflicts whenever possible
Programming for avoiding conflicts whenever possible
Andā¦
1/11/2005 Hiroaki Kobayashi 33
z Chaining
Example:
MULV.D V1,V2,V ADDV.D V4,V1,V
A sustained rate (ignoring start-up) of two floating-point operation per cycle. Total running time: (Vector length)+(Start-up Time (^) ADD) + (Start-up timeMULV)
1/11/2005 Hiroaki Kobayashi 34
A i B i
D i
C i
lo a d
lo a d lo a d
s t o r e
Example D(i)=A(i) B(i)+C(i)
vld $v4, 8, $s vld $v5, 8, $s vld $v7, 8, $s vfmp $v6, $v4, $v vfad $v3, $v6, $v vst $v3, 8, $s
Assembler Image VLD^ VLD VLD
VFAD
VFMP
VST
Vector Multiplier
Vector Adder
Vector Register Memory
1/11/2005 Hiroaki Kobayashi 37
z Sparse Matrices
Example: A sparse vector sum on the arrays A and C, using index vector K and M to designate the nonzero elements of A and C.
do 100 i=1,n 100 A(K(i)) = A(K(i)) + C(M(i))
Scatter-Gather Operations using index vectors ¾ Support moving between a dense representation (i.e., zeros are not included) and normal representation (i.e., the zeros are included) of a sparse matrix
1/11/2005 Hiroaki Kobayashi 38
Ā The result is a non-sparse vector in a vector register.
Ra, Rc, Rk, and Rm contain the starting addresses of the vectors LVI: load vector indexed SVI: store vector indexed
Scatter-gather
Example
1/11/2005 Hiroaki Kobayashi 39
1/11/2005 Hiroaki Kobayashi 40