Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ get_num_threads()

int stan::math::internal::get_num_threads ( )
inline

Get number of threads to use.

The function uses the environment variable STAN_NUM_THREADS and follows these conventions:

  • STAN_NUM_THREADS is not defined => num_threads=1
  • STAN_NUM_THREADS is positive => num_threads is set to the specified number
  • STAN_NUM_THREADS is set to -1 => num_threads is the number of available cores on the machine
  • STAN_NUM_THREADS < -1, STAN_NUM_THREADS = 0 or STAN_NUM_THREADS is not numeric => throws an exception
Returns
number of threads to use
Exceptions
std::invalid_argumentif the value of STAN_NUM_THREADS env. variable is invalid

Definition at line 46 of file init_threadpool_tbb.hpp.