Hi all,
I wonder if there is a documentation somewhere about how to turn on/off complier flags in cmdstanpy?
At the stage, I want to explore if change turning on/off CXXFLGAS += -march=native -mtune=native
or using external BLAS/LAPACK would speed up my GP fitting (https://discourse.mc-stan.org/t/speedup-by-using-external-blas-lapack-with-cmdstan-and-cmdstanr-py/25441
Thanks!
Andy
Looks like our cmdstanpy devs are all away from the forums, so I can help. Sorry it took so long for such a simple question.
The API doc for CmdStanModel
explains how to configure compiler flags in C++:
https://mc-stan.org/cmdstanpy/api.html#cmdstanmodel
Hi Bob,
Many thanks.
I would like to clarify a few things:
-
How can I translate “CXXFLAGS+= -O3 -march=native -mtune=native” into the python dict cpp_options ?
a. Do I need to include “-” as part of the key?
b. For “O3”, there is not “=” sign. Should I treat the “O3” as key or “O” as key and “3” as value?
-
In the linked thread, there was discussion about setting “STAN_CPP_OPTIMS=TRUE” . Is this still required/recommended? If so, how can I set this flag in cmdstanpy (Under stand_options or cpp_options)?
Thanks,
Andy
The way CmdStanPy treats the cpp_options
dictionary is by pasting together the key and value with =
and then adding it to the make
invocation. It doesn’t try to be particularly smart
So if I wanted the effect of make examples/bernoulli/bernoulli FOO="-bar -baz"
I would create the dictionary as {"FOO": "-bar -baz"}
.
For the other things you mentioned, they could be written as {"CXXFLAGS_PROGRAM": "-march=native"}
or {"STAN_CPP_OPTIMS": "TRUE"}
(I left out mtune
since it is implied by march, and O=3
is the default. For why I used CXXFLAGS_PROGRAM vs CXXFLAGS, the make behavior is a bit odd with the former, see this issue)