Describe the bug
If threading is enabled globally by way of STAN_THREADS=true in make/local (as opposed to locally via cpp_options = list(stan_threads = TRUE) in a call to model$compile()), cmdstanr does not respect the setting. Although model$cpp_options is TRUE for the key STAN_THREADS, assert_valid_threads() only checks for stan_threads in lowercase.
Although threading is perhaps the most common use case, the same bug would apply to STAN_OPENCL and any other C++ option. To fix the bug, CmdStanModel needs to standardise on all-caps or lowercase for its internal cpp_options representation. It seems to me that lowercase would be the most consistent (and thus model_compile_info() should use tolower() instead of toupper() here), but in case this has further-reaching consequences than I can see, I’m making an issue instead of a pull request.
To Reproduce
Set STAN_THREADS=true in make/local, compile a model, and then try to run model$sample() with threads_per_chain set to some integer greater than 1.
Expected behavior
The model should sample using multi-threading instead of complaining (erroneously) that the model has not been compiled with threading enabled.
Operating system
Although this should be platform-agnostic, I am running macOS 13.3.1 on an Apple M1 architecture.
CmdStanR version number
2.32.1
Additional context
None
Describe the bug
If threading is enabled globally by way of
STAN_THREADS=trueinmake/local(as opposed to locally viacpp_options = list(stan_threads = TRUE)in a call tomodel$compile()),cmdstanrdoes not respect the setting. Althoughmodel$cpp_optionsisTRUEfor the keySTAN_THREADS,assert_valid_threads()only checks forstan_threadsin lowercase.Although threading is perhaps the most common use case, the same bug would apply to
STAN_OPENCLand any other C++ option. To fix the bug,CmdStanModelneeds to standardise on all-caps or lowercase for its internalcpp_optionsrepresentation. It seems to me that lowercase would be the most consistent (and thusmodel_compile_info()should usetolower()instead oftoupper()here), but in case this has further-reaching consequences than I can see, I’m making an issue instead of a pull request.To Reproduce
Set
STAN_THREADS=trueinmake/local, compile a model, and then try to runmodel$sample()withthreads_per_chainset to some integer greater than 1.Expected behavior
The model should sample using multi-threading instead of complaining (erroneously) that the model has not been compiled with threading enabled.
Operating system
Although this should be platform-agnostic, I am running macOS 13.3.1 on an Apple M1 architecture.
CmdStanR version number
2.32.1
Additional context
None