File: options%2Cnested.R

package info (click to toggle)
r-cran-future.apply 1.11.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 444 kB
  • sloc: sh: 13; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,347 bytes parent folder | download
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
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 <- future_lapply(1:2, FUN = function(x) {
        outer <- data.frame(
          label   = "outer",
          idx     = x,
          pid     = Sys.getpid(),
          maxSize = getOption("future.globals.maxSize", NA_real_)
        )
        
        inner <- future_lapply(3:4, FUN = function(x) {
          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")