/usr/lib/R/site-library/BiocParallel/unitTests/test_SnowParam.R is in r-bioc-biocparallel 1.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | test_SnowParam_construction <- function()
{
checkException(SnowParam(logdir = tempdir()))
p <- MulticoreParam(jobname = 'test')
checkIdentical(bpjobname(p), 'test')
}
test_SnowParam_SOCK <- function()
{
if (!suppressWarnings(require(snow)))
## quietly succeed if 'snow' not available
return()
param <- SnowParam(2, "SOCK", tasks=2)
checkIdentical(FALSE, bpisup(param))
exp <- bplapply(1:2, function(i) Sys.getpid(), BPPARAM=param)
checkIdentical(2L, length(unique(unlist(exp))))
checkIdentical(FALSE, bpisup(param))
}
test_SnowParam_MPI <- function()
{
if (.Platform$OS.type == "windows")
return()
param <- SnowParam(2, "MPI", tasks=2)
checkIdentical(FALSE, bpisup(param))
exp <- bplapply(1:2, function(i) mpi.comm.rank(), BPPARAM=param)
checkIdentical(c(1L, 2L), sort(unlist(exp)))
checkIdentical(FALSE, bpisup(param))
}
test_SnowParam_coerce_from_SOCK <- function()
{
if (!suppressWarnings(require(snow)))
## quietly succeed if 'snow' not available
return(TRUE)
cl <- parallel::makeCluster(2L, "SOCK")
p <- as(cl, "SnowParam")
checkTrue(validObject(p))
obs <- tryCatch(bpstart(p), error=conditionMessage)
exp <- "'bpstart' not available; instance from outside BiocParallel?"
checkIdentical(exp, obs)
obs <- tryCatch(bpstop(p), error=conditionMessage)
exp <- "'bpstop' not available; instance from outside BiocParallel?"
checkIdentical(exp, obs)
exp <- bplapply(1:2, function(i) Sys.getpid(), BPPARAM=p)
checkIdentical(2L, length(unique(unlist(exp))))
checkIdentical(TRUE, bpisup(p))
parallel::stopCluster(cl)
}
test_SnowParam_coerce_from_MPI <- function()
{
if (.Platform$OS.type == "windows")
return()
if (!(suppressWarnings(require(snow)) ||
suppressWarnings(require(Rmpi))))
## quietly succeed if 'snow', 'Rmpi' not available
return()
cl <- parallel::makeCluster(2L, "MPI")
p <- as(cl, "SnowParam")
checkTrue(validObject(p))
obs <- tryCatch(bpstart(p), error=conditionMessage)
exp <- "'bpstart' not available; instance from outside BiocParallel?"
checkIdentical(exp, obs)
obs <- tryCatch(bpstop(p), error=conditionMessage)
exp <- "'bpstop' not available; instance from outside BiocParallel?"
checkIdentical(exp, obs)
exp <- bplapply(1:2, function(i) mpi.comm.rank(), BPPARAM=p)
checkIdentical(c(1L, 2L), sort(unlist(exp)))
checkIdentical(TRUE, bpisup(p))
parallel::stopCluster(cl)
}
test_SnowParam_workers <- function()
{
if (.Platform$OS.type == "windows")
return()
if (!(suppressWarnings(require(snow)) ||
suppressWarnings(require(Rmpi))))
## quietly succeed if 'snow', 'Rmpi' not available
return()
checkException(SnowParam("host", "MPI"), silent=TRUE)
checkException(SnowParam("host", "FORK"), silent=TRUE)
}
|