Skip to contents

Set the number of OpenMP threads used by choicer

Usage

set_num_threads(n_threads)

Arguments

n_threads

Positive integer number of threads.

Value

Invisibly returns NULL.

Details

The setting applies to every choicer kernel run afterwards in the session (it calls omp_set_num_threads()); thread_info() reports it. Each thread of the mixed logit's compiled routines (behind the log-likelihood and its gradient, the Hessian, the BHHH matrix, the robust and clustered meats and the conditional tastes) needs its own working memory, besides what they share. Before allocating it, they compare an upper estimate of the call's total with the machine's total physical memory and, when it would not fit, stop with an error that gives the number of threads that fits; they do not lower the thread count to make it fit. Memory already in use (the data, store-mode draws, other processes) is not counted, nor is the inversion in R of the resulting matrices, so passing the check does not promise that the call fits; where the physical memory cannot be read and the option is unset, there is no check. options(choicer.max_memory = <bytes>) sets the limit instead, for a container or a cluster job with less memory than the machine, and Inf lifts the check.