supercomputer architecture: vector processing 1/11/2005 hiroaki kobayashi 7 vector processing:...

21
1 1 Supercomputer Architecture: Supercomputer Architecture: Vector Processing Vector Processing Hiroaki Kobayashi 1/11/2005 2 What is a Supercomputer? What is a Supercomputer? A supercomputer is a hardware and software system that provides close to the maximum performance that can currently be achieved. Over the last 10 years the range for the Top500 (http://www.top500.org) has increased greater than Moore’s Law 1993: #1 = 59.7 GFlop/s #500 = 422 MFlop/s 2004: #1 = 70 TFlop/s #500 = 850 GFlop/s CRAY-1 (1976) First Supercomputer 160MFlop/s

Upload: hoangnguyet

Post on 18-May-2018

219 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

1

1

Supercomputer Architecture:Supercomputer Architecture:Vector ProcessingVector Processing

Hiroaki Kobayashi1/11/2005

1/11/2005 Hiroaki Kobayashi 2

What is a Supercomputer?What is a Supercomputer?

A supercomputer is a hardware and software system that provides close to the maximum performance that can currently be achieved.

♦ Over the last 10 years the range for the Top500 (http://www.top500.org) has increased greater than Moore’s Law♦ 1993:� #1 = 59.7 GFlop/s� #500 = 422 MFlop/s♦ 2004:� #1 = 70 TFlop/s� #500 = 850 GFlop/s

CRAY-1 (1976)First Supercomputer160MFlop/s

Page 2: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

2

1/11/2005 Hiroaki Kobayashi 3

Trend in Supercomputer ArchitecturesTrend in Supercomputer Architectures

Emergence of supercomputersAccelerators

1/11/2005 Hiroaki Kobayashi 4

Trend in Supercomputer Performance Trend in Supercomputer Performance

Sour

ce: J

.Don

garr

a

Page 3: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

3

1/11/2005 Hiroaki Kobayashi 5

What is a Supercomputer?What is a Supercomputer?

Source: J.Dongarrawww.top500.org

1/11/2005 Hiroaki Kobayashi 6

Qualitative Evaluation of SupercomputersQualitative Evaluation of Supercomputers

HPC Challenge Benchmarkinghttp://icl.cs.utk.edu/hpcc/http://icl.cs.utk.edu/hpcc/hpcc_results_all.cgi

Page 4: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

4

1/11/2005 Hiroaki Kobayashi 7

Vector Processing: Fundamental Processing Vector Processing: Fundamental Processing Model for Supercomputer ArchitecturesModel for Supercomputer Architectures

Basic IdeaExtend the instruction set and

architecture of the system to support the execution of commonly used vector operations in hardware.

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,64

are represented by a vector instruction of the type

VOP V3, V1, V2

where VOP represents a vector operation, and V1, V2, V3 indicate specific vector registers.

The operation performed is:V3 = V1 VOP V2

for all register values within each vector registers.

1/11/2005 Hiroaki Kobayashi 8

Important Properties of Vector InstructionsImportant Properties of Vector Instructions

A single vector instruction specifies a great deal of work

It is equivalent to executing an entire loop.

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.

Hardware needs only check for data hazards between two vector instructions once per vector operand, not once for every element within the vectors.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.

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.

Page 5: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

5

1/11/2005 Hiroaki Kobayashi 9

Basic Vector ArchitectureBasic Vector Architecture

Vector registersEach vector register is a fixed-length bank holding a single vector and must have at least two read ports and one write port.

Vector functional unitsEach 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.

Vector load-store unitThis 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 VR1 &VR2 To VR3

Pre-normalize

Fraction add

Post-normalize

Round

Pipelined FP ADD Unit

1/11/2005 Hiroaki Kobayashi 10

Characteristics of Typical Vector ProcessorsCharacteristics of Typical Vector Processors

Remarks:1. The clock rates shown

are for the vector units.2. The lanes show the

number of parallel pipelines used to execute operations within each vector instruction.

3. The Fujitsu machines’vector registers are configurable.

4. The NEC machines have eight foreground vector registers connected to the arithmetic units plus 32-64 background vector registers connected between the memory system and the foreground vector registers.

5. The Cray SV1 can group four CPUs with 2 lanes each to act in unison as a single larger CPU with eight lanes, called a multi-streaming Processor (MSP).

Page 6: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

6

1/11/2005 Hiroaki Kobayashi 11

NEC SXNEC SX--7 Architecture7 Architecture

Main M

emory

(MMU)

~256GB

Load/Store

Vector Unit×8

Vector Registers

Mask Reg.

Div

CacheMem.

1 chip CPU

Scalar Unit

Scalar Reg. Scalar Pipe

Add/Shift

Multiply

Logic

Mask

I/O Processor (IOP)

Mem BW1130GB/s

Max 4IOP

Clock552MHz

Max 32CPUs

1/11/2005 Hiroaki Kobayashi 12

Example of Vector InstructionsExample of Vector Instructions

Page 7: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

7

1/11/2005 Hiroaki Kobayashi 13

How Vector Processors Work: An ExampleHow Vector Processors Work: An Example

SAXPY (Single-precision a×X plus Y) and DAXPY (Double-precision a×X plus Y)

Y = a × X + Y, where X and Y are vectors, initially resident in memory, and a is a scalar

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

Vector Code Example: Y=a x X + YVector Code Example: Y=a x X + Y

This reduction occurs both 1. because the vector operations work on 64 elements and 2. because the overhead instructions that constitute nearly

half the loop on MIPS are not present in the vector code.

MIPS codeLD F0,a ;load scalar aDADDIU 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 XDADDIU Ry,Ry,#8 ;increment index to YDSUBU R20,R4,Rx ;compute boundBNEZ R20, Loop ; check if done

The vector processor greatly reduces the dynamic instruction bandwidth.Executing only 6 instructions versus almost 600 for MIPS.

Vector codeLD F0,a ;load scalar aLV V1,Rx ;load vector XMULV.D V2,V1,F0 ;vector-scalar multiplyLV V3,Ry ;load vector YADDV.D V4,V2,V3 ;addSV Ry,V4 ;store the result

Page 8: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

8

1/11/2005 Hiroaki Kobayashi 15

Vector Code Example (ContVector Code Example (Cont’’d)d)

MIPS codeLD F0,a ;load scalar aDADDIU 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 XDADDIU Ry,Ry,#8 ;increment index to YDSUBU R20,R4,Rx ;compute boundBNEZ R20, Loop ; check if done

Vector codeLD F0,a ;load scalar aLV V1,Rx ;load vector XMULV.D V2,V1,F0 ;vector-scalar multiplyLV V3,Ry ;load vector YADDV.D V4,V2,V3 ;addSV 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.DOn 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

How Can Vector Execution Time be Estimated? How Can Vector Execution Time be Estimated?

Three factors that affect the execution time of a sequence of vector operations

Length of the operand vectorsStructural hazards among the operationsData dependency

The time for a single vector instruction can be computed when the vector length and the initiation rate are given.

Initiation rate: the rate at which a vector unit consumes new operands, and produces new results.

Model for estimating vector execution time

One lane with an initiation rate of one element per clock cycle for individual operationsNotion 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 hazardsA 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.

Page 9: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

9

1/11/2005 Hiroaki Kobayashi 17

Estimation using Convoys and Chimes: ExampleEstimation using Convoys and Chimes: Example

LV V1,Rx ;load vector XMULV.D V2,V1,F0 ;vector-scalar multiplyLV V3,Ry ;load vector YADDV.D V4,V2,V3 ;addSV Ry,V4; ;store the result

1. LV2. MULVS.D LV3. ADDV.D4. SV

• The sequence requires four convoys and hence takes fourchimes.

• Ignores some overheads: vector instruction issue overhead and the vector start-up time.

Because the initiation overhead is very small compared with cycles for a vector operation, the chime approximation is reasonably accurate for long vectors.

For example, for 64-element vectors, the sequence would take about 256 clock cycles but the initiation overhead is as small as two cycles in most vector machines.

1/11/2005 Hiroaki Kobayashi 18

StartStart--Up Time of a PipelineUp Time of a Pipeline

Space-time diagramDepict the processing status of a pipeline as a function of time

Time

Spac

e: P

ipel

ine

stag

es

Input of individual operations into a pipeline

Output of individual operations from a pipeline

Start-up time is the pipeline latency of the vector operation, and is principally determined by how deep the pipeline is for the functional unit used.

Start-up time

τ:pipeline cycleThroughput: 1/τ

A deeper pipeline has a longer start-up time!

Shorterstartup time

Longer startup time

Longer vector length means smaller a start-up overhead!

Vector length

Page 10: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

10

1/11/2005 Hiroaki Kobayashi 19

Effect of StartEffect of Start--up Time on the Execution up Time on the Execution CyclesCycles

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?

6Add unit

7Multiply unit

12Load and store unit

Start-up overhead (cycles)

Unit

Start-up overhead

41 + 4n30 + 3n + 1230 + 3n4. SV

29 + 3n24 + 2n + 624 + 2n3. ADDV.D

23 + 2n12 + n + 1212 + n2. MULVS.D LV

11 + n1201. LV

Last-result timeFirst-result timeStarting timeConvoy

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

Vector LoadVector Load--Store Units and Vector Memory Store Units and Vector Memory SystemsSystems

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.

12Vector load

20Vector divide

7Vector multiply

6Vector add

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

Page 11: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

11

1/11/2005 Hiroaki Kobayashi 21

Banked Memory Systems for Vector Banked Memory Systems for Vector ProcessingProcessing

1. The memory system needs to have multiple banks and able to control the addresses to the banks independently.

Many vector computer support multiple loads or stores per clock, and the memory bank cycle time is often several times larger than the CPU cycle time.

2. Many vector processors support the ability to load or store data words that are not sequential.

Independent bank addressing, rather than interleaving, is required.

3. Many vector computers support multiple processors sharing the same memory system, and so each processor will be generating its own independent stream of address

Three primary reasons for use of memory banks for vector processing, rather than simple interleaving.

BK0 BK1 BKn

Memory System

Vector Processors

Bank

s

Time

Memory latencyPipelinecycle

Memory transaction

1/11/2005 Hiroaki Kobayashi 22

How Many Banks are Required: Cray T90 CaseHow Many Banks are Required: Cray T90 Case

Cray T902.167 ns CPU clock cycle32 processors, each capable of four loads and two stores per CPU clock cycleSRAM memory cycle of 15ns

Calculate the minimum number of memory banks required to allow all CPU to run at full memory bandwidth

• The maximum number of memory references each cycle is 192 (=32CPUs X 6 references/CPU)

• Each SRAM bank is busy for 15/2.167 = 6.92 clock cycles, rounding up 7 clock cycles.

192 × 7 = 1344 memory Banks!But actually, 1024 memory banks are adopted (later model introduce synchronous DRAM for providing sufficient bandwidth).

Page 12: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

12

1/11/2005 Hiroaki Kobayashi 23

How the Banked Memory System WorksHow the Banked Memory System Works

Suppose we want to fetch a vector of 64 elements starting at byte address 136, and a memory access takes 6 clocks.

Questions:• How many memory

banks must we have to support one fetch per clock cycle?

• With what addresses are the banks accessed?

• When will the various elements arrive at the CPU?

1/11/2005 Hiroaki Kobayashi 24

Two RealTwo Real--World Issues: Vector Length and World Issues: Vector Length and StrideStride

Vector-Length ControlA single piece of code may require different vector lengths

What do you do when the vector length in a program is not exactly 64, the physical size of a vector register?

Example:

do 10 I = 1,n10 Y(i) = a * X(i) + Y(i)

The size of all the vector operations depends n, which may not even known until run time!The value of n might also be a parameter to a procedure containing the above loop and therefore be subject to change during execution.

SolutionVector-Length Register

Controls the length of any vector operation, including a vector load or store.

The introduction of the VLR solves the vector-length problem as long as the real length is less than or equal to the maximum vector length (MVL) defined by the processor.

Page 13: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

13

1/11/2005 Hiroaki Kobayashi 25

What If the Vector Length is Greater Than What If the Vector Length is Greater Than MVL?MVL?

Strip miningGeneration of code such that each vector operation is done for asize less than or equal to the MVL.

do 10 I = 1,n10 Y(i) = a * X(i) + Y(i)

Strip mining

low =1VL = (n mod 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 continuelow = 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 variable m is used for the expression (n mod MVL)

1/11/2005 Hiroaki Kobayashi 26

Effect of StripEffect of Strip--Mining on the Execution TimeMining on the Execution Time

There are two key factors that contribute to the running time of a strip-mined loop consisting of a sequence of convoys:

1. The number of convoys in the loop, which determines the number of chimes.

Tchime for the execution time in chimes

2. The overhead for each strip-mined sequence of convoys.

This overhead consists of the cost of executing the scalar code for strip-mining each block, Tloop, plus the vector start-up cost for each convoy, Tstart

Total running time for a vector sequence operating on a vector of length n, called Tn:

Tn =⎡ n / MVL⎤× (Tloop + Tstart) + n × Tchime

Tstart, Tloop and Tchime 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

Page 14: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

14

1/11/2005 Hiroaki Kobayashi 27

Effect of StripEffect of Strip--Mining on the Execution Time: Mining on the Execution Time: ExampleExample

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?

AssumeThe addresses of A and B are initially in Ra and Rb, s is in Fs, and R0 always holds 0.Tloop is a constant value of 15 from Cray-1 data.

Answer• Since (200 mod 64)=8, the first iteration

of the strip-mind loop will execute for a vector length of 8 element, and the following iterations will execute for a vector length of 64 elements

• Since the vector length is either 8 or 64, increment the address registers by 8x8=64 after the first segment and 8X64=512 for later segments.

• Since the total number of bytes in the vector is 8X200=1600, the test for completion is performed by comparing the address of the next vector segment to the initial address plus 1600

1/11/2005 Hiroaki Kobayashi 28

Generated Code:

DADDUI R2,R0,#1600 ;total # of bytes in vectorDADDU R2,R2,Ra ;address of the end of A vectorDADDUI R1,R0,#8 ;loads length of 1st segmentMTC1 VLR,R1 ;load vector length in VLRDADDUI R1,R0,#64 ;length in bytes of 1st segmentsDADDUI R3,R0,#64 ;vector length of other segments

Loop:LV V1,Rb ;load BMULVS.D V2,V1,Fs ;vector * scalarSV Ra,V2 ;store ADADDU Ra,Ra,R1 ;address of next segment of ADADDU Rb,Rb,R1 ;address of next segment of BDADDUI R1,R0,#512 ;load byte offset next segmentMTC1 VLR,R3 ;set length to 64 elementsDSUBU R4,R2,Ra ;at the end of A?BNEZ R4,Loop ;if not, go back

Effect of StripEffect of Strip--Mining on the Execution Time: Mining on the Execution Time: Example (ContExample (Cont’’d)d)

• The three vector instructions in the loop are dependent and must go into three convoys, hence Tchime=3

The execution time per element with all start-up costs is 784/200=3.9, compared with a chime approximation of 3.

Page 15: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

15

1/11/2005 Hiroaki Kobayashi 29

Effect of the Vector Length on Total Time Effect of the Vector Length on Total Time and Total Overheadand Total Overhead

A chime counting model would lead to 3 clock cycles per element, while the two sources of overhead add 0.9 clock cycles per element in the limit!

Chime approximation of 3

1/11/2005 Hiroaki Kobayashi 30

Two RealTwo Real--World Issues: Vector Length and World Issues: Vector Length and StrideStride

The second problem addresses is that the position in memory of adjacent elements in a vector may not be sequential.

To do so, we must consider how adjacent elements in B and adjacent elements in C are addressed.If the elements of the vectors are stored in the column-major order (the case in which the code is written in Fortran), the elements of B accessed by iterations in the inner loop are separated by the row size times 8 (the number of bytes per entry) for a total of 800 bytes.

Example:do 10 i=1, 100

do 10 j=1,100A(i,j)=0.0do 10 k=1,100

10 A(i,j)=A(i,j)+B(i,k)*C(k,j)

At the statement labeled 10 we could vectorize the multiplication of each row of B with each column of C and strip-mine the inner loop with k as index variable. The distance separating elements are

gathered into a single register, and processed as if it had logically adjacent elements

Page 16: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

16

1/11/2005 Hiroaki Kobayashi 31

Conflicts on a BankConflicts on a Bank

Suppose8 memory banksA 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.

A bank busy time of 6 cyclesThe 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: Since the number of banks is larger than the bank busy time, for a stride of 1, no conflict on memory banksThe load will take 76 (=12+64) clock cycles, 1.2 clocks per element

Case of 32-Stride: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

To Decrease the Possibility of Bank ConflictsTo Decrease the Possibility of Bank Conflicts……

Memory bank conflicts will not occur within a single vector memory instruction if

The stride and number of banks are relatively prime with respect to each other, and

There are enough banks to avoid conflicts in the unit stride case

With 64 banks, a stride of 32 will stall on every other access, rather than every access.With 256 banks, a stride of 32 will stall on every 8 access.

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…

Page 17: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

17

1/11/2005 Hiroaki Kobayashi 33

Enhancing Vector Performance: ChainingEnhancing Vector Performance: Chaining

ChainingThe concept of forwarding extended to vector registers

The results from the first functional unit in the chain are forwarded to the second functional unit.

Example:

MULV.D V1,V2,V3ADDV.D V4,V1,V5

A sustained rate (ignoring start-up) of two floating-point operation per cycle.Total running time: (Vector length)+(Start-up TimeADD) + (Start-up timeMULV)

1/11/2005 Hiroaki Kobayashi 34

Chaining ExampleChaining Example

主 記 憶

ベ ク トル レ ジ ス タ

⑤ ベ ク トル 加 算 器

④ ベ ク トル 乗 算 器A ( i)

B ( i)

D ( i)

C ( i)

① lo a d

② lo a d

③ lo a d

⑥ s to r e

Example:D(i)=A(i)×B(i)+C(i)

① vld $v4, 8, $s37② vld $v5, 8, $s46③ vld $v7, 8, $s38④ vfmp $v6, $v4, $v5⑤ vfad $v3, $v6, $v7⑥ vst $v3, 8, $s47

Assembler Image ③VLD①VLD ②VLD

⑤VFAD

④VFMP

⑥VST

Time

Vector Multiplier

Vector AdderVector Register

Memory

Page 18: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

18

1/11/2005 Hiroaki Kobayashi 35

Conditionally Executed StatementsConditionally Executed Statements

Two reasons why higher levels of vectorization are not achieved

Presence of conditionals (if statements) inside loops

Programs that contain if statements in loops cannot be run in vector mode using the techniques we have discussed so far.

Use of sparse matricesSparse matrices cannot be efficiently implemented using any of the capabilities we have seen so far.

How can we handle conditional execution?

Example

But, if the inner loop could be run for the iteration for which A(i)≠0, then the subtraction could be vectorized.

Impossible to vectorize!

Vector-mask control

1/11/2005 Hiroaki Kobayashi 36

VectorVector--Mask ControlMask Control

Use a Boolean vector of length MVL to control the execution of a vector instruction just as conditionally executed instructions use a Boolean condition to determine whether an instruction is executed

When the vector-mask register is enabled, any vector instructions executed operate only on the vector elements whose correspondingentries in the vector-mask register are 1.

Example

Page 19: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

19

1/11/2005 Hiroaki Kobayashi 37

Handling Sparse MatricesHandling Sparse Matrices

Sparse MatricesThe elements of a vector are usually stored in some compacted form and then accessed indirectly.

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,n100 A(K(i)) = A(K(i)) + C(M(i))

Scatter-Gather Operations using index vectorsSupport 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

ScatterScatter--Gather OperationsGather Operations

A gather operation takes an index vector and fetches the vector whose elements are at the addresses given by adding a base address to the offsets given in the index vector.

The result is a non-sparse vector in a vector register.

After these elements are operated on in dense form, the sparse vector can be stored in expanded form by a scatter store, using the same index vector.

Ra, Rc, Rk, and Rm contain the starting addresses of the vectors

LVI: load vector indexedSVI: store vector indexed

Scatter-gather

Example

Page 20: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

20

1/11/2005 Hiroaki Kobayashi 39

Multiple LanesMultiple Lanes

Combination of parallel and pipelined functional unitsEach lane contains one portion of the vector-register file and one execution pipeline from each vector functional unitEach vector functional unit executes vector instructions at the rate of one element group per cycle using multiple pipeline, one per lane.Inter-lane wiring is only required to access main memory

1/11/2005 Hiroaki Kobayashi 40

Vector Processing on Multiple LanesVector Processing on Multiple Lanes

Page 21: Supercomputer Architecture: Vector Processing 1/11/2005 Hiroaki Kobayashi 7 Vector Processing: Fundamental Processing Model for Supercomputer Architectures Basic Idea zExtend the instruction

21

1/11/2005 Hiroaki Kobayashi 41

Bank Conflicts ExampleBank Conflicts Example

Bank 0

Bank 1

Bank 3

Bank 4

Bank 5

Bank 2

Bank 6

Bank 7

0 8 16 24 32 40 48 56 64 ・・・

1 9 17 25 33 41 49 57 65 ・・・

2 10 18 26 34 42 50 58 66 ・・・

3 11 19 27 35 43 51 59 67 ・・・

4 12 20 28 36 44 52 60 68 ・・・

5 13 21 29 37 45 53 61 69 ・・・

6 14 22 30 38 46 54 62 70 ・・・

7 15 23 31 39 47 55 63 71 ・・・

stride 8

with stride 15

a stride of a prime number to # of banks does not cause bank conflict!

Stride-32 access

Stride-1 access