bitpit
bitpit copied to clipboard
Substitute std::pow functions used in RBF with a faster implementation
RBFs make use of std::pow(a,b), in which b is always an integer. By carrying out tests for the std::pow function, it seems that this is suboptimal in contrast to the case in which an in-house version of a "pow" function is used, which is specialized for exponents of type of integer. The speed-up is at least an order of magnitude.
The bitpit module "operators" defines a specialized "pow" version for unsigned integer exponents (uipow). Would it be possible for you to do some tests using that function?
For future reference, https://baptiste-wicht.com/posts/2017/09/cpp11-performance-tip-when-to-use-std-pow.html contains some benchmarks that compare std::pow with a handcrafted equivalent. Citing from the conclusions of that blog post: "If you are using double precision (double), std::pow(x, n) will be slower than the handcrafted equivalent unless you use -ffast-math, in which case, there is absolutely no overhead. The overhead without using the compiler option is quite large, around 2 orders of magnitude, starting from the third power. With or without -ffast-math, std::pow(x, 2) has no overhead compared to x * x."
Thanks, I will have a look at it.
Is this still relevant?
Nothing was done about this, but I think that this issue will be studied later but I don't know yet when.