Title | CSE675 03 Performance - Lecture notes 1-3 |
---|---|
Course | Computer Arch |
Institution | Al Zaiem Al Azhari University |
Pages | 13 |
File Size | 611.3 KB |
File Type | |
Total Downloads | 47 |
Total Views | 174 |
Per...
CSE 675.02: Introduction to Computer Architecture
Performances of Computer Systems
Performance • • • •
Measure, Report, and Summarize Make intelligent choices See through the marketing hype Key to understanding underlying organizational motivation Why is some hardware better than others for different programs?
Presentation C
What factors of system performance are hardware related? (e.g., Do we need a new machine, or a new operating system?) How does the machine's instruction set affect performance? Gojko Babić
06/27/2005
Basic Performance Metrics
Which of these airplanes has the best performance?
Airplane
Passengers
Boeing 737-100 Boeing 747 BAC/Sud Concorde Douglas DC-8-50
101 470 132 146
Range (mi) Speed (mph) 630 4150 4000 8720
598 610 1350 544
• How much faster is the Concorde compared to the 747? • How much bigger is the 747 than the Douglas DC-8?
• Response time: the time between the start and the completion of a task (in time units) • Throughput: the total amount of tasks done in a given time period (in number of tasks per unit of time) • Example: Car assembly factory: – 4 hours to produce a car (response time), – 6 cars per an hour produced (throughput) In general, there is no relationship between those two metrics, – throughput of the car assembly factory may increase to 18 cars per an hour without changing time to produce one car. – How? g. babic
Presentation C
4
Computer Performance: Introduction • The computer user is interested in response time (or execution time) – the time between the start and completion of a given task (program).
Computer Performance: TIME, TIME, TIME •
Response Time (latency) — How long does it take for my job to run? — How long does it take to execute a job? — How long must I wait for the database query?
•
Throughput — How many jobs can the machine run at once? — What is the average execution rate? — How much work is getting done?
•
If we upgrade a machine with a new processor what do we increase?
•
If we add a new machine to the lab what do we increase?
• The manager of a data processing center is interested in throughput – the total amount of work done in given time. • The computer user wants response time to decrease, while the manager wants throughput increased. • Main factors influencing performance of computer system are: – processor and memory, – input/output controllers and peripherals, – compilers, and – operating system. g. babic
Presentation C
5
Analysis of CPU Time
Execution Time • Elapsed Time – counts everything (disk and memory accesses, I/O , etc.) – a useful number, but often not good for comparison purposes
• CPU time – doesn't count I/O or time spent running other programs – can be broken up into system time, and user time
CPU time depends on the program which is executed, including: – a number of instructions executed, – types of instructions executed and their frequency of usage. Computers are constructed is such way that events in hardware are synchronized using a clock. Clock rate is given in Hz (=1/sec). A clock rate defines durations of discrete time intervals called clock cycle times or clock cycle periods:
• Our focus: user CPU time – time spent executing the lines of code that are "in" our program
g. babic
Presentation C
8
Book's Definition of Performance •
seconds cycles seconds = × program program cycle
PerformanceX = 1 / Execution timeX
• •
cycle time = time between ticks = seconds per cycle clock rate (frequency) = cycles per second (1 Hz. = 1 cycle/sec)
time
A 4 Ghz. clock has a
– machine A runs a program in 20 seconds – machine B runs the same program in 25 seconds
=
cycles program
×
seconds cycle
So, to improve performance (everything else being equal) you can either (increase or decrease?)
cycle time
• Could assume that number of cycles equals number of instructions
•
...
program
6th
seconds
× 1012 = 250picoseconds (ps)
How many cycles are required for a program?
5th
How to Improve Performance
1 4 ×10 9
4th
• Problem:
Clock “ticks” indicate when to start activities (one abstraction):
3rd instruction
Performance (X) n = –––––––––––––– Performance (Y)
•
2nd instruction
• "X is n times faster than Y"
Instead of reporting execution time in seconds, we often use cycles
1st instruction
• For some program running on machine X,
Clock Cycles
________ the # of required cycles for a program, or time
________ the clock cycle time or, said another way, ________ the clock rate.
This assumption is incorrect, different instructions take different amounts of time on different machines. Why? hint: remember that these are machine instructions, not lines of C code
Different numbers of cycles for different instructions
Example
time
• Multiplication takes more time than addition • Floating point operations take longer than integer ones • Accessing memory takes more time than accessing registers •
Important point: changing the cycle time often changes the number of cycles required for various instructions (more later)
• Our favorite program runs in 10 seconds on computer A, which has a 4 GHz. clock. We are trying to help a computer designer build a new machine B, that will run this program in 6 seconds. The designer can use new (or perhaps more expensive) technology to substantially increase the clock rate, but has informed us that this increase will affect the rest of the CPU design, causing machine B to require 1.2 times as many clock cycles as machine A for the same program. What clock rate should we tell the designer to target?"
Now that we understand cycles •
A given program will require – some number of instructions (machine instructions) – some number of cycles – some number of seconds
•
We have a vocabulary that relates these quantities: – cycle time (seconds per cycle) – clock rate (cycles per second)
Performance • Performance is determined by execution time • Do any of the other variables equal performance? – – – – –
# of cycles to execute program? # of instructions in program? # of cycles per second? average # of cycles per instruction? average # of instructions per second?
– CPI (cycles per instruction) a floating point intensive application might have a higher CPI
– MIPS (millions of instructions per second) this would be higher for a program using simple instructions
• Common pitfall: thinking one of the variables is indicative of performance when it really isn’t.
CPU Time Equation
CPI Example
• CPU time = Clock cycles for a program * Clock cycle time = Clock cycles for a program / Clock rate Clock cycles for a program is a total number of clock cycles needed to execute all instructions of a given program.
•
Suppose we have two implementations of the same instruction set architecture (ISA). For some program,
• CPU time = Instruction count * CPI / Clock rate
Machine A has a clock cycle time of 250 ps and a CPI of 2.0 Machine B has a clock cycle time of 500 ps and a CPI of 1.2
CPI – the average number of clock cycles per instruction (for a given execution of a given program) is an important parameter given as:
What machine is faster for this program, and by how much?
CPI = Clock cycles for a program / Instructions count •
Instruction count is a number of instructions executed, sometimes referred as the instruction path length. g. babic
Presentation C
17
# of Instructions Example • A compiler designer is trying to decide between two code sequences for a particular machine. Based on the hardware implementation, there are three different classes of instructions: Class A, Class B, and Class C, and they require one, two, and three cycles (respectively). The first code sequence has 5 instructions: 2 of A, 1 of B, and 2 of C The second sequence has 6 instructions: 4 of A, 1 of B, and 1 of C. Which sequence will be faster? How much? What is the CPI for each sequence?
If two machines have the same ISA which of our quantities (e.g., clock rate, CPI, execution time, # of instructions, MIPS) will always be identical?
MIPS example •
Two different compilers are being tested for a 4 GHz. machine with three different classes of instructions: Class A, Class B, and Class C, which require one, two, and three cycles (respectively). Both compilers are used to produce code for a large piece of software. The first compiler's code uses 5 million Class A instructions, 1 million Class B instructions, and 1 million Class C instructions. The second compiler's code uses 10 million Class A instructions, 1 million Class B instructions, and 1 million Class C instructions.
• •
Which sequence will be faster according to MIPS? Which sequence will be faster according to execution time?
Sequential Execution of 3 LW Instructions
Phases in Instruction Execution
• Assumed are the following delays: Memory access = 2 nsec, ALU operation = 2 nsec, Register file access = 1 nsec;
• We can divide the execution of an instruction into the following five stages:
P r o g ra m 2
e x e c u tio n
– IF: Instruction fetch
o rd e r
4
6
8
10
12
14
16
18
T im e
( i n i n s t r u c t io n s )
– ID: Instruction decode and register fetch
lw r 1 , 1 0 0 ( r 0 )
– EX: Execution, effective address or branch calculation
lw r 2 , 2 0 0 ( r 0 )
– MEM: Memory access (for lw and sw instructions only)
I n s t r u c t io n
D a ta R eg
A LU
fe tc h
access
8 ns
R eg
I n s t r u c t io n
D a ta R eg
A LU
fe tc h
a c c e ss
R eg
I n s t r u c t io n
lw r 3 , 3 0 0 ( r 0 )
8 ns
fe tc h
... 8 ns
– WB: Register write back (for ALU and lw instructions) Every lw instruction needs 8 nsec to execute.
In this course, we are designing processors that execute instructions sequentially. g. babic
Presentation C
21
g. babic
Consider an implementation of MIPS ISA with 500 MHz clock and – each ALU instruction takes 3 clock cycles, – each branch/jump instruction takes 2 clock cycles, – each sw instruction takes 4 clock cycles, – each lw instruction takes 5 clock cycles. Also, consider a program that during its execution executes: – x=200 million ALU instructions – y=55 million branch/jump instructions – z=25 million sw instructions – w=20 million lw instructions Find CPU time. Presentation C
22
CPU Time: Example 1 (continued)
CPU Time: Example 1
g. babic
Presentation C
23
• a. Approach 1: Clock cycles for a program = (x×3 + y×2 + z×4 + w×5) = 910 × 106 clock cycles CPU_time = Clock cycles for a program / Clock rate = 910 × 106 / 500 × 106 = 1.82 sec • b. Approach 2: CPI = Clock cycles for a program / Instructions count CPI = (x×3 + y×2 + z×4 + w×5)/ (x + y + z + w) = 3.03 clock cycles/ instruction CPU time = Instruction count × CPI / Clock rate = (x+y+z+w) × 3.03 / 500 × 106 = 300 × 106 × 3.03 /500 × 106 = 1.82 sec g. babic
Presentation C
24
Analysis of CPU Performance Equation
CPU Time: Example 2 Consider another implementation of MIPS ISA with 1 GHz clock and – each ALU instruction takes 4 clock cycles, – each branch/jump instruction takes 3 clock cycles, – each sw instruction takes 5 clock cycles, – each lw instruction takes 6 clock cycles. Also, consider the same program as in Example 1. Find CPI and CPU time. CPI = (x×4 + y×3 + z×5 + w×6)/ (x + y + z + w) = 4.03 clock cycles/ instruction
Presentation C
• How to improve (i.e. decrease) CPU time: – Clock rate: hardware technology & organization, – CPI: organization, ISA and compiler technology, – Instruction count: ISA & compiler technology. Many potential performance improvement techniques primarily improve one component with small or predictable impact on the other two.
CPU time = Instruction count × CPI / Clock rate = (x+y+z+w) × 4.03 / 1000 × 106 = 300 × 106 × 4.03 /1000 × 106 = 1.21 sec g. babic
• CPU time = Instruction count * CPI / Clock rate
25
g. babic
Presentation C
26
Calculating Components of CPU time
Attempting to Calculate CPI
• For an existing processor it is easy to obtain the CPU time (i.e. the execution time) by measurement, and the clock rate is known. But, it is difficult to figure out the instruction count or CPI.
The table below indicates frequency of all instruction types executed in a “typical” program and, from the reference manual, we are provided with a number of cycles per instruction for each type. Instruction Type ALU instruction Load instruction
Newer processors, MIPS64 processor is such an example, include counters for instructions executed and for clock cycles. Those can be helpful to programmers trying to understand and tune the performance of an application. • Also, different simulation techniques and queuing theory could be used to obtain values for components of the execution (CPU) time. g. babic
Presentation C
27
Store instruction Branch instruction
Frequency 50% 30% 5%
Cycles 4 5 4
15%
2
CPI = 0.5*4 + 0.3*5 + 0.05*4 + 0.15*2 = 4 cycles/instruction The calculation may not be necessary correct since the numbers for cycles per instruction given don’t account for pipeline effects. g. babic
Presentation C
28
Pipelining: Its Natural!
Sequential Laundry 6 PM
7
8
9
11
10
Midnight
Time
• Dave has four loads of clothes to wash, dry, and fold
A
B
C
30 40 20 30 40 20 30 40 20 30 40 20
D T a s k
• Washer takes 30 minutes
A B
O r d e r
• Dryer takes 40 minutes
C D Sequential laundry takes 6 hours for 4 loads;
• “Folder” takes 20 minutes g. babic
If Dave learned pipelining, how long would laundry take?
Presentation C
29
7
8
9
10
Presentation C
30
Pipeline Executing 3 LW Instructions
Pipelined Laundry 6 PM
g. babic
11
Midnight
• Assuming delays as in the sequential case and pipelined processor with a clock cycle time of 2 nsec. P ro g r a m
Time
2
e x e c u t io n
4
6
8
10
12
14
T im e o rd e r
30 40
40
40
( i n i n s t r u c t io n s )
40 20
lw r 1 , 1 0 0 ( r 0 )
I n s t r u c t io n
R eg
A L U
fe tc h
T a s k
A
lw r 2 , 2 0 0 ( r 0 )
lw r 3 , 3 0 0 ( r 0 )
B
In s tru c tio n
2 ns
fe tc h
2 ns
I n s t r u c t io n
A LU
R eg
access
A LU
fe tc h
C
R eg
D a ta
R eg
a cc e s s
2 ns
2 ns
2 ns
2 ns
Note that registers are written during the first part of a cycle and read during the second part of the same cycle.
D
• Pipelining doesn’t help to execute a single instruction, it may improve performance by increasing instruction throughput;
Pipelined laundry takes 3.5 hours for 4 loads; g. babic
R eg
D a ta R eg
2 ns
O r d e r
D a ta a cc e s s
Presentation C
31
g. babic
Presentation C
32
Quantitative Performance Measures
Quantitative Performance Measures (continued)
• The original performance measure was time to perform an individual instruction, e.g. add. Instructions took the same time, Æ appropriate. • Next performance measure was the average instruction time, obtained from the relative frequency of instructions in some typical instruction mix and times to execute each instruction. Since instruction sets were similar, this was a more accurate comparison. • One alternative to execution time as the metric was MIPS – Million Instructions Per Second. For a given program MIPS rating is simple:
• Another popular, misleading and essentially useless measure was peak MIPS. That is a MIPS obtained using an instruction mix that minimizes the CPI, even if that instruction mix is totally impractical. Computer manufacturers still occasionally announce products using peak MIPS as a metric, often neglecting to include the work “peak”.
Instruction count Clock rate MIPS rating = –––––––––––––– = ––––––––– CPU time * 106 CPI * 106 The problems with MIPS rating as a performance measure: – difficult to compare computers with different instruction sets, – MIPS varies between programs on the same computer, – MIPS can vary inversely with performance! g. babic
Presentation C
33
• Another popular alternative to execution time was million floating point operations per second – MFLOPS: Number of floating point operations in a program MFLOPS = –––––––––––––––––––––––––––––––––––––––– Execution time * 106 Because it is based on operations in the program rather than on instructions, MFLOPS has a stronger claim than MIPS to being a fair comparison between different machines. MFLOPS are not applicable outside floating-point performance. g. babic
Presentation C
Benchmark Suites It has become popular to put together collection of benchmarks to try to measure the performance of processors. Benchmarks could be: – real programs; – modified (or scripted) applications; – kernels – small, key pieces from real programs; – synthetic benchmarks – not real programs, but codes try to match the average frequency of operations and operands of a large set of programs. Examples: Whetstone and Dhrystone benchmarks; • SPEC (Standard Performance Evaluation Corporation) was founded in late 1980s to try to improve the state of benchmarking and make more valid base for comparison of desk top and server c...