cs184b: computer architecture (abstractions and optimizations)
DESCRIPTION
CS184b: Computer Architecture (Abstractions and Optimizations). Day 2: April 2, 2003 Instruction Set Architecture. Today. Datapath review H&P view on ISA Questions Themes Compilers RISC. RISC?. What does RISC mean?. Compute. 0000 00 010 11 0110 - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/1.jpg)
Caltech CS184 Spring2003 -- DeHon1
CS184b:Computer Architecture
(Abstractions and Optimizations)
Day 2: April 2, 2003
Instruction Set Architecture
![Page 2: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/2.jpg)
Caltech CS184 Spring2003 -- DeHon2
Today
• Datapath review
• H&P view on ISA
• Questions
• Themes
• Compilers
• RISC
![Page 3: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/3.jpg)
Caltech CS184 Spring2003 -- DeHon3
RISC?
• What does RISC mean?
![Page 4: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/4.jpg)
Caltech CS184 Spring2003 -- DeHon4
Terminology
• Primitive Instruction (pinst)– Collection of bits which tell a single bit-
processing element what to do– Includes:
• select compute operation• input sources in space
– (interconnect)• input sources in time
– (retiming)
Compute
0000 00 010 11 0110 net0 add mem slot#6
![Page 5: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/5.jpg)
Caltech CS184 Spring2003 -- DeHon5
Instructions
• Distinguishing feature of programmable architectures?– Instructions -- bits which tell the device
how to behave
Compute
0000 00 010 11 0110 net0 add mem slot#6
![Page 6: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/6.jpg)
Caltech CS184 Spring2003 -- DeHon6
Single ALU Datapath
![Page 7: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/7.jpg)
Caltech CS184 Spring2003 -- DeHon7
With Branch and IndirectInstr: ALUOP Bsel Write Bsrc Asrc DST Baddr
CS184a
Day
5
![Page 8: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/8.jpg)
Caltech CS184 Spring2003 -- DeHon8
ISA
• Model based around Sequential Instruction Execution
• Visible-Machine-State Instruction New Visible-Machine-State
• New Visible-Machine-State identifies next instruction– PCPC+1 or PCbranch-target
![Page 9: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/9.jpg)
Caltech CS184 Spring2003 -- DeHon9
Machine State: Initial
• Counter: 0• Instruction Memory:
000: 0000 1 001 001 010
001: 0000 1 000 010 011
010: 1000 1 011 100 111
• Data Memory:000: A
001: B
010: ?
011: ?
100: 00001111
101: ?
110: ?
111: ?
CS184a
Day
5
![Page 10: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/10.jpg)
Caltech CS184 Spring2003 -- DeHon10
ISA
• Visible Machine State– Registers (including PC)– Memory
• Instructions– ADD R1, R2, R3– LD R3, R4– BNE R4, R2, loop
![Page 11: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/11.jpg)
Caltech CS184 Spring2003 -- DeHon11
Datapath
[Datapath from PH (Fig. 5.1)]
![Page 12: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/12.jpg)
Caltech CS184 Spring2003 -- DeHon12
Instructions
• Primitive operations for constructing (describing) a computation
• Need to do?– Interconnect (space and time)– Compute (intersect bits)– Control (select operations to run)
![Page 13: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/13.jpg)
Caltech CS184 Spring2003 -- DeHon13
Detail Datapath
[Datapath from PH (Fig. 5.13)]
![Page 14: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/14.jpg)
Caltech CS184 Spring2003 -- DeHon14
uCoded / Decoded
• uCoded– Bits directly control datapath– Horizontal vs. Vertical– Not abstract from implementation
• Decoded– more compressed – only support most common operations– abstract from implementation– time/area to decode to datapath control signals
![Page 15: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/15.jpg)
Caltech CS184 Spring2003 -- DeHon15
Detail Datapath
[Datapath from PH (Fig. 5.13)]
![Page 16: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/16.jpg)
Caltech CS184 Spring2003 -- DeHon16
H&P View• ISA design done?• Not many opportunities to completely redefine• Many things mostly settled
– at least until big technology perturbations arrive
• Implementation (uArch) is where most of the action is
• Andre: maybe we’ve found a nice local minima...
![Page 17: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/17.jpg)
Caltech CS184 Spring2003 -- DeHon17
H&P Issues
• Registers/stack/accumulator– # operands, memory ops in instruction
• Addressing Modes
• Operations
• Control flow
• Primitive Data types
• Encoding
![Page 18: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/18.jpg)
Caltech CS184 Spring2003 -- DeHon18
Register/stack/accumulator
• Driven largely by cost model– ports into memory– latency of register versus memory– instruction encoding (bits to specify)
• Recall Assignment 3: Instructions #4
![Page 19: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/19.jpg)
Caltech CS184 Spring2003 -- DeHon19
Register/stack/accumulator
• Today: Load-Store, General Register arch.
• Registers more freedom of addressing than stack
• Load into register, then operate– Separate op, not much slower than memory
addressing mode– usually use more than once (net reduction)
![Page 20: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/20.jpg)
Caltech CS184 Spring2003 -- DeHon20
Addressing Modes• Minimal:
– Immediate #3– Register R1– register indirect (R1)
• Others:– displacement– indirect (double derference)– auto increment/decrement ( p[x++]=y)– scaled
![Page 21: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/21.jpg)
Caltech CS184 Spring2003 -- DeHon21
Addressing Modes
• More capable– less instructions– potentially longer instructions
• bits and cycle time
– many operations (complicate atomicity of instructions)
• Add (R2)+,(R3)+,(R4)+
![Page 22: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/22.jpg)
Caltech CS184 Spring2003 -- DeHon22
Address Space Quote
• The Virtual Address eXtension of the PDP-11 architecture . . . provides a virtual address of about 4.3 gigabytes which, even given the rapid improvement of memory technology, should be adequate far into the future.
• William Strecker, “VAX-11/780—A Virtual address Extension to the PDP-11 Family,” AFIPS Proc., National Computer Conference, 1978
![Page 23: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/23.jpg)
Caltech CS184 Spring2003 -- DeHon23
Operations• ALU/Arithmetic
– add, sub, or, and, xor– compare
• Interconnect– move registers– load, store
• Control– jump– conditional branch– procedure call/return
![Page 24: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/24.jpg)
Caltech CS184 Spring2003 -- DeHon24
Operations: ALU
• Small set of SIMD operations
• Covers very small fraction of the space of all www
![Page 25: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/25.jpg)
Caltech CS184 Spring2003 -- DeHon25
Operations: Branching
• Models:– ops set condition codes, branch on
condition codes• Extra state
– compare result placed in register; branch on register zero or one
– comparison part of branch• May affect critical path for branch resolution
![Page 26: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/26.jpg)
Caltech CS184 Spring2003 -- DeHon26
Operations: Procedure call/return
• ? Save registers?
• Update PC– call target– return address
• Change stack and frame pointers– store old– install new
![Page 27: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/27.jpg)
Caltech CS184 Spring2003 -- DeHon27
Operations: Procedure call/return
• Question: How much should instruction do?
• Lesson: High variance in work needs to be done– which registers need to save– best way to transfer arguments to procedures– better to expose primitives to the compiler and
let it specialize the set of operations to the particular call
![Page 28: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/28.jpg)
Caltech CS184 Spring2003 -- DeHon28
Data Types
• Powers of two from bytes to double words?– 8, 16, 32, 64– (very implementation driven decision)
• Floating Point types
• Are pointers integers?
• Alignment requirements
![Page 29: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/29.jpg)
Caltech CS184 Spring2003 -- DeHon29
Encoding
• Variable vs. Fixed
• How complex is the decoding?– Fields in the same place…or have to be
routed/muxed?– Sequential requirements in decode?
• E.g. must decode previous byte to know what to do with next byte?
![Page 30: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/30.jpg)
Caltech CS184 Spring2003 -- DeHon30
Detail Datapath
[Datapath from PH (Fig. 5.13)]
![Page 31: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/31.jpg)
Caltech CS184 Spring2003 -- DeHon31
Encoding: RISC/Modern
[DLX Instruction Format from HP2nd ed. (Fig. 2.21)]
![Page 32: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/32.jpg)
Caltech CS184 Spring2003 -- DeHon32
Operation Complexity
• Contradiction?– Providing primitives – including floating point ops
![Page 33: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/33.jpg)
Caltech CS184 Spring2003 -- DeHon33
Local Minima?
• Self-Fulfilling?– How would we quantitatively validate need
for a new operation?
– [cue: bridge story]– This is what we use as primitives– Funny, we don’t find a need for other
primitives…
![Page 34: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/34.jpg)
Caltech CS184 Spring2003 -- DeHon34
Themes
• Common case fast
• Provide primitives (building blocks)
• Let compiler specialize to particular operation
• Make decode/operation simple so implementation is fast
![Page 35: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/35.jpg)
Caltech CS184 Spring2003 -- DeHon35
Compilers
• 19601990 shift– increasing capability and sophistication of
compilers– e.g.
• inter-procedural optimization• register assignment (register usage)• strength reduction• dataflow analysis and instruction reordering• (some progress) alias analysis
![Page 36: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/36.jpg)
Caltech CS184 Spring2003 -- DeHon36
Compilers
• Gap between programmer and Architecture
• Increasingly bridged by compiler
• Less need to make assembly language human programmable
• More opportunity for compiler to specialize, partial evaluate – (do stuff at compile time to reduce runtime)
• RISC: “Relegate Interesting Stuff to Compiler”
![Page 37: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/37.jpg)
Caltech CS184 Spring2003 -- DeHon37
Implementation Significance
• André Agree: Implementation issues are significant in the design of ISA
• Many of these issues are more interesting when we discuss in light of implementation issues
![Page 38: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/38.jpg)
Caltech CS184 Spring2003 -- DeHon38
ISA Driven by
1. Implementation costs
2. Compiler technology
3. Application structure
• Can’t do good architecture in isolation from any of these issues.
![Page 39: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/39.jpg)
Caltech CS184 Spring2003 -- DeHon39
RISC?
![Page 40: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/40.jpg)
Caltech CS184 Spring2003 -- DeHon40
VAX Instructions
• Vary in length 1 to 53 bytes
• Some very complex– Powerful call routines– Polynomial evaluate (polyf)– Calculate CRC (crc)
![Page 41: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/41.jpg)
Caltech CS184 Spring2003 -- DeHon41
VAX / MIPS procedure
http://jbsim.cs.pku.edu.cn/users/chengxu/Org_web_ext/PDF_FILES/webext3_vax.pdf
![Page 42: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/42.jpg)
Caltech CS184 Spring2003 -- DeHon42
RISC
• Reduced Instruction Set Computers
• Idea:– Provide/expose minimal primitives– Make sure primitives fast– Compose primitives to build functionality– Provide orthogonal instructions
![Page 43: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/43.jpg)
Caltech CS184 Spring2003 -- DeHon43
RISC Equation
• Time= CPI Instructions CycleTime• CISC:
– Minimize: Instructions– Result in High CPI– Maybe High CycleTime
• RISC:– Target single-cycle primitives (CPI~1)– Instruction Count increases– Simple encoding, ops reduced Cycle Time
![Page 44: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/44.jpg)
Caltech CS184 Spring2003 -- DeHon44
VAX Data
[Emer/Clark, ISCA 1984]
![Page 45: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/45.jpg)
Caltech CS184 Spring2003 -- DeHon45
RISC Enabler 1
• “large”, fast On-Chip SRAM– Large enough to hold kernel exploded in RISC Ops ~
1--10K 32b words?
• Previous machines:– Off-chip memory bandwidth bottleneck– Fetch single instruction from off chip– Execute large number of microinstructions from on-
chip ROM• ROM smaller than SRAM
• Small/minimal machine make room for cache
![Page 46: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/46.jpg)
Caltech CS184 Spring2003 -- DeHon46
RISC Enable 2
• High Level Programming– Bridge semantic gap by compiler– As opposed to providing powerful building
blocks to assembly language programmer
![Page 47: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/47.jpg)
Caltech CS184 Spring2003 -- DeHon47
Fit Problem
• “A great dal depends on being able to fit an entire CPU design on a single chip."
• "RISC computers benefit from being realizable at an earlier date."
![Page 48: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/48.jpg)
Caltech CS184 Spring2003 -- DeHon48
Common Case
• "wherever there is a system function that is expensive or slow in all its generality, but where software can recognize a frequently occurring degenerate case (or can move the entire function from runtime to compile time) that function is moved from hardware to software, resulting in lower cost and improved performance." – 801 paper
![Page 49: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/49.jpg)
Caltech CS184 Spring2003 -- DeHon49
Measurement Good
• Don’t assume you know what’s going on – measure
• Tune your intuition • "Boy, you ruin all our fun -- you have
data.” – DEC designers in response to a detailed quantitative study [Emer/Clark Retrospective on 11/780 performance characterization]
![Page 50: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/50.jpg)
Caltech CS184 Spring2003 -- DeHon50
VAX/RISC Compare
[Bhandarkar/Clark ASPLOS 1991]
![Page 51: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/51.jpg)
Caltech CS184 Spring2003 -- DeHon51
VAX/RISC Compare
[Bhandarkar/Clark ASPLOS 1991]
![Page 52: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/52.jpg)
Caltech CS184 Spring2003 -- DeHon52
VAX
• Smoking gun?:– 3-operand instructions– One cycle per operand field– If field a mem-op, wash with ld/st in RISC– If register-op, costs more
• …long way to supporting gap…
![Page 53: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/53.jpg)
Caltech CS184 Spring2003 -- DeHon53
ISA Growth
• Can add instructions (upward compatibility)
• Do we ever get to remove any?
![Page 54: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/54.jpg)
Caltech CS184 Spring2003 -- DeHon54
RISC
• Everyone believe RISC– X86 only one left– ...and it’s a RISC core…
• …but do they understand it?– Today’s processors pretty complicated– Who’s managing instruction scheduling?– What mean to FPGAs?
![Page 55: CS184b: Computer Architecture (Abstractions and Optimizations)](https://reader036.vdocument.in/reader036/viewer/2022081603/56815152550346895dbf7584/html5/thumbnails/55.jpg)
Caltech CS184 Spring2003 -- DeHon55
Big Ideas• Common Case
– Measure to verify/know what it is!
• Primitives• Highly specialized instructions brittle• Design pulls
– simplify processor implementation– simplify coding
• Orthogonallity (limit special cases)• Compiler: fill in gap between user and hardware
architecture