Calculating Performance
Notes
- Hopefully last time we came up with a list of items that might be considered for measuring performance in a computer
- CPU speed
- Memory Capacity
- Bus Bandwidth
- Capacity for peripherals
- ?
- H & P focus on program execution time
- Is this strictly related to clock speed?
- No, clock speed is just one component.
- Execution Time Components
- CPU speed or cycles per second
- Number of instructions executed
- CPI or cycles per instruction.
- Clock speed:
- Measured in Hz.
- Determined and fixed
- Not much you can do about this.
- Instructions
- Measured in instructions
- Based on the problem/program/algorithm/compiler
- You have some control over this
- CPI:
- Determined by the operations you perform.
- Based on the problem/program/algorithm/compiler
- You have some control over this
-
perf
- Look at the man page (man perf)
- This is more accurate on intel than arm
-
perf stat -e cycles,instructions prog
- An experiment with perf
- I have written several example programs.
-
| Program | Operation | Instructions | Cycles | CPI |
| intAdd | a = b + c | 9,601,972 | 9,679,109 | 1.01 |
| intMult | a = b * c | 8,601,971 | 8,771,291 | 1.02 |
| intDiv | a = b / c | 9,601,971 | 16,167,373 | 1.68 |
| floatAdd | a = b + c | 9,601,971 | 10,150,683 | 1.06 |
| floatDiv | a = b / c | 9,601,976 | 26,193,372 | 2.73 |
| arrayAdd | a[i] = b[i] + 7 | 1,048,263,321 | 1,257,159,126 | 1.20 |
| arrayDiv | a[i] = b[i] / 7 | 1,055,263,333 | 1,253,667,290 | 1.19 |
- These are not perfect, they are just to show
- Int add and multiplication are fairly similar
- Int division is yucky
- Array access is somewhat in-between , and dominates the operation
- Floating point add, and multiply are not too bad
- Floating point division is very yucky
- In the end, my experiment is flawed because
- I have not really studied perf, so I might not be using it correctly
- I have not automated data collection and processing, so there could be hand copy and paste errors
- I am allowing the compiler to move to assembly language, so I could be encountering some unexpected optimization
- Definitely do not us
-On when compiling.
- Cache could have an impact here, I was definitely trying for that in the array programs.
- But it should be clear that different instructions have different CPI's
- And that this is somewhat controllable by the programmer.
- Note, that the cpi does not have to be greater than 1
- This seems strange, but we might be able to execute more than one instruction at a time!
- See me at the end of the semester.
- I will get accounts set up on Archimedes soon, you should
- Consider an hour or so of experimentation to see if Intel and ARM are similar
- Note: The ARM family handles instruction tracing much different than the Intel family
- Do to this, the results reported by perf on an ARM machine are very different.
- Try this on another Intel or AMD architecture
- Mirkwood has Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
-
cat /proc/cpuinfo | grep "model name" on linux
- Experiment with other programs/instructions. See if you can find a combination that is worse than floatDiv.cpp