Description Usage Arguments Details Value Examples
makeParallel
is a high level function that performs all the steps
to generate parallel code, namely:
1 2 3 | makeParallel(code, graph = inferGraph(code), run = FALSE,
scheduler = schedule, ..., generator = generate, generatorArgs = list(),
file = FALSE, prefix = "gen_", overWrite = FALSE)
|
code |
file name or expression from |
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
|
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 |
character added to front of file name |
overWrite |
logical write over existing generated file |
Infer the task graph
Schedule the statements
Generate parallel code
The arguments allow the user to control every aspect of this process.
For more details see vignette("makeParallel-concepts")
.
code object of class GeneratedCode
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.