CMSC 611: Advanced Computer Architecture
CMSC 611: Advanced Computer Architecture
CMSC 611: Advanced Computer Architecture
Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted from Hennessy & Patterson / 2003 Elsevier Science
Lecture Overview
Last Week
Different performance metrics (response time, throughput, CPU time) Performance reports, summary and comparison (Experiment reproducibility, arithmetic and weighted arithmetic means) Widely used benchmark programs (SPEC, Whetstone and Dhrystone) Example industry metrics (e.g. MIPS, MFLOP, etc.)
This Week
Classifications of instruction set architectures Different addressing modes Instruction types, operands and operations
Introduction
software instruction set hardware
To command a computer's hardware, you must speak its language Instructions: the words of a machine's language Instruction set: its vocabulary The MIPS instruction set is used as a case study
Figure: Dave Patterson
Goals:
Introduce design alternatives Present a taxonomy of ISA alternatives
+ some qualitative assessment of pros and cons
Present and analyze some instruction set measurements Address the issue of languages and compilers and their bearing on instruction set architecture Show some example ISAs
Interface Design
A good interface:
Lasts through many implementations (portability, compatibility) Is used in many different ways (generality) Provides convenient functionality to higher levels Permits an efficient implementation at lower levels
Interface
use use imp 2
Time
imp 3
Memory ISAs
Terms
Result = Operand <operation> Operand
Stack
Operate on top stack elements, push result back on stack
Memory-Memory
Operands (and possibly also result) in memory
Register ISAs
Accumulator Architecture
Common in early stored-program computers when hardware was expensive Machine has only one register (accumulator) involved in all math & logic operations Accumulator = Accumulator op Memory
ISA Operations
Famous ISA
Stack Memory-Memory Accumulator Architecture Extended Accumulator Architecture General-Purpose Register Architecture
Machine
Motorola 6800 DEC VAX Intel 8086 Motorola 68000 Intel 80386 PowerPC DEC Alpha
# general-purpose registers
2 16 1 16 32 32 32
Architecture style
Accumulator Register-memory, memory-memory Extended accumulator Register-memory Register-memory Load-store Load-store
Year
1974 1977 1978 1980 1985 1992 1992
Some people blamed the code density on the instruction set rather than the programming language A machine design philosophy advocated making the hardware more like high-level languages The effectiveness of high-level languages, memory size limitation and lack of efficient compilers doomed this philosophy to a historical footnote
RISC architecture favors simplified hardware design over rich instruction set
Rely on compilers to perform complex operations
Virtually all new architecture since 1982 follows the RISC philosophy:
fixed instruction lengths, load-store operations, and limited addressing mode
Compact Code
Scarce memory or limited transmit time (JVM) Variable-length instructions (Intel 80x86)
Match instruction length ot operand specification Minimize code size
Register-Memory Arch
# memory addresses
0 1 2 3
Examples
SPARC, MIPS, PowerPC, ALPHA Intel 60X86, Motorola 68000 VAX (also has 3 operands format) VAX (also has 2 operands format)
Advantages
- Fixed length instruction encoding - Simple code generation model - Similar execution time (pipeline)
Disadvantages
- Higher instruction count - Some instructions are short leading to wasteful bit encoding - Can restrict # register available for use - Clocks per instr. varies by operand type - Source operands are destroyed - Less potential for compiler optimization - Can create memory access bottleneck
Reg-Mem (1,2)
- Direct access without loading - Easy instruction encoding - No temporary register usage - Compact code
Mem-Mem (3,3)
Memory Addressing
The address of a word matches the byte address of one of its 4 bytes The addresses of sequential words differ by 4 (word size in byte) Words' addresses are multiple of 4 (alignment restriction)
Misalignment (if allowed) complicates memory access and causes programs to run slower
12 100 10 101 1 Data
8 4 0 Address Memory
Byte Order
Given N bytes, which is the most significant, which is the least significant?
Big Endian
Leftmost / most significant byte = word address
Little Endian
Rightmost / least significant byte = word address
Byte ordering can be as problem when exchanging data among different machines Can also affect array index calculation or any other operation that treat the same data a both byte and word.
Addressing Modes
How to specify the location of an operand (effective address) Addressing modes have the ability to:
Significantly reduce instruction counts Increase the average CPI Increase the complexity of building a machine
VAX machine is used for benchmark data since it supports wide range of memory addressing modes Can classify based on:
source of the data (register, immediate or memory) the address calculation (direct, indirect, indexed)
Example
ADD R4, R3 ADD R4, #3 ADD R4, (R1) ADD R4, (1001) ADD R4, 100 (R1) ADD R4, (R1 + R2) ADD R4, (R2) +
Meaning
Regs[R4] = Regs[R4] + Regs[R3] Regs[R4] = Regs[R4] + 3 Regs[R4] = Regs[R4] + Mem[Regs[R1] ] Regs[R4] = Regs[R4] + Mem[ 1001 ] Regs[R4] = Regs[R4] + Mem[ 100 + Regs[R1] ] Regs[R4] = Regs[R4] + Mem[Regs[R1] + Regs[R2]] Regs[R4] = Regs[R4] + Mem[Regs[R2] ] Regs[R2] = Regs[R2] + d Regs[R2] = Regs[R2] d Regs[R4] = Regs[R4] + Mem[Regs[R2] ] Regs[R4] = Regs[R4] + Mem[100 + Regs[R2] + Regs[R3] * d]
When used
When a value is in a register For constants Accessing using a pointer or a computed address Sometimes useful for accessing static data; address constant may need to be large Accessing local variables Sometimes useful in array addressing: R1 = base of the array: R2 = index amount Useful for stepping through arrays within a loop. R2 points to start of the array; each reference increments R2 by d. Same use as autoincrement. Autodecrement/increment can also act as push/pop to implement a stack Used to index arrays.
Auto decrement
Scaled
Percentage of displacement
Similar measurements on the VAX (with 32-bit immediate values) showed that 20-25% of immediate values were longer than 16-bits
DSP offers special addressing modes to better serve popular algorithms Special features requires either hand coding or a compiler that uses such features
Modulo addressing:
Reverse addressing:
Address is the reverse order of the current address Expedites access / otherwise require a number of logical instructions or extra memory accesses
Register
Byte
Halfword
Word
PC
Word
Concatenation
Memor y
PC
Word
MIPS assembler allows only one instruction/line and ignore comments following # until end of line
Example:
Translation of a segment of a C program to MIPS assembly instructions: C: f = (g + h) - (i + j) t0, g, h t1, i, j f, t0, t1 # temp. variable t0 contains "g + h" # temp. variable t1 contains "i + j" # f = t0 - t1 = (g + h) - (i + j) (pseudo)MIPS: add add sub
Operator type Arithmetic and logical Data Transfer Control System Floating point Decimal String Graphics
Arithmetic, logical, data transfer and control are almost standard categories for all machines System instructions are required for multiprogramming environment although support for system functions varies Others can be primitives (e.g. decimal and string on IBM 360 and VAX), provided by a co-processor, or synthesized by compiler.
Partitioned Add:
The most widely executed instructions are the simple operations of an instruction set Average usage in SPECint92 on Intel 80x86:
Rank 1 2 3 4 5 6 7 8 9 10 80x86 Instruction Load Conditional branch Compare Store Add And Sub Move register-register Call Return Total Integer Average (% total executed) 22% 20% 16% 12% 8% 6% 5% 4% 1% 1% 96%
Jump: unconditional change in the control flow Branch: conditional change in the control flow Procedure calls and returns
PC-relative addressing
Good for short position-independent forward & backward jumps
Condition Evaluation
Name
Condition Code (CC) Condition register Compare & branch
Advantages
Sometimes condition is set for free Simple One instruction rather than two for a branch
Disadvantages
CC is extra state. Condition codes constrain instructions ordering since they pass info. from one instruction to a branch Uses up a register May be too much work per instruction
Remember to focus Remember to focus on the common case on the common case
DSPs support repeat instruction for for loops (vectors) using 3 registers
Common types include character, half word and word size integer, single- and doubleprecision floating point
Characters are almost always in ASCII, though 16bit Unicode (for international characters) is gaining popularity Integers in 2s complement Floating point in IEEE 754
Unusual Types
Business Applications
Binary Coded Decimal (BCD)
Exactly represents all decimal fractions (binary doesnt!)
DSP
Fixed point
Good for limited range numbers: more mantissa bits
Graphics
4-element vector operations (RGBA or XYZW)
8-bit, 16-bit or singleprecision floating point
Size of Operands
Frequency of reference by size based on SPEC2000 on Alpha
Double-word: double-precision floating point + addresses in 64-bit machines Words: most integer operations + addresses in 32-bit machines For the mix in SPEC, word and double-word data types dominates
Instruction Representation
All data in computer systems is represented in binary Instructions are no exception The program that translates the human-readable code to numeric form is called an Assembler Hence machine-language or assembly-language
Example: Assembly: M/C language (binary): M/C language (hex): ADD $t0, $s1, $s2
000000 00001 00010 00000 00000 100000 0000 0000 0010 0010 0000 0000 0010 0000 0x00220020
Note: MIPS compiler by default maps $s0,,$s7 to reg. 16-23 and $t0,,$t7 to reg. 8-15
Fixed size instruction encoding simplifies CPU design but limits addressing choices
Encoding Examples
funct codes
000 001 010 011 100 101 110 111 000 001 010 sll srl jr jalr mfhi mthi mflo mult multu div add addu sub slt 011 100 sra sllv mtlo divu subu sltu 101 110 111 srlv srav
and
or
xor
nor
Processor
Conclusion
Summary
Type and size of operands
(common data types, effect of operand size on complexity)
Next Week
Role and effect of compilers on ISA Pipelined execution of instructions Pipeline hazards