Learn R Programming

ParallelLogger (version 3.4.1)

makeCluster: Create a cluster of nodes for parallel computation

Description

Create a cluster of nodes for parallel computation

Usage

makeCluster(
  numberOfThreads,
  singleThreadToMain = TRUE,
  setAndromedaTempFolder = TRUE,
  setAndromedaMemoryLimit = TRUE
)

Value

An object representing the cluster.

Arguments

numberOfThreads

Number of parallel threads.

singleThreadToMain

If numberOfThreads is 1, should we fall back to running the process in the main thread?

setAndromedaTempFolder

When TRUE, the andromedaTempFolder option will be copied to each thread.

setAndromedaMemoryLimit

When TRUE, the andromedaMemoryLimit option will be set in each thread to be either the global andromedaMemoryLimit / numberOfThreads or 75 percent of the system memory / number of threads.

Examples

Run this code
fun <- function(x) {
  return (x^2)
}

cluster <- makeCluster(numberOfThreads = 3)
clusterApply(cluster, 1:10, fun)
stopCluster(cluster)

Run the code above in your browser using DataLab