I have hot spots in my code where I'm doing pow() taking up around 10-20% of my execution time.
My input to pow(x,y) is very specific, so I'm wondering if there's a way to roll two pow() approximations (one for each exponent) with higher performance:
- I have two constant exponents: 2.4 and 1/2.4.
- When the exponent is 2.4, x will be in the range (0.090473935, 1.0].
- When the exponent is 1/2.4, x will be in the range (0.0031308, 1.0].
- I'm using SSE/AVX
floatvectors. If platform specifics can be taken advantage of, right on!
A maximum error rate around 0.01% is ideal, though I'm interested in full precision (for float) algorithms as well.
I'm already using a fast pow() approximation, but it doesn't take these constraints into account. Is it possible to do better?