Beruflich Dokumente
Kultur Dokumente
Chapter 1
Fundamentals
Chapter 1 - Fundamentals 1
Introduction
1.1 Introduction
1.2 The Task of a Computer Designer
1.3 Technology and Computer Usage Trends
1.4 Cost and Trends in Cost
1.5 Measuring and Reporting Performance
1.6 Quantitative Principles of Computer Design
1.7 Putting It All Together: The Concept of Memory Hierarchy
Chapter 1 - Fundamentals 2
Art and
Architecture
Lyonel Feininger,
Marktkirche in Halle
Chapter 1 - Fundamentals 3
Art and Architecture
Notre Dame
de Paris
SOFTWARE
Chapter 1 - Fundamentals 5
What’s Computer Architecture?
• 1950s to 1960s: Computer Architecture Course
Computer Arithmetic.
• 1970s to mid 1980s: Computer Architecture Course
Instruction Set Design, especially ISA appropriate for
compilers. (What we’ll do in Chapter 2)
• 1990s to 2000s: Computer Architecture Course
Design of CPU, memory system, I/O system,
Multiprocessors. (All evolving at a tremendous rate!)
Chapter 1 - Fundamentals 6
The Task of a
Computer Designer
1.1 Introduction
1.2 The Task of a Computer
Designer
1.3 Technology and Computer
Usage Trends Evaluate Existing
1.4 Cost and Trends in Cost Implementation Systems for
1.5 Measuring and Reporting Complexity Bottlenecks
Performance
1.6 Quantitative Principles of
Computer Design Benchmarks
1.7 Putting It All Together: The
Concept of Memory Technology
Hierarchy Trends
Implement Next
Simulate New
Generation System
Designs and
Organizations
Workloads
Chapter 1 - Fundamentals 7
Technology and
Computer Usage Trends
1.1 Introduction
1.2 The Task of a Computer Designer When building a Cathedral numerous
1.3 Technology and Computer Usage very practical considerations need to
Trends
be taken into account:
1.4 Cost and Trends in Cost
1.5 Measuring and Reporting Performance • available materials
1.6 Quantitative Principles of Computer • worker skills
Design
• willingness of the client to pay the
1.7 Putting It All Together: The Concept of
Memory Hierarchy price.
Chapter 1 - Fundamentals 8
Trends
Gordon Moore (Founder of Intel) observed in 1965 that the number of
transistors that could be crammed on a chip doubles every year.
This has CONTINUED to be true since then.
Transistors Per Chip
1.E+08
Pentium 3
Pentium Pro
1.E+07 Pentium II
Pentium Power PC G3
80286
1.E+05
8086
1.E+04
4004
1.E+03
1970 1975 1980 1985 1990 1995 2000 2005
Chapter 1 - Fundamentals 9
Trends
Processor performance, as measured by the SPEC benchmark has
also risen dramatically.
5000
Alpha 6/833
4000
3000
2000
DEC Alpha 5/500
DEC
1000 Sun MIPS
IBM AXP/
RS/ 500 DEC Alpha 4/266 DEC Alpha 21264/600
-4/ M
6000
260 2000
0
87
88
89
90
91
92
93
94
95
96
97
98
99
2000
Chapter 1 - Fundamentals 10
Trends
Memory Capacity (and Cost) have changed dramatically in the last 20
years.
size
1000000000
100000000
year size(Mb) cyc time
10000000
1980 0.0625 250 ns
1983 0.25 220 ns
1000000
1986 1 190 ns
100000 1989 4 165 ns
1992 16 145 ns
10000
1996 64 120 ns
1000 2000 256 100 ns
1970 1975 1980 1985 1990 1995 2000
Year
Chapter 1 - Fundamentals 11
Trends
Based on SPEED, the CPU has increased dramatically, but memory
and disk have increased only a little. This has led to dramatic
changed in architecture, Operating Systems, and Programming
practices.
Chapter 1 - Fundamentals 12
Measuring And
Reporting Performance
1.1 Introduction
1.2 The Task of a Computer Designer
1.3 Technology and Computer Usage
Trends
1.4 Cost and Trends in Cost
1.5 Measuring and Reporting Performance This section talks about:
1.6 Quantitative Principles of Computer
Design
1. Metrics – how do we describe
1.7 Putting It All Together: The Concept of
Memory Hierarchy in a numerical way the
performance of a computer?
Chapter 1 - Fundamentals 13
Metrics
Throughput
Plane DC to Paris Speed Passengers
(pmph)
BAD/Sud
3 hours 1350 mph 132 178,200
Concodre
ExTime(Y) Performance(X)
--------- = ---------------
ExTime(X) Performance(Y)
Performance Comparisons
Which of the following statements reflect the performance comparison of rabbit and
turtle?
o Rabbit is 100% faster than turtle. o Rabbit takes 200% less time than turtle.
o Rabbit is twice as fast as turtle. o Turtle is 50% as fast as rabbit.
o Rabbit takes 1/2 as long as turtle. o Turtle is 50% slower than rabbit.
o Rabbit takes 1/3 as long as turtle. o Turtle takes 200% longer than rabbit.
o Rabbit takes 100% less time than turtle. o Turtle takes 300% longer than rabbit.
Chapter 1 - Fundamentals 16
Metrics - Throughput
Application Answers per month
Operations per second
Programming
Language
Compiler
(millions) of Instructions per second: MIPS
ISA (millions) of (FP) operations per second: MFLOP/s
Datapath
Control Megabytes per second
Function Units
Transistors Wires Pins Cycles per second (clock rate)
Chapter 1 - Fundamentals 17
Methods For Predicting
Performance
• Benchmarks, Traces, Mixes
• Hardware: Cost, delay, area, power estimation
• Simulation (many levels)
– ISA, RT, Gate, Circuit
• Queuing Theory
• Rules of Thumb
• Fundamental “Laws”/Principles
Chapter 1 - Fundamentals 18
Benchmarks
SPEC: System Performance Evaluation
Cooperative
• First Round 1989
– 10 programs yielding a single number (“SPECmarks”)
• Second Round 1992
– SPECInt92 (6 integer programs) and SPECfp92 (14 floating point programs)
• Compiler Flags unlimited. March 93 of DEC 4000 Model 610:
spice: unix.c:/def=(sysv,has_bcopy,”bcopy(a,b,c)=
memcpy(b,a,c)”
wave5: /ali=(all,dcom=nat)/ag=a/ur=4/ur=200
nasa7: /norecu/ag=a/ur=4/ur2=200/lc=blas
• Third Round 1995
– new set of programs: SPECint95 (8 integer programs) and SPECfp95 (10 floating
point)
– “benchmarks useful for 3 years”
– Single flag setting for all programs: SPECint_base95, SPECfp_base95
Chapter 1 - Fundamentals 19
Benchmarks
CINT2000 (Integer Component of SPEC CPU2000):
http://www.spec.org/osg/cpu2000/CFP2000/
Chapter 1 - Fundamentals 21
Benchmarks Sample Results For
SpecINT2000
http://www.spec.org/osg/cpu2000/results/res2000q3/cpu2000-20000718-00168.asc
Chapter 1 - Fundamentals 22
Benchmarks
Performance Evaluation
• “For better or worse, benchmarks shape a field”
• Good products created when have:
– Good benchmarks
– Good ways to summarize performance
• Given sales is a function in part of performance relative to
competition, investment in improving product as reported by
performance summary
• If benchmarks/summary inadequate, then choose between
improving product for real programs vs. improving product to get
more sales;
Sales almost always wins!
• Execution time is the measure of computer performance!
Chapter 1 - Fundamentals 23
Benchmarks
How to Summarize Performance
Management would like to have one number.
Technical people want more:
1. They want to have evidence of reproducibility – there should be enough
information so that you or someone else can repeat the experiment.
2. There should be consistency when doing the measurements multiple
times.
Program P1 (secs) 1 10 20
Chapter 1 - Fundamentals 24
Quantitative Principles
of Computer Design
1.1 Introduction
1.2 The Task of a Computer Designer
1.3 Technology and Computer Usage
Trends
1.4 Cost and Trends in Cost
Make the common case fast.
1.5 Measuring and Reporting Performance Amdahl’s Law:
1.6 Quantitative Principles of Computer Relates total speedup of a
Design
system to the speedup of some
1.7 Putting It All Together: The Concept of
Memory Hierarchy portion of that system.
Chapter 1 - Fundamentals 25
Quantitative Amdahl's Law
Design
Speedupenhanced
1
ExTimeold
Speedupoverall = =
ExTimenew (1 - Fractionenhanced) + Fractionenhanced
Speedupenhanced
Chapter 1 - Fundamentals 27
Quantitative Amdahl's Law
Design
• Floating point instructions improved to run 2X; but only
10% of actual instructions are FP
1
Speedupoverall = = 1.053
0.95
Chapter 1 - Fundamentals 28
Quantitative Cycles Per
Design Instruction
CPI = (CPU Time * Clock Rate) / Instruction Count
= Cycles / Instruction Count
n
CPU _ Time = Cycle _ Time * ∑ CPI i * I i
i =1
“Instruction Frequency” Number of
instructions of
type I.
n
CPI = ∑ CPI i * Fi where Fi = Ii
Instruction _ Count
i =1
Chapter 1 - Fundamentals 31
The Concept of
Memory Hierarchy
1.1 Introduction
1.2 The Task of a Computer Designer
1.3 Technology and Computer Usage
Trends
1.4 Cost and Trends in Cost Fast memory is expensive.
1.5 Measuring and Reporting Performance
1.6 Quantitative Principles of Computer
Design Slow memory is cheap.
1.7 Putting It All Together: The Concept of
Memory Hierarchy
The goal is to minimize the
price/performance for a
particular price point.
Chapter 1 - Fundamentals 32
Memory Hierarchy
Level 1 Level 2
Registers Memory Disk
cache Cache
Chapter 1 - Fundamentals 33
Memory Hierarchy
• Hit: data appears in some block in the upper level (example:
Block X)
– Hit Rate: the fraction of memory access found in the upper level
– Hit Time: Time to access the upper level which consists of
RAM access time + Time to determine hit/miss
• Miss: data needs to be retrieve from a block in the lower level
(Block Y)
– Miss Rate = 1 - (Hit Rate)
– Miss Penalty: Time to replace a block in the upper level +
Time to deliver the block the processor
• Hit Time << Miss Penalty (500 instructions on 21264!)
Chapter 1 - Fundamentals 34
Memory Hierarchy
Level 1 Level 2
Registers Memory Disk
cache Cache
Chapter 1 - Fundamentals 35
Wrap Up
1.1 Introduction
1.2 The Task of a Computer Designer
1.3 Technology and Computer Usage Trends
1.4 Cost and Trends in Cost
1.5 Measuring and Reporting Performance
1.6 Quantitative Principles of Computer Design
1.7 Putting It All Together: The Concept of Memory Hierarchy
Chapter 1 - Fundamentals 36
Computer Architecture
Chapter 2
Instruction Sets
Chapter 1 - Fundamentals 37
Introduction
2.1 Introduction
2.2 Classifying Instruction Set Architectures
2.3 Memory Addressing
2.4 Operations in the Instruction Set
2.5 Type and Size of Operands
2.6 Encoding and Instruction Set
2.7 The Role of Compilers
2.8 The MIPS Architecture
Bonus
Chapter 1 - Fundamentals 38
Introduction
The Instruction Set Architecture is that portion of the machine visible
to the assembly level programmer or to the compiler writer.
software
instruction set
hardware
Chapter 1 - Fundamentals 40
Instruction Set Basic ISA
Architectures Classes
Accumulator:
1 address add A acc ← acc + mem[A]
1+x address addx A acc ← acc + mem[A + x]
Stack:
0 address add tos ← tos + next
Chapter 1 - Fundamentals 41
Instruction Set Basic ISA
Architectures Classes
The results of different address classes is easiest to see with the examples here,
all of which implement the sequences for C = A + B.
Pop C Store C, R3
Registers are the class that won out. The more registers on the CPU, the better.
Chapter 1 - Fundamentals 42
Instruction Set Intel 80x86
Architectures Integer Registers
GPR0 EAX Accumulator
GPR1 ECX Count register, string, loop
GPR2 EDX Data Register; multiply, divide
GPR3 EBX Base Address Register
GPR4 ESP Stack Pointer
GPR5 EBP Base Pointer – for base of stack seg.
GPR6 ESI Index Register
GPR7 EDI Index Register
CS Code Segment Pointer
SS Stack Segment Pointer
DS Data Segment Pointer
ES Extra Data Segment Pointer
FS Data Seg. 2
GS Data Seg. 3
PC EIP Instruction Counter
Eflags Condition Codes
Chapter 1 - Fundamentals 43
Memory Addressing
2.1 Introduction
2.2 Classifying Instruction Set Architectures
2.3 Memory Addressing
2.4 Operations in the Instruction Set Sections Include:
2.5 Type and Size of Operands
2.6 Encoding and Instruction Set
Interpreting Memory Addresses
2.7 The Role of Compilers
2.8 The DLX Architecture
Addressing Modes
Chapter 1 - Fundamentals 44
Memory Interpreting Memory
Addressing Addresses
Chapter 1 - Fundamentals 45
Memory Addressing
Addressing Modes
This table shows the most common modes. A more complete set is in
Figure 2.6
Chapter 1 - Fundamentals 46
Addressing Modes
Mode Example Meaning
Register add r4, r3 R[4]←R[4]+R[3]
Chapter 1 - Fundamentals 48
Memory Immediate Address
Addressing Mode
Used where we want to get to a numerical value in an
instruction.
Load R2, 17
if ( a > 17 ) CMPBGT R1, R2
Chapter 1 - Fundamentals 50
Operations In The Operator Types
Instruction Set
Arithmetic and logical - and, add
Data transfer - move, load
Control - branch, jump, call
System - system call, traps
Floating point - add, mul, div, sqrt
Decimal - add, convert
String - move, compare
Multimedia - 2D, 3D? e.g., Intel MMX and Sun VIS
Chapter 1 - Fundamentals 51
Operations In The Control
Instructions
Instruction Set Conditional branches are 20%
of all instructions!!
Chapter 1 - Fundamentals 52
Operations In The Control
Instructions
Instruction Set
There are numerous tradeoffs: There are numerous tradeoffs:
Chapter 1 - Fundamentals 53
Operations In The Control
Instructions
Instruction Set
Link Return Address: Save or restore state:
Chapter 1 - Fundamentals 54
Type And Size of Operands
2.1 Introduction
The type of the operand is usually
2.2 Classifying Instruction Set encoded in the Opcode – a LDW
Architectures
implies loading of a word.
2.3 Memory Addressing
Common sizes are:
2.4 Operations in the Instruction Set
Character (1 byte)
2.5 Type and Size of Operands
Half word (16 bits)
2.6 Encoding and Instruction Set Word (32 bits)
2.7 The Role of Compilers Single Precision Floating Point (1 Word)
2.8 The DLX Architecture Double Precision Floating Point (2 Words)
Integers are two’s complement binary.
Floating point is IEEE 754.
Some languages (like COBOL) use
packed decimal.
Chapter 1 - Fundamentals 55
Encoding And Instruction Set
2.1 Introduction This section has to do with how an
2.2 Classifying Instruction Set Architectures assembly level instruction is
2.3 Memory Addressing encoded into binary.
2.4 Operations in the Instruction Set
2.5 Type and Size of Operands
Ultimately, it’s the binary that is
2.6 Encoding and Instruction Set
read and interpreted by the
2.7 The Role of Compilers
machine.
2.8 The DLX Architecture
Chapter 1 - Fundamentals 56
Encoding And 80x86 Instruction
Instruction Set Encoding
for ( index = 0; index < iterations; index++ ) Here’s some
0040D3AF C7 45 F0 00 00 00 00 mov dword ptr [ebp-10h],0 sample code that’s
0040D3B6 EB 09 jmp main+0D1h (0040d3c1) been disassembled.
0040D3B8 8B 4D F0 mov ecx,dword ptr [ebp-10h] It was compiled
0040D3BB 83 C1 01 add ecx,1 with the debugger
0040D3BE 89 4D F0 mov dword ptr [ebp-10h],ecx option so is not
0040D3C1 8B 55 F0 mov edx,dword ptr [ebp-10h] optimized.
0040D3C4 3B 55 F8 cmp edx,dword ptr [ebp-8]
0040D3C7 7D 15 jge main+0EEh (0040d3de)
long_temp = (*alignment + long_temp) % 47; This code
0040D3C9 8B 45 F4 mov eax,dword ptr [ebp-0Ch] was
0040D3CC 8B 00 mov eax,dword ptr [eax] produced
0040D3CE 03 45 EC add eax,dword ptr [ebp-14h] using Visual
0040D3D1 99 cdq Studio
0040D3D2 B9 2F 00 00 00 mov ecx,2Fh
0040D3D7 F7 F9 idiv eax,ecx
0040D3D9 89 55 EC mov dword ptr [ebp-14h],edx
0040D3DC EB DA jmp main+0C8h (0040d3b8)
Chapter 1 - Fundamentals 57
Encoding And 80x86 Instruction
Instruction Set Encoding
Here’s some
for ( index = 0; index < iterations; index++ )
sample code that’s
00401000 8B 0D 40 54 40 00 mov ecx,dword ptr ds:[405440h]
00401006 33 D2 xor edx,edx
been disassembled.
00401008 85 C9 test ecx,ecx It was compiled
0040100A 7E 14 jle 00401020 with optimization
0040100C 56 push esi
0040100D 57 push edi This code
0040100E 8B F1 mov esi,ecx was
long_temp = (*alignment + long_temp) % 47; produced
00401010 8D 04 11 lea eax,[ecx+edx] using Visual
00401013 BF 2F 00 00 00 mov edi,2Fh Studio
00401018 99 cdq
00401019 F7 FF idiv eax,edi
0040101B 4E dec esi
0040101C 75 F2 jne 00401010
0040101E 5F pop edi
0040101F 5E pop esi
00401020 C3 ret
Chapter 1 - Fundamentals 58
Encoding And 80x86 Instruction
Instruction Set Encoding
Here’s some
for ( index = 0; index < iterations; index++ )
sample code that’s
0x804852f <main+143>: add $0x10,%esp been disassembled.
0x8048532 <main+146>: lea 0xfffffff8(%ebp),%edx It was compiled
0x8048535 <main+149>: test %esi,%esi with optimization
0x8048537 <main+151>: jle 0x8048543 <main+163>
0x8048539 <main+153>: mov %esi,%eax This code
0x804853b <main+155>: nop was
0x804853c <main+156>: lea 0x0(%esi,1),%esi produced
long_temp = (*alignment + long_temp) % 47; using gcc
0x8048540 <main+160>: dec %eax and gdb.
0x8048541 <main+161>: jne 0x8048540 <main+160> For details,
0x8048543 <main+163>: add $0xfffffff4,%esp
see Lab 2.1
6 2 8 8
Chapter 1 - Fundamentals 60
Encoding And 80x86 Instruction
Encoding
Instruction Set
4 4 8
JE Cond Disp.
8 16 16
6 2 8 8
5 3
PUSH Reg
Chapter 1 - Fundamentals 61
Encoding And 80x86 Instruction
Instruction Set
Here’s the instruction that we had several pages ago:
Encoding
0040D3AF C7 45 F0 00 00 00 00 mov dword ptr [ebp-10h],0
Is described in:
http://developer.intel.com/design/pentium4/manuals/245471.htm
(I found it on page 479, but this is obviously version dependent.)
Copies the second operand (source operand) to the first operand (destination operand).
The source operand can be an immediate value, general purpose register, segment
register, or memory location. Both operands must be the same size, which can be a
byte, a word, or a doubleword.
In our case, because of the “C7” Opcode, we know it’s a sub-flavor of MOV putting an
immediate value into memory.
Chapter 1 - Fundamentals 63
The Role of Steps In Compilation
Compilers
Parsing --> intermediate representation
Jump Optimization
Loop Optimizations
Register Allocation
Code Generation --> assembly code
Common Sub-Expression
Procedure in-lining
Constant Propagation
Strength Reduction
Pipeline Scheduling
Chapter 1 - Fundamentals 64
The Role of
Steps In Compilation
Compilers
Optimization Explanation % of the total number of
Name optimizing
transformations
High Level At or near the source level; Not Measured
machine-independent
Chapter 1 - Fundamentals 65
The Role of What compiler writers want:
Compilers
One solution or all possible solutions
• regularity • 2 branch conditions - eq, lt
• orthogonality • or all six - eq, ne, lt, gt, le, ge
• composability • not 3 or 4
Chapter 1 - Fundamentals 66
The MIPS Architecture
2.1 Introduction
2.2 Classifying Instruction Set Architectures
2.3 Memory Addressing MIPS is very RISC oriented.
2.4 Operations in the Instruction Set
2.5 Type and Size of Operands
MIPS will be used for many
2.6 Encoding and Instruction Set
2.7 The Role of Compilers
examples throughout the
2.8 The MIPS Architecture course.
Chapter 1 - Fundamentals 67
The MIPS MIPS Characteristics
Architecture Addressing Modes
There’s MIPS – 32 that we learned in • Immediate
CS140 • Displacement
32-bit byte addresses aligned • (Register Mode used only for ALU)
Load/store - only displacement
addressing
Standard datatypes Data transfer
3 fixed length formats • load/store word, load/store
32 32-bit GPRs (r0 = 0) byte/halfword signed?
16 64-bit (32 32-bit) FPRs • load/store FP single/double
FP status register • moves between GPRs and FPRs
No Condition Codes ALU
There’s MIPS – 64 – the current arch. • add/subtract signed? immediate?
Standard datatypes • multiply/divide signed?
4 fixed length formats (8,16,32,64) • and,or,xor immediate?, shifts: ll, rl,
32 64-bit GPRs (r0 = 0) ra immediate?
64 64-bit FPRs • sets immediate?
Chapter 1 - Fundamentals 68
The MIPS MIPS Characteristics
Architecture
Control
• branches == 0, <> 0
• conditional branch testing FP bit
• jump, jump register
• jump & link, jump & link register
• trap, return-from-exception
Floating Point
• add/sub/mul/div
• single/double
• fp converts, fp set
Chapter 1 - Fundamentals 69
The MIPS The MIPS Encoding
Architecture
Register-Register
31 26 25 21 20 16 15 11 10 6 5 0
Register-Immediate
31 26 25 21 20 16 15 0
Op Rs1 Rd immediate
Branch
31 26 25 21 20 16 15 0
Jump / Call
31 26 25 0
Op target
Chapter 1 - Fundamentals 70
RISC versus CISC
BONUS
combines 3 features
• architecture
• implementation
• compilers and OS
argues that
• implementation effects are second order
• compilers are similar
• RISCs are better than CISCs: fair comparison?
Chapter 1 - Fundamentals 71
RISC versus CISC
BONUS
RISC factor: {CPI VAX * Instr VAX }/ {CPI MIPS * Instr MIPS }
Chapter 1 - Fundamentals 72
RISC versus CISC
BONUS
Compensating factors Factors favoring MIPS
• Increase VAX CPI but decrease • Operand specifier decoding
VAX instruction count • Number of registers
• Increase MIPS instruction count • Separate floating point unit
• e.g. 1: loads/stores versus • Simple branches/jumps (lower
operand specifiers latency)
• e.g. 2: necessary complex • No complex instructions
instructions: loop branches • Instruction scheduling
Factors favoring VAX • Translation buffer
• Big immediate values • Branch displacement size
• Not-taken branches incur no
delay
Chapter 1 - Fundamentals 73
Wrapup
2.1 Introduction
2.2 Classifying Instruction Set Architectures
2.3 Memory Addressing
2.4 Operations in the Instruction Set
2.5 Type and Size of Operands
2.6 Encoding and Instruction Set
2.7 The Role of Compilers
2.8 The DLX Architecture
Bonus
Chapter 1 - Fundamentals 74