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

◆ init_threadpool_tbb()

tbb::task_arena & stan::math::init_threadpool_tbb ( int  n_threads = 0)
inline

Initialize the Intel TBB threadpool and global scheduler through the tbb::task_arena object.

In case an instance of the tbb::task_scheduler_object has been instantiated prior to calling this function, then any subsequent initialization is ignored by the Intel TBB.

The maximal number of threads is read from the environment variable STAN_NUM_THREADS using internal::get_num_threads. See conventions of get_num_threads. The TBB scheduler will be activated by calling this function.

The function returns a reference to the static tbb::global_control instance.

Parameters
n_threadsThe maximum number of threads available to the tbb. If not set will search for the environment variable STAN_NUM_THREADS. A value of -1 will assume all detectable threads are available for the process.
Returns
reference to the static tbb::global_control
Exceptions
std::runtime_errorif n_threads (defaults to zero) is not provided and the value of STAN_NUM_THREADS environment variable is invalid.

Definition at line 100 of file init_threadpool_tbb.hpp.