I'm trying to look into C++'s operators to see if it's possible to create a math function that executes faster than those in the STL, but less accurate, for when high precision isn't necessary (and also to expand my knowledge of some of the ones I haven't used as much, like the bitwise operators). A consideration, though, seems to be that not all operators are equal; I've heard that floating point multiplication can be very slow compared to bitwise operations.
Are there any other C++ operators that could possibly take a very long amount of time to execute, assuming that only int and float data types are used?
Also, does it take a long time to cast an int to a float and vice versa?
And, as a separate note, (for example) if there is a way to perform bitwise operations on floats, or other strange combinations, is it possible that it'll give a different result on a different machine than mine?
Using C++ operators effectively and efficiently
Page 1 of 11 Replies - 208 Views - Last Post: 20 February 2013 - 03:08 PM
Replies To: Using C++ operators effectively and efficiently
#2
Re: Using C++ operators effectively and efficiently
Posted 20 February 2013 - 03:08 PM
Good luck, if you are talking about replacing all these functions:
http://en.cppreferen...pp/numeric/math
http://en.cppreferen...numeric/complex
http://en.cppreferen.../numeric/random
then good luck. You've got a big project ahead of you. I'd like to see your performance numbers and too see if the weeks/months that you spend is worth the milliseconds of speed that you will gain.
As for getting different results on different machines, it's really a matter of several factors:
- raw speed of the processor
- processor architecture (ex. RISC vs CISC)
- processor family/generation with the family
- variants of the processor (same processor family, but different cache sizes)
- quality of your compiler
- quality of your runtime library
If you are willing to hold those factors stable to be able to do apples to apples comparison, then it should be the same results.
http://en.cppreferen...pp/numeric/math
http://en.cppreferen...numeric/complex
http://en.cppreferen.../numeric/random
then good luck. You've got a big project ahead of you. I'd like to see your performance numbers and too see if the weeks/months that you spend is worth the milliseconds of speed that you will gain.
As for getting different results on different machines, it's really a matter of several factors:
- raw speed of the processor
- processor architecture (ex. RISC vs CISC)
- processor family/generation with the family
- variants of the processor (same processor family, but different cache sizes)
- quality of your compiler
- quality of your runtime library
If you are willing to hold those factors stable to be able to do apples to apples comparison, then it should be the same results.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|