Skip to contents

Sets the "iscream.threads" option to n_threads. To see how many threads you have available see ?get_threads().

Usage

set_threads(n_threads)

Arguments

n_threads

The number of threads to use

Value

NULL. Sets the iscream.threads option to the requested number of threads if available

Details

iscream uses OpenMP to parallelize certain functions. You can use as many threads as are available to you on your system to varying degrees of performance improvements. The get_threads() function uses parallelly::availableCores() to report the number of available threads. Although OpenMP can detect the number of available cores, on high preformance computers (HPCs) with resource allocating job schedulers like SLURM, OpenMP may detect all available threads across the HPC and not limit itself to the cores that were allocated to you by the scheduler. If your system administrator has not set up any limits, this may result in your job taking resources from other jobs. If there are limits, trying to use more threads that those available will reduce iscream's performance. Job schedulers will typically have an environment variable (e.g. SLURM_CPUS_ON_NODE with SLURM) that gives you the actual number of available cores. Further, on hyperthreaded systems, this count may be double that of the available processors. Using hyperthreading does not guarantee any performance improvement - it may be better to set the number of threads to half the reported number. parallelly::availableCores() takes HPC scheduler/CRAN/Bioconductor limits into account when reporting the number of available threads but it may not reliably report hyperthreading ('system' or 'nproc'). To set the number of threads without having to call set_threads() in every session, put

options(iscream.threads = [n_threads])

in your .Rprofile See help('Rprofile') for information on startup options.

Functions currently using OpenMP:

Examples

(ncores <- parallelly::availableCores())
#> system 
#>      4 
if (FALSE) { # \dontrun{
set_threads(ncores)
} # }