-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ROBUSTNESS: Add unit test asserting that option future.globals.maxSiz…
…e is carried forward in nested parallelization (fix #81)
- Loading branch information
BHGC Website GHA Workflow Runner
committed
Dec 13, 2023
1 parent
f93c19c
commit 8cec43e
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
source("incl/start.R") | ||
|
||
message("*** Options in nested parallelization ...") | ||
|
||
options(future.debug = FALSE) | ||
options(future.apply.debug = FALSE) | ||
options(future.globals.maxSize = 1234000) | ||
|
||
for (cores in 1:availCores) { | ||
message(sprintf("Testing with %d cores ...", cores)) | ||
options(mc.cores = cores) | ||
strategies <- supportedStrategies(cores) | ||
|
||
for (strategy1 in strategies) { | ||
for (strategy2 in strategies) { | ||
message(sprintf("- plan('%s') ...", strategy2)) | ||
plan(list(outer = tweak(strategy1), inner = strategy2)) | ||
|
||
v <- foreach(x = 1:2) %dofuture% { | ||
outer <- data.frame( | ||
label = "outer", | ||
idx = x, | ||
pid = Sys.getpid(), | ||
maxSize = getOption("future.globals.maxSize", NA_real_) | ||
) | ||
|
||
inner <- foreach(x = 3:4) %dofuture% { | ||
data.frame( | ||
label = "inner", | ||
idx = x, | ||
pid = Sys.getpid(), | ||
maxSize = getOption("future.globals.maxSize", NA_real_)) | ||
} | ||
inner <- do.call(rbind, inner) | ||
rbind(outer, inner) | ||
} | ||
v <- do.call(rbind, v) | ||
print(v) | ||
stopifnot(!anyNA(v$maxSize)) | ||
} ## for (strategy2 ...) | ||
} ## for (strategy1 ...) | ||
} ## for (cores in ...) | ||
|
||
message("*** Options in nested parallelization ... done") | ||
|
||
source("incl/end.R") |