makeParallel: Make Parallel Code From Serial

Description Usage Arguments Details Value Examples

Description

makeParallel is a high level function that performs all the steps to generate parallel code, namely:

Usage

1
2
3
makeParallel(code, graph = inferGraph(code), run = FALSE,
  scheduler = schedule, ..., generator = generate, generatorArgs = list(),
  file = FALSE, prefix = "gen_", overWrite = FALSE)

Arguments

code

file name or expression from parse

graph

object of class DependGraph

run

logical, evaluate the code once to gather timings?

scheduler,

function to produce a Schedule from a DependGraph.

...,

additional arguments to scheduler

generator

function to produce GeneratedCode from a Schedule

generatorArgs

list of named arguments to use with generator

file

character name of the file to write the generated script. If FALSE then don't write anything to disk. If TRUE and code comes from a file then use prefix to make a new name and write a script.

prefix

character added to front of file name

overWrite

logical write over existing generated file

Details

  1. Infer the task graph

  2. Schedule the statements

  3. Generate parallel code

The arguments allow the user to control every aspect of this process. For more details see vignette("makeParallel-concepts").

Value

code object of class GeneratedCode

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Make an existing R script parallel
script <- system.file("examples/mp_example.R", package = "makeParallel")
makeParallel(script)

# Write generated code to a new file
newfile <- tempfile()
makeParallel(script, file = newfile)

# Clean up
unlink(newfile)

# Pass in code directly
d <- makeParallel(parse(text = "lapply(mtcars, mean)"))

# Now we can examine generated code
writeCode(d)

# Specify a different scheduler
pcode <- makeParallel(parse(text = "x <- 1:100
y <- rep(1, 100)
z <- x + y"), scheduler = scheduleTaskList)

# Some schedules have plotting methods
plot(schedule(pcode))

makeParallel documentation built on May 2, 2019, 9:40 a.m.