You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm curious how the build of Cmdstan with a make/local file and the compiling of a model with supplied compiler args interact with one another
Description:
I'm constantly doing a lot of profiling on models where I'm switching at the CXXFlags/ STAN options when building Cmdstan. Since one can specify those flags in the make/local as well as when building a model via cmdstanpy, I was curious how these things interact. E.g., If I build Cmdstan:
make build
and my make/local has
STAN_OPENCL=True
Does that opencl option when building the model model override what is in make/local? So, if I set to false in cmdstanpy, it will be overridden, but if I do not set it, then it will always be tru?
CmdStanPy does do something special related to opencl, which is if you pass the use-opencl flag to stanc, it will also turn on STAN_OPENCL in the C++ options.
There are two things I'm not sure about -
How command line arguments and make/local compose
What STAN_OPENCL does if the model is not compiled with use-opencl in stanc.
@rok-cesnovar - do you have a better answer for either of those?
What STAN_OPENCL does if the model is not compiled with use-opencl in stanc.
Nothing really as none of the OpenCL-related stuff will be used, so this just adds a bit more code in C++ so a bit longer compile times. You need the use-opencl flag in stanc3 in order to generate the model with the OpenCL-related constructs (matrix_cl class, etc) and setting STAN_OPENCL then enables the OpenCL code in Stan Math so that the generated C++ actually compiles.
To sum up:
no use-opencl stanc3 flag & STAN_OPENCL=False -> normal sequential case
no use-opencl stanc3 flag & STAN_OPENCL=True -> same as sequential code, a bit longer compile times excepted
use-opencl stanc3 flag & STAN_OPENCL= False -> if any OpenCL code was generated in stanc3, the C++ will not compile
use-opencl stanc3 flag & STAN_OPENCL= True -> OpenCL model
are these correct?
They are.
@grburgess if you are ever in doubt about what gets passed to the compiler, I suggest using ˙make print-variable` command. Its precisely used for debugging these kind of stuff.
I set STAN_OPENCL=false in make/local and run:
rok@rok-Z97X-UD5H:~/Desktop/cmdstan$ make print-STAN_OPENCL
STAN_OPENCL = false
rok@rok-Z97X-UD5H:~/Desktop/cmdstan$ make STAN_OPENCL=true print-STAN_OPENCL
STAN_OPENCL = true
Activity
ahartikainen commentedon Jan 20, 2022
Good question. ( I don't have an answer to this)
which one is preferred a cmdline argument or the make/local file.
(Question for anyone needing to debug this, is there a way to print in somewhere while building is going on)
grburgess commentedon Jan 20, 2022
I have noticed that if I turn on OpenCL in the make/local, but say nothing in the cmdline, I get the following output during the build:
I do see the OpenCL stuff popping up.
WardBrian commentedon Jan 20, 2022
CmdStanPy does do something special related to opencl, which is if you pass the
use-openclflag to stanc, it will also turn onSTAN_OPENCLin the C++ options.There are two things I'm not sure about -
use-openclin stanc.@rok-cesnovar - do you have a better answer for either of those?
mitzimorris commentedon Jan 20, 2022
command line arguments to make override make/local argument.
https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_9.html#SEC90
here's what's in the CmdStan docs w/r/t OpenCL - @rok-cesnovar are these correct? https://mc-stan.org/docs/cmdstan-guide/parallelization.html#opencl
rok-cesnovar commentedon Jan 20, 2022
Nothing really as none of the OpenCL-related stuff will be used, so this just adds a bit more code in C++ so a bit longer compile times. You need the use-opencl flag in stanc3 in order to generate the model with the OpenCL-related constructs (matrix_cl class, etc) and setting STAN_OPENCL then enables the OpenCL code in Stan Math so that the generated C++ actually compiles.
To sum up:
They are.
@grburgess if you are ever in doubt about what gets passed to the compiler, I suggest using ˙make print-variable` command. Its precisely used for debugging these kind of stuff.
I set STAN_OPENCL=false in make/local and run:
rok-cesnovar commentedon Jan 20, 2022
And make is its own beast, I never assume I know anything without triple-checking and even then I don't trust it haha
grburgess commentedon Jan 20, 2022
Awesome. I think I understand the workflow now. Thanks!