Debian Codegraph @

inst/testme/test-makeClusterMPI.R

raw
1 library(parallelly)
2 library(parallel)
3
4 message("*** makeClusterMPI() ...")
5
6 pkg <- "Rmpi"
7 if (fullTest && requireNamespace(pkg, quietly = TRUE)) {
8 cl <- makeClusterMPI(2L)
9 str(cl)
10
11 res <- parLapply(cl, X = 1:2, fun = function(x) {
12 list(
13 hostname = Sys.info()[["nodename"]],
14 pid = Sys.getpid(),
15 value = x^2
16 )
17 })
18 utils::str(res)
19 y <- vapply(res, FUN = `[[`, "value", FUN.VALUE = NA_real_)
20 stopifnot(identical(y, c(1, 4)))
21
22 stopCluster(cl)
23 str(cl)
24 }
25
26 message("*** makeClusterMPI() ... DONE")