Hi!
I am trying to optimize some Stan models using cmdstan-2.30.1.
When I use the following make command, everything works well:
make STAN_THREADS=TRUE STANCFLAGS=--O1 /PATH/TO/MODEL
However, if I introduce the STAN_CPP_OPTIMS flag, everything fails: make STAN_THREADS=TRUE STAN_CPP_OPTIMS=TRUE /PATH/TO/MODEL.
I am not sure what the difference between these two optimization flags, but would love to know if I should be using STAN_CPP_OPTIMS, and how I might be able to solve the errors that occur.
Since there are so many errors, I only copied some of the terminal output here: stan_cpp_optims errors.txt (9.1 KB)
Hmm, it seems like there’s something strange with your toolchain. This error:
stan/lib/stan_math/stan/math/prim/eigen_plugins.h:18:25: error: expected type-specifier
using double_return_t = std::conditional_t<std::is_const<std::remove_reference_t<T>>::value,
Happens when a compiler is too old to fully support the c++14 standard, but yours is more than new enough. Is this a computing cluster/server where you have to load a compiler module before compiling code? Is there a chance that step was missed with the cpp_optims code?
Hi Andrew,
I’m embarrassed to say you are probably right, and I might have missed this step earlier :O
Rerunning it with the appropriate loading of the gcc module, I get the following error:
I recently ran into a similar issue on a cluster environment because STAN_CPP_OPTIMS enabled some features my compiler there did not support. In particular the error was caused by the -floop family of flags, the error was something like sorry, unimplemented: Graphite loop optimizations cannot be used.
It may just be the case that the STAN_CPP_OPTIMS flag is not well suited for your exact environment, but you can manually enable the flags it contains one by one and see if they work
Thanks for pointing this out. I think I must be doing something wrong in trying to set the CXXFLAGS myself. I followed this example in two ways:
Within the make command: make STAN_THREADS=TRUE CXXFLAGS+= -fvectorize -ftree-vectorize -fslp-vectorize -ftree-slp-vectorize -fno-standalone-debug -fstrict-return -funroll-loops -flto=full -fstrict-vtable-pointers -fforce-emit-vtables STAN_NO_RANGE_CHECKS=TRUE STANCFLAGS=--O1 /Path/To/File/bernoulli_example
In the make/local file: CXXFLAGS+= -fvectorize -ftree-vectorize -fslp-vectorize -ftree-slp-vectorize -fno-standalone-debug -fstrict-return -funroll-loops -flto=full -fstrict-vtable-pointers -fforce-emit-vtables
However, it seems like none of these optiones are being detected properly:
make: vectorize: No such file or directory
make: tree-vectorize: No such file or directory
make: slp-vectorize: No such file or directory
make: tree-slp-vectorize: No such file or directory
make: no-standalone-debug: No such file or directory
make: strict-return: No such file or directory
make: unroll-loops: No such file or directory
make: lto=full: No such file or directory
make: strict-vtable-pointers: No such file or directory
make: force-emit-vtables: No such file or directory
make: *** No rule to make target `force-emit-vtables'. Stop.
I would appreciate your feedback on what it is that I’m doing wrong.
Thanks!