stan-dev / cmdstanr

CmdStanR: the R interface to CmdStan
https://mc-stan.org/cmdstanr/
Other
143 stars 63 forks source link

Interactive installation #605

Open rok-cesnovar opened 2 years ago

rok-cesnovar commented 2 years ago

As @avehtari suggested, we could ask users a few things during installation to add additional compile flags.

For example:

Also, add an option to skip interaction with yes/no to all.

I am not 100% how that plays with installing cmdstan as part of a script that is not interactive (for example for CI). This is my only worry really. I don't want to break existing scripts obviously.

avehtari commented 2 years ago

I am not 100% how that plays with installing cmdstan as part of a script that is not interactive (for example for CI). This is my only worry really. I don't want to break existing scripts obviously.

We can use interactive() to check, see https://stat.ethz.ch/R-manual/R-devel/library/base/html/interactive.html

avehtari commented 2 years ago

From the discourse thread https://discourse.mc-stan.org/t/speedup-by-using-external-blas-lapack-with-cmdstan-and-cmdstanr-py/25441/29

When interactive()=TRUE we could ask

Optimization:

  1. Safe: Should work with all compilers and CPUs. [Default. Recommended for MINGW on Windows or if 2. doesn't work]
  2. Fast: 0-100% faster computation using CPU specific instruction sets, specially in case of bigger matrix operations, but the compilation may fail for some compiler-OS-CPU combinations. (CXXFLAGS += -march=native) [Recommended if 3. doesn't work]
  3. Faster: 0-100% faster computation using CPU specific instruction sets and CPU specific optimization, specially in case of bigger matrix operations, but the compilation may fail for some compiler-OS-CPU combinations. (CXXFLAGS += -march=native -mtune=native) [Recommended for GCC on Linux]

Threads:

  1. Single thread: If you are not using sum_reduce or …? [Default]
  2. Multithread: If you are using sum_reduce or …? (not needed for external BLAS/LAPACK multithreading]

BLAS/LAPACK:

  1. Eigen internal: No need to install other packages. [Default. Recommended for most users.]
  2. External BLAS/LAPACK: Possibly slightly faster single thread computation than with Eigen, and possibility to use multithreaded matrix operations by using external BLAS/LAPACK such as OpenBLAS or Intel MKL (CXXFLAGS += -DEIGEN_USE_BLAS -DEIGEN_USE_LAPACKE) [Recommended only for advanced users in case of slow computation dominated by big matrix operations]
rok-cesnovar commented 2 years ago

Thanks. Just adding to a line so we dont forget to mention:

Multithread: If you are using reduce_sum or want to always use the single executable multi-chain approach? (when we add this, which should be soon now).

avehtari commented 1 year ago

Bumping this up, as it seems a bit silly that now cmdstan_install() compiles and after that proposes to copy make/local and requiring re-compilation. With interactive option, the installation could ask whether make/local is copied before compilation.