nimble-dev / nimble

The base NIMBLE package for R
http://R-nimble.org
BSD 3-Clause "New" or "Revised" License
156 stars 23 forks source link

`pow_int` is slow #1342

Closed paciorek closed 9 months ago

paciorek commented 1 year ago

In the wolverine example of nimbleSCR, pow is used 4 times in dbinomLocal_normal. This is apparently enough to cause a roughly 2x slowdown when run under nimble 1.0.1 compared to nimble 0.13.2.

I haven't timed pow vs pow_int individually, but switching nimble 1.0.1 to use pow in genCpp_processSpecificCalls.R causes the speed difference to disappear. And simply running dbinomLocal_normal under 1.0.1 vs. 0.13.2 shows a 2x speed difference, with the only difference in the generated C++ being pow vs. pow_int.

perrydv commented 9 months ago

This was fixed with C++ inline