numCoresToUse: Estimate Number of CPU Cores to Use for Parallel Processing

View source: R/downloadTileAndUpload.R

numCoresToUseR Documentation

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)

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).

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()).

Note

This function depends on detectActiveCores() and is not supported on Windows systems.

See Also

detectActiveCores()

Examples

if (FALSE) {
  numCoresToUse()
  numCoresToUse(min = 4)
}


reproducible documentation built on Aug. 26, 2026, 1:07 a.m.