numCoresToUse: Estimate Number of CPU Cores to Use for Parallel Processing
Description
This function estimates the number of CPU cores that can be safely used for
parallel processing, taking into account a minimum threshold, the total
number of physical cores, and currently active threads.
Usage
numCoresToUse(min = 2, max = NULL)
Value
An integer representing the number of cores that can be used for
parallel tasks, ensuring at least min cores are used, while subtracting
one for the current process and an estimate of actively used threads (via
detectActiveCores()).
Arguments
min
An integer specifying the minimum number of cores to use. Default is 2.
max
An integer specifying the maximum number of cores available,
typically the number of physical cores. Default is
max(1L, getOption("Ncpus", 1L), parallel::detectCores() - 1, logical = FALSE, na.rm = TRUE).