Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
Vorlesung / Course IN2075: Mikroprozessoren / Microprocessors VLIW Architectures 8 Jan 2018
Carsten Trinitis Lehrstuhl für Rechnertechnik und Rechnerorganisation (LRR) Technische Universität München
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
Instruction Level Parallelism ●
Idea: –
●
several independent instructions from the same instruction stream are executed in parallel.
Two approaches: –
–
VLIW: identification of independent instructions by compiler. Superscalarity: identification of independent instructions by hardware. – – – –
compatible with old code. flexibility (e.g. jumps). higher hardware complexity (more transistors). decisions have to be made in real time.
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
VLIW
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
Explicit Parallelism ●
Making on-chip parallelism explicit – Allow directly to specify several operations – Instruction bundles – Result: Very Long Instruction Word (VLIW)
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
VLIW ●
Instruction explicitly contains several operations – –
Normally matching the number of present units Longer instruction length Int #1
Int #2
FP #1
FP #2
Load/Store
Int Unit #1
Int Unit #2
FP Unit #1
FP Unit #2
L/S Unit
Purely controlled by Software Role of the compiler Reduces hardware complexity
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
VLIW Architectures Time
●
FI
DI FD PD WD Specified by one PD bundle PD FI DI FD PD WD Specified by one PD bundle PD
Only PD phase is replicated – All other phases work as usual – Not all PD units have to be equal – Can be combined with pipelining
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
Early VLIW Architectures • FPS A120B (1976): • Array-Processor for scientific Applications • First commercial processor with „wide“ instructions • Math. Libraries for vector processing including Software Pipelining / Loop Unrolling
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
Early VLIW Architectures • Multiflow Trace (1987): • 7, 14 or 28 operations / instruction • 28 operations in one 1024-Bit instruction word
• Cydrome Cydra-5 (1987): • 7 operations, 256 Bit instruction word • Rotating Registers (also in Itanium)
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
More “famous” VLIW Examples ●
Mainstream –
Transmeta Crusoe (x86 emulation)
–
Intel Itanium / IA-64
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture ●
First 64 Bit member of the Intel processor family – –
●
Characteristics – – – –
●
Entirely new design - compatibility only by emulation Developed together with HP
64 bit width VLIW design Predicated execution Speculation
EPIC = Explicitly Parallel Instruction Computing
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture – Registers:
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
IA-64 Instructions ●
Single instruction as the basis – Three register operands possible – Additional: Predicate Opcode
14 Bits
For
Register 1 Register 2 Register 3 Predicate
7 Bits
7 Bits
7 Bits
6 Bits
final instruction combine three of them
Instruction 1
Instruction 2
Instruction 3
41 Bits
41 Bits
41 Bits
128 Bits © Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Template 5 Bits
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture • IA-64 ISA – Template: indicates, if • Instructions in a bundle can be executed simultaneously, or, • One or more instructions are to be executed sequentially, or • Neighbouring bundles can be executed in parallel.
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
Predication (see also ARM before) ●
●
Branches are a problem for pipelines – Leads to a pipeline stall – Overhead to restart the pipeline
Difficult to optimise at compile-time – Dynamic information not available – Conditions for conditional branches unknown
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 ISA – Most programs are (still) written sequentially – VLIW: Compiler must map ILP – Problem: Conditional branches • Information which path to take unknown at compile time. • Processor must decide during runtime, which instructions are to be fetched into pipeline. • Branch Prediction: If wrong, instructions must be thrown away. • Problem increases with pipeline depth and number of functional units. • Approach: Get rid of branches © Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture Compare Instructions (syntax) Instruction
Compare
cmp.eq
a == b
cmp.ne
a !=b
cmp.lt
a= b
cmp.ltu
a=b (unsigned)
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture • Compare instructions example
cmp.eq
p1, p2 = r1, r2
• If GR[r1] and GR[r2] are equal p1 -> 1 p2 ->0 otherwise p1 -> 0 p2 -> 1 © Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture • Compare Instructions: • Each compare sets two separate predicate registers. • Predicate registers are modified depending on type of compare. • First predicate is set according to result of compare, second to its complement.
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture • If-Then-Else example in C: if (emp_status == ACTIVE) { n_active_emps++; total_payroll *= emp_pay; } else{ n_inactive_emps++; }
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
IF - THEN - ELSE • Standard Approach: { Cmp.ne (p1) br
p1 = rs, ACTIVE else
} .label then { add rt = rt, rp add ra = ra, 1 br join } .label else Add ri = ri, 1 } .label join
// compare emp_status // to else if condition not fulfilled.
// total_payroll+emp_pay // n_active_emps++ // skip else-code
// n_inactive_emps++
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
IF - THEN - ELSE • With Predication: { Cmp.eq
p1, p2 = rs, ACTIVE
// compare. emp_status
} { (p1) add rt = rt, rp (p1) add ra = ra, 1 (p2) add ri = ri, 1
// total_payroll+emp_pay // n_active_emps++ // n_inactive_emps++
}
– No more branches
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
IF - THEN – ELSE – { IF – THEN - ELSE} • Compare instructions IA-64: • Can be predicated themselves: • (qp) cmp.typ.mod pt1, pt2
=
reg1, reg2
• Normal and Unconditional Mode • Normal Mode: • Only executed if Qualifying Predicate (qp) == 1, see previous slide. • Unconditional Mode: • If (qp) == 1, as in normal mode • If (qp) == 0, sets both predicate targets to 0 • Used for Nested IF-Constructs © Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
IF - THEN – ELSE – { IF – THEN - ELSE} • Nested-IF: 1
... if (a>b) { // block 1 c++; // block 2 } else { d+= c; // block 3 if (e==f) { // block 3 g++; // block 4 } else { h-// block 5 } } ...
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
2
3
4
5
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
IF - THEN – ELSE – { IF – THEN - ELSE} • With Unconditional Compare: { cmp.gt
p1, p2 = ra, rb
// block 1
} {
(p1) add rc = rc, 1 // block 2 (p2) add rd = rd, rc // block 3 (p2) cmp.eq.unc p3, p4 = re, rf // block 3
} {
(p3) add rg = rg, 1 (p4) add rh = rh, -1
// block 4 // block 5
} • If a>b, then (p2)-> 0 , i.e. the unconditional compare in block 3 causes (p3)-> 0 and (p4)-> 0 ==> Code in Nested IF will not be executed. © Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
Parallel Compare
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture • Parallel Compare: if (status == FOUND && record == search_key && no_error) { ... // do something }
• Traditional approach: sequentially • Status == FOUND ? • Record == search_key ? • No_error ?
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture • Parallel Compare: • Convert sequential -> parallel Instructions
{ cmp.eq.and cmp.eq.and cmp.ne.and
p1, p2 = rs, FOUND // status==FOUND p1, p2 = rr, rk //record==search_key p1, p2 = rn ,0 // no_error != 0
}
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture ●
Speculative Loads –
Load instructions can be moved
–
Can lead to missing operands
–
Marked by NaT bits (65 bit registers!)
–
Observed during arithmetic operations
–
Recovery code (generated by compiler)
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture ●
Speculation –
Try to guess about values / conditions
–
Leads to faster code
–
Verification of speculation needed
–
Again, recovery code needed if speculation fails
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture ●
Register Rotation –
●
Rename registers during the execution –
Ability to use offsets in register file
–
Base register + actually used register numbers
Useful for loops
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture • Register Rotation: • Register Rotation Base (RRB)-Register • An Instruction refers to register GR x as follows: • IF x=32, register GR[x+RRB] is referenced! • Special loop instructions decrement RRB. © Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture • Register Rotation: • GRs, FRs und PRs have static (lower 25%) and „rotating“ section (upper 75%): Register File
Static
General Registers
GR0 - GR31 GR32 - GR127
Floating-point Registers
FR0 - FR31
Predicate Registers
PR0 - PR15 PR16-PR63
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
„Rotating“
FR32 - FR127
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture • Register Rotation: • Example: • RRB=64, instruction writes value 0x1234 to GR63 => GR127 is referenced. • Loop iteration decrements RRB to 63. • Instruction referencing GR63 now refers to physical register GR126.
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
The IA-64 Architecture Before Rotation
After
Rotation
GR-#
Content
GR-#
Content
127
0x7f
127
0x7e
126
0x7e
126
0x7d
...
...
...
...
34
0x22
34
0x21
33
0x21
33
0x20
32
0x20
32
0x7f
31
0x1f
31
0x1f
...
...
...
...
0
0x0
0
0x0
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018
Lehrstuhl für Rechnertechnik und Rechnerorganisation Fakultät für Informatik Technische Universität München
VLIW: From a Software Point of View ●
Role of Compiler is getting more important! – – –
●
Advantage: – –
●
Need to create bundles Need to use predication Need to allow useful speculation/prediction More time during compile time Extensive optimisations possible
Disadvantage: – –
No dynamic information Can not adapt to runtime behaviour
© Carsten Trinitis, Microprocessors Lecture @TUM, WS 2017/2018