We have a CFD solver and while running a simulation, it was found to run extraordinarily slow on some machines but not others. Using Intel VTune, it was found the following
Just write your own pow
function, put the .o
file in a static library archive libmypow.a
somewhere in the linker's library path, and pass -lmypow
when linking.
pow(a,b)
is the same as exp(b*ln(a))
, maybe that substitution will work for you.
I tested this myself, and indeed if I compile the test program from the page you link to it uses call pow
in the assembly code. However, compiling with optimization -ffast-math
there is no call to pow, but the result is slightly different.
Well, hold on now. The library isn't calling __slowpow()
just to toy with you; it's calling __slowpow()
because it believes the extra precision is necessary to give an accurate result for the values you're giving it (in this case, base very near 1, exponent of order 1). If you care about the accuracy of this computation, you should understand why that is and if it matters before trying to work around it. It might be the case that for (say) large negative F0 this whole thing can be safely rounded to 1; or it might not, depending on what's done with this value later. If you ever need 1.d0 minus this result, you're going to want that extra precision.