We could use the BOOST forms instead if they do the same thing
or better. It looks like they’ll reduce to our existing use for
g++. Is the Boost module header-only for them? If so, I’d rather
use the BOOST versions to push off all the ifdefs on compiler
type into BOOST—they’re much more likely to keep up with the compilers
than we are.
Quickly looking over this I got the impression that boost config is header only. Do we have a good benchmark for Stan where I could test if now clang compiled programs speed up due to enabled branch prediction?
I now managed to benchmark using the examples you sent me, Bob. Specifically I use the normal_log_density_stan example and I cannot really conclude anything from that. I first tested if the g++ compiler did accelerate due to the use of the likely macro before going to clang++. All of this was performed on my macOS 10.12 laptop using the current dev version stan.
g++ 4.6 seems to benefit from using likely, but this is far from being clear from the benchmark
g++ 6 seems to slow down from a defined __builtin_expect macro
clang can be faster for small sizes, but seems to be slower for large sizes
All of the above would need extensive testing to get the statistics right. Maybe we have some better tests for this?
As of now I would recommend to switch to the boost macros if we really think we are doing something smart here; from what I have seen so far - I don’t know. I remember Mike having seen major speedups for higher order derivatives… so maybe these cases can answer the question more clearly.
PS: The quoted version of stan 2.6.3 does not work out of the box with the code you sent me. Maybe there was an update in between? The current dev version of stan-math worked somewhat easier with it…
I was first using stan 2.6.3 as this is the version referred to in the arXiv autodiff paper. My comment related to the fact that the sources Bob sent me did not work out of the box with 2.6.3; so maybe there was an update to the sources after the paper was put on arXiv.
However, what I have reported above is against the current dev version. I guess that’s close enough to 2.12.0, or?
boosts likely vs “bare” computation (no branch prediction)
stans vanilla likely vs “bare”
is different. To me it looks like I am a victim of small effect sizes here - all noise. I would have to do serious simulation to find out more and be able to report something useful. Let’s just put this aside… looks like digging in dirt here.