bitpit icon indicating copy to clipboard operation
bitpit copied to clipboard

Substitute std::pow functions used in RBF with a faster implementation

Open kgkara opened this issue 3 years ago • 4 comments

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.

kgkara avatar May 03 '21 09:05 kgkara

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."

andrea-iob avatar May 03 '21 09:05 andrea-iob

Thanks, I will have a look at it.

kgkara avatar May 03 '21 09:05 kgkara

Is this still relevant?

andrea-iob avatar Nov 29 '21 08:11 andrea-iob

Nothing was done about this, but I think that this issue will be studied later but I don't know yet when.

kgkara avatar Nov 29 '21 09:11 kgkara