Set the number of OpenMP threads used by choicer
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 and the profile likelihood's
block of the constants, the BHHH matrix, the score matrix, the robust and
clustered meats and the conditional tastes), of the multinomial and
nested logits' (the log-likelihood and its gradient, the Hessian, the
BHHH matrix, the score matrix and the clustered meat), and of the three
models' elasticities and diversion ratios (whose threads keep their own
copies of the J x J sums while those fit in 2 GiB, and share one sum
beyond) 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. The share inversion (blp() and the expert functions)
keeps exponentials of the utilities across its iterations only within
half of that limit, less the memory the call already holds (the mixed
logit's for as many choice situations as fit), and evaluates the shares
it does not cover without them; where there is no limit (Inf, or a
physical memory that cannot be read), only the mixed logit's
keep_draws_bytes bounds them.
See also
thread_info(); run_mxlogit(), whose draws = "generate"
holds no draw cube in memory.