Amdahl's Law: Execution Time After Improvement
Amdahl's Law: Execution Time After Improvement
Time before
Improvement
Time after
Improvement
Amdahl’s Law
Example: Executing a program on n independent processors
Speedup =n
enhanced
ExTime oldFractionenhanced
ExTime = ExTime (1- Fractionenhanced )+
old
new n
ExTime old 1
Speedup overall
ExTimenew Fraction enhanced
1 Fractionenhanced
Speedup enhanced
Lim Speedup = 1 / (1 - Fraction )
n overall enhanced
• Example:
compiler’s job to associate
variables with registers
C code: A = B + C
Register Set:
Control Input
Memory
Datapath Output
Processor I/O
Memory Organization
• Bytes are load/store units, but most data items use larger
words
• For MIPS, a word is 32 bits or 4 bytes.
•0 32 bits of data
4 32 bits of data Registers correspondingly hold 32 bits of data
8 32 bits of data
12 32 bits of data
...
31 26 25 21 20 16 15 11 10 6 5 0
rd
rt
add $4, $3, $2
rs
31 26 25 21 20 16 15 11 10 6 5 0
0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0
opcode rs rt rd shamt funct
0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0
Encoding = 0x00622020
13
Machine Language
• Consider the load-word and store-word instructions,
– what would the regularity principle have us do?
• we would have only 5 or 6 bits to determine the offset from a base
register
op rs rt 16 bit offset
MIPS Encoding: I-Type
31 26 25 21 20 16 15 0
rt
Immediate
lw $5, 3000($2)
rs
31 26 25 21 20 16 15 0
1 0 0 0 1 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 1 0 1 1 1 0 0 0
opcode rs rt Immediate Value
1 0 0 0 1 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 1 0 1 1 1 0 0 0
Encoding = 0x8C450BB8
15
MIPS Encoding: I-Type
31 26 25 21 20 16 15 0
rt
Immediate
sw $5, 3000($2)
rs
31 26 25 21 20 16 15 0
1 0 1 0 1 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 1 0 1 1 1 0 0 0
opcode rs rt Immediate Value
1 0 1 0 1 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 1 0 1 1 1 0 0 0
Encoding = 0xAC450BB8
16
The immediate value is signed
Control: Conditional Branch
• Decision making instructions
– alter the control flow,
• i.e., change the next instruction to be executed
• Solution: specify a register (as for lw and sw) and add it to offset
– use PC (= program counter), called PC-relative addressing, based on
– principle of locality: most branches are to instructions near current
instruction (e.g., loops and if statements)
Control: Unconditional Branch (Jump)
000010 00000000000000000000011001
6 bits 26 bits
op 26 bit number
Addresses in Jump
• Word-relative addressing also for jump instructions
J op 26 bit address
op rs rt 16 bit number
How about larger constants?
• First we need to load a 32 bit constant into a register
• Must use two instructions for this: first new load upper immediate
instruction for upper 16 bits
lui $t2, 1010101010101010 filled with zeros
1010101010101010 0000000000000000
0000000000000000 1010101010101010
ori
1010101010101010 1010101010101010