From e98c7ef2c3d673cdcd1017a9960a84b2cfd60001 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 21 Aug 2024 09:37:33 +0200 Subject: [PATCH 1/2] Clarify meaning of "set flag" in cmdstan-guide State explicitly that setting `STAN_THREADS`, `STAN_MPI`, and `STAN_OPENCL` to any value, including falsy values, turns the corresponding feature on. Fix https://github.com/stan-dev/cmdstan/issues/1293 --- src/cmdstan-guide/parallelization.qmd | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cmdstan-guide/parallelization.qmd b/src/cmdstan-guide/parallelization.qmd index 7653d0d03..7e7954c96 100644 --- a/src/cmdstan-guide/parallelization.qmd +++ b/src/cmdstan-guide/parallelization.qmd @@ -21,7 +21,9 @@ on how to rewrite Stan models to use these functions see [Stan's User guide chap Once a model is rewritten to use the above-mentioned functions, the model must be compiled with the `STAN_THREADS` makefile flag. The flag can be supplied in the `make` call but we recommend writing the flag to the -`make/local` file. +`make/local` file. If the `STAN_THREADS` flag is set to any non-empty value, +threads will be enabled. + An example of the contents of `make/local` to enable threading with TBB: @@ -77,7 +79,7 @@ implementations are [MPICH](https://www.mpich.org/) and [OpenMPI](https://www.op Once a model is rewritten to use `map_rect`, additional makefile flags must be written to the `make/local`. These are: -- `STAN_MPI`: Enables the use of MPI with Stan if `true`. +- `STAN_MPI`: Enables the use of MPI with Stan if set. - `CXX`: The name of the MPI C++ compiler wrapper. Typically `mpicxx`. - `TBB_CXX_TYPE`: The C++ compiler the MPI wrapper wraps. Typically `gcc` on Linux and `clang` on macOS. @@ -158,8 +160,8 @@ Follow Intel's install instructions given [here](https://software.intel.com/cont ### Compiling In order to enable the OpenCL backend the model -must be compiled with the `STAN_OPENCL` makefile flag. The flag can be -supplied in the `make` call but we recommend writing the flag to the +must be compiled with the `STAN_OPENCL` makefile flag set (to any non-empty value). +The flag can be supplied in the `make` call but we recommend writing the flag to the `make/local` file. An example of the contents of `make/local` to enable parallelization @@ -169,7 +171,7 @@ with OpenCL: STAN_OPENCL=true ``` -If you are using OpenCL with an integrated GPU you also need to add the `INTEGRATED_OPENCL` flag, as the sharing of memory between CPU and GPU is slightly different with integrated graphics: +If you are using OpenCL with an integrated GPU you also need to set the `INTEGRATED_OPENCL` flag, as the sharing of memory between CPU and GPU is slightly different with integrated graphics: ``` INTEGRATED_OPENCL=true From c120bdb7c16fb6e6e8b8a4213c0bba4326b1e6b5 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 21 Aug 2024 16:05:17 +0200 Subject: [PATCH 2/2] cpp flags set -> defined --- src/cmdstan-guide/parallelization.qmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmdstan-guide/parallelization.qmd b/src/cmdstan-guide/parallelization.qmd index 7e7954c96..637577270 100644 --- a/src/cmdstan-guide/parallelization.qmd +++ b/src/cmdstan-guide/parallelization.qmd @@ -21,7 +21,7 @@ on how to rewrite Stan models to use these functions see [Stan's User guide chap Once a model is rewritten to use the above-mentioned functions, the model must be compiled with the `STAN_THREADS` makefile flag. The flag can be supplied in the `make` call but we recommend writing the flag to the -`make/local` file. If the `STAN_THREADS` flag is set to any non-empty value, +`make/local` file. If the `STAN_THREADS` flag is defined/non-empty, threads will be enabled. @@ -79,7 +79,7 @@ implementations are [MPICH](https://www.mpich.org/) and [OpenMPI](https://www.op Once a model is rewritten to use `map_rect`, additional makefile flags must be written to the `make/local`. These are: -- `STAN_MPI`: Enables the use of MPI with Stan if set. +- `STAN_MPI`: Enables the use of MPI with Stan if defined. - `CXX`: The name of the MPI C++ compiler wrapper. Typically `mpicxx`. - `TBB_CXX_TYPE`: The C++ compiler the MPI wrapper wraps. Typically `gcc` on Linux and `clang` on macOS. @@ -160,7 +160,7 @@ Follow Intel's install instructions given [here](https://software.intel.com/cont ### Compiling In order to enable the OpenCL backend the model -must be compiled with the `STAN_OPENCL` makefile flag set (to any non-empty value). +must be compiled with the `STAN_OPENCL` makefile flag defined/non-empty. The flag can be supplied in the `make` call but we recommend writing the flag to the `make/local` file. @@ -171,7 +171,7 @@ with OpenCL: STAN_OPENCL=true ``` -If you are using OpenCL with an integrated GPU you also need to set the `INTEGRATED_OPENCL` flag, as the sharing of memory between CPU and GPU is slightly different with integrated graphics: +If you are using OpenCL with an integrated GPU you also need to define the `INTEGRATED_OPENCL` flag, as the sharing of memory between CPU and GPU is slightly different with integrated graphics: ``` INTEGRATED_OPENCL=true