Skip to content

Instantly share code, notes, and snippets.

@benfasoli
Last active March 5, 2019 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benfasoli/626f499cccbe7a25a44b897ed07ead9c to your computer and use it in GitHub Desktop.
Save benfasoli/626f499cccbe7a25a44b897ed07ead9c to your computer and use it in GitHub Desktop.
#!/usr/bin/env Rscript
library(parallel)
fun <- function(x) {
x^2
}
cl <- makeForkCluster(nnodes = 2, outfile = '')
out <- parSapply(cl, 1:2, fun)
stopCluster(cl)
str(out)
# num [1:2] 1 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment