Open wds15 opened 5 years ago
+1
Having something like a config file where a user just changes the value of a flag to use some feature is also much better than saying add XYZW=true to make/local
. That reason alone make this worthwhile to me.
For instance I use OpenCL all the time but keep having to go to a wiki page to see the exact names of certain flags. But that might just be me being forgetful.
exact names of certain flags. But that might just be me being forgetful.
Same tbh
You might be interested in my CMake-ified stan-math build, it is located here: https://github.com/alashworth/stan-monorepo/blob/develop/CMakeLists.txt
I basically handle this use-case by defining separate targets for the four main Stan math use cases: vanilla Stan, Stan + OpenCL, Stan + OpenMPI, Stan + multithreading.
If the user is also using CMake, it is trivial to link against them. Configuration is done automatically via find_package
calls and settings specific CMake options.
This is actually only part of an entire monorepo that merges Stan, Stan Math, and Cmdstan; bits are missing from the public repo because I'm in a long rebase process of moving onto Stan 2.20. However, Stan and Cmdstan should appear within the next week or so, and I will make an announcement on Discourse.
I looked over the readme and the stuff you have going on (and issues you found) in the monorepo and it is absolutely fantastic!
Description
We are having an increasing number of optional features in Stan-math. At the moment these are OpenCL, MPI and threading. Moreover, there are sometimes choices to make at compile time which should be kept optional rather than hard-coded in the code.
Right now we basically configure these compile time things using our makefiles in
make/local
. Unfortunately this is also somewhat inconsistent for the different features. While for MPI we define a makefile variableSTAN_MPI=true
we have simple defines for the others (ok, there is a reason for this which is that MPI needs more bells and whistles to go live as I recall).Example
We should have better ways to control compile time options. Many other projects define config headers. Boost has this and sundials has it as well. Given how Stan-math grows we should probably have a similar facility.
Oftentimes these config.hpp files have defaults which work in many cases, but sometimes these files are generated from tools like cmake or automake which adapt the config file to the available things on the target system.
Expected Output
Better and more flexible way of setting compile time options. We should also rethink how much we want to control by makefiles vs the config.hpp (or whatever we come up with).
Current Version:
v2.20.0