STAN_CPP_OPTIMS=true in make/local results in STAN_CPP_OPTIMS=false in `model info`
Related to https://github.com/stan-dev/cmdstanpy/issues/794.
In cmdstan directory with no make/local I run:
make examples/bernoulli/bernoulli
./examples/bernoulli/bernoulli info
this gives:
stan_version_major = 2
stan_version_minor = 36
stan_version_patch = 0
STAN_THREADS=false
STAN_MPI=false
STAN_OPENCL=false
STAN_NO_RANGE_CHECKS=false
STAN_CPP_OPTIMS=false
Now if I create a make/local with STAN_CPP_OPTIMS=true and run:
make clean-all
make examples/bernoulli/bernoulli
./examples/bernoulli/bernoulli info
again gives:
stan_version_major = 2
stan_version_minor = 36
stan_version_patch = 0
STAN_THREADS=false
STAN_MPI=false
STAN_OPENCL=false
STAN_NO_RANGE_CHECKS=false
STAN_CPP_OPTIMS=false
I have confirmed that modifying STAN_THREADS in a similar way successfully reports STAN_THREADS=true from the model info.
I compared the compilation times with/without STAN_CPP_OPTIMS=true by running
make clean-all
time make examples/bernoulli/bernoulli
four times, modifying whether STAN_CPP_OPTIMS was present in my make/local each time. This gave:
NO STAN_CPP_OPTIMS
make examples/bernoulli/bernoulli 74.15s user 3.27s system 99% cpu 1:17.63 total
WITH STAN_CPP_OPTIMS
make examples/bernoulli/bernoulli 79.18s user 3.83s system 99% cpu 1:23.26 total
WITH STAN_CPP_OPTIMS
make examples/bernoulli/bernoulli 80.16s user 3.87s system 99% cpu 1:24.28 total
NO STAN_CPP_OPTIMS
make examples/bernoulli/bernoulli 74.68s user 3.30s system 99% cpu 1:18.20 total
So it seems like the options is impacting compilation, perhaps just an issue reporting from model info?
I can confirm that model info doesn't report this, and by going back and trying the first commit the info command was added in, it seems as though it never reported it correctly.
The reason is that STAN_CPP_OPTIMS doesn't actually lead to any #defines in the C++, unlike THREADS, OPENCL, etc. All it does (and it is doing this correctly) is set extra compiler flags that we think boost performance.
To fix this we could have it also define something that the code could actually check, or (my vote) just remove it from the output of model info. If this has been broken since it's first addition, clearly nobody is relying on it, and I don't think it 'deserves' a spot in the same way as e.g. STAN_THREADS. After all, you could pass all the same arguments yourself and it wouldn't be marked as STAN_CPP_OPTIMS