trex_get_num_threads: The library's thread budget

View source: R/utils.R

trex_get_num_threadsR Documentation

The library's thread budget

Description

The library is single-threaded by default. Every parallel region of the C++ backend runs on an explicit budget: a selector's random experiments and its inner kernels on trex_control( max_outer_threads, max_inner_threads), a T-solver on tsolver_options(n_threads), and every method without an option of its own (the scalers, the clustering, the ML regressions, the dummy and data generators, trex_normalize_design) on the library's default budget, which starts at 1. trex_get_num_threads() reads that default budget and trex_set_num_threads() sets it for this session; the n_threads argument of those methods overrides it per object. trex_get_max_threads() reports the threads OpenMP can run on this machine (1 in a build without OpenMP), an upper bound for a budget.

Usage

trex_get_num_threads()

trex_get_max_threads()

trex_set_num_threads(n)

Arguments

n

Positive integer, the default thread budget.

Value

trex_get_num_threads(), trex_get_max_threads(): an integer. trex_set_num_threads(): invisibly, the previous budget.

See Also

Other T-Rex selectors and controls: Gauss_data, TRexBiobankScreeningSelector, TRexDASelector, TRexGVSSelector, TRexSPCASelector, TRexScreeningSelector, TRexSelector, TRexTikhonovSelector, trex_biobank_control(), trex_build_group_centering_k(), trex_control(), trex_da_control(), trex_default_lambda2_grid(), trex_dummy_distribution(), trex_fdp(), trex_fdp_dense(), trex_gamma_to_k(), trex_gvs_control(), trex_gvs_lambda2_power_rule(), trex_normalize_design(), trex_precision(), trex_recall(), trex_screen_control(), trex_spca_control(), trex_tikhonov_control(), trex_tikhonov_lambda2_power_rule(), trex_tpp(), trex_tpp_dense()

Examples

trex_get_num_threads()   # 1
old <- trex_set_num_threads(min(2L, trex_get_max_threads()))
trex_get_num_threads()
trex_set_num_threads(old)

TRexSelector documentation built on Nov. 20, 2026, 5:09 p.m.