Original Post
I have a small program that tests the speed of the various operations - addition, multiplication and division in both integer and floating point formats.
My conclusions on the speed of floating point math seem to be way off, as my CPU is taking very different amounts of time depending on the numbers being multiplied or divided.
My benchmark for testing division speed is:
The optimiser would only emit actual divide ops if I used FP:precise. FP:fast turned them into multiplication ops. FP:precise took twice as long as FP:fast due to the need to convert back to single precision after every operation. I decided to stick with FP:fast, so the optimiser created the constant 1/1.01 = 0.6834... and multiplied by it throughout. (the loops unrolled to 10 ops per iteration)
Turns out repetedly multiplying a number by 0.6834 is extremely slow on my machine. It took 30 times as long as say, multiplying by 1.00001. This is about 10 times as long as it takes to do floating point division.
Has anyone noticed this before? It has the potential to affect the performance of math intensive code in ways that I didn't realise possible. At least on my machine (Core i7 920)
My conclusions on the speed of floating point math seem to be way off, as my CPU is taking very different amounts of time depending on the numbers being multiplied or divided.
My benchmark for testing division speed is:
for(int i=0;i<numOps;i++){ flVal /= 1.01f; }The optimiser would only emit actual divide ops if I used FP:precise. FP:fast turned them into multiplication ops. FP:precise took twice as long as FP:fast due to the need to convert back to single precision after every operation. I decided to stick with FP:fast, so the optimiser created the constant 1/1.01 = 0.6834... and multiplied by it throughout. (the loops unrolled to 10 ops per iteration)
Turns out repetedly multiplying a number by 0.6834 is extremely slow on my machine. It took 30 times as long as say, multiplying by 1.00001. This is about 10 times as long as it takes to do floating point division.
Has anyone noticed this before? It has the potential to affect the performance of math intensive code in ways that I didn't realise possible. At least on my machine (Core i7 920)