tests/makeClusterMPI.R

source("incl/start.R")

library(parallel)

message("*** makeClusterMPI() ...")

pkg <- "Rmpi"
if (fullTest && requireNamespace(pkg, quietly = TRUE)) {
  cl <- makeClusterMPI(2L)
  str(cl)
  
  res <- parLapply(cl, X = 1:2, fun = function(x) {
    list(
      hostname = Sys.info()[["nodename"]],
      pid      = Sys.getpid(),
      value    = x^2
    )
  })
  utils::str(res)
  y <- vapply(res, FUN = `[[`, "value", FUN.VALUE = NA_real_)
  stopifnot(identical(y, c(1, 4)))

  stopCluster(cl)
  str(cl)
}

message("*** makeClusterMPI() ... DONE")

source("incl/end.R")

Try the parallelly package in your browser

Any scripts or data that you put into this service are public.

parallelly documentation built on Sept. 11, 2024, 7:56 p.m.