parallel.threading: Parallel Threading Affinity Optimization

Description Usage Arguments Value Examples

View source: R/parallel.threading.R

Description

Generate a cluster and optimizes the affinity of the provided cluster to perform NUMA-like optimization and avoid as much as possible inter-core communication. Basically, makes core selection sequential in the order of provided clusters. Currently works only on Windows!!!

Usage

1
2
parallel.threading(cl = parallel::detectCores(),
  max_threads = parallel::detectCores(), first_thread = 1)

Arguments

cl

Type: cluster or integer. A parallel cluster. When it is a number, creates a cluster with the specified number of parallel clusters. Defaults to parallel::detectCores().

max_threads

Type: numeric. The maximum number of threads allowed (for all clusters together, not for each cluster). Make sure the result of max_threads cores divided by cl is an integer number, while max_threads is smaller or equal to the number of (logical) cores in your computer. Defaults to parallel::detectCores(), which means use all available (logical) cores.

first_thread

Type: numeric. The first core to use as the first thread to setup affinity. Useless for NUMA environments when using multiple R scripts. Defaults to 1.

Value

The cluster itself.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# Cannot pass CRAN checks. Disabled.
library(parallel)

# Core 1-2, Core 3-4, Core 5-6, Core 7-8
cl <- parallel.threading(cl = 4, max_threads = 8)
stopCluster(cl)

# Core 5-6, Core 7-8
cl <- parallel.threading(cl = 2, max_threads = 4, first_thread = 4)
stopCluster(cl)

## End(Not run)

Laurae2/LauraeDS documentation built on May 29, 2019, 2:25 p.m.