R Under development (unstable) (2023-12-19 r85710 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > source("incl/start.R") Loading required package: foreach Loading required package: future R Under development (unstable) (2023-12-19 r85710 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows Server 2022 x64 (build 20348) Matrix products: default locale: [1] LC_COLLATE=C LC_CTYPE=German_Germany.utf8 [3] LC_MONETARY=C LC_NUMERIC=C [5] LC_TIME=C time zone: Europe/Berlin tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] doFuture_1.0.1 future_1.33.0 foreach_1.5.2 loaded via a namespace (and not attached): [1] compiler_4.4.0 parallelly_1.36.0 tools_4.4.0 [4] parallel_4.4.0 future.apply_1.11.0 listenv_0.9.0 [7] codetools_0.2-19 iterators_1.0.14 digest_0.6.33 [10] globals_0.16.2 > > strategies <- future:::supportedStrategies() > > if (require("doRNG")) { + truth <- NULL + + my_fcn_dopar <- function() { + y <- foreach(i = 1:10) %dopar% { + sample.int(n = 100L, size = 1L) + } + mean(unlist(y)) + } + + my_fcn_dorng <- function() { + y <- foreach(i = 1:10) %dorng% { + sample.int(n = 100L, size = 1L) + } + mean(unlist(y)) + } + + registerDoFuture() + + message("*** withDoRNG() ...") + print(sessionInfo()) + + for (strategy in strategies) { + message(sprintf("- plan('%s') ...", strategy)) + plan(strategy) + + if (is.null(truth)) { + set.seed(1234) + truth <- my_fcn_dorng() + } + + set.seed(1234) + res <- withDoRNG(my_fcn_dopar()) + print(res) + stopifnot(identical(res, truth)) + + # Shutdown current plan + plan(sequential) + + message(sprintf("- plan('%s') ... DONE", strategy)) + } ## for (strategy ...) + + message("*** withDoRNG() ... DONE") + + } ## if (require("doRNG")) Loading required package: doRNG Loading required package: rngtools *** withDoRNG() ... R Under development (unstable) (2023-12-19 r85710 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows Server 2022 x64 (build 20348) Matrix products: default locale: [1] LC_COLLATE=C LC_CTYPE=German_Germany.utf8 [3] LC_MONETARY=C LC_NUMERIC=C [5] LC_TIME=C time zone: Europe/Berlin tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] doRNG_1.8.6 rngtools_1.5.2 doFuture_1.0.1 future_1.33.0 foreach_1.5.2 loaded via a namespace (and not attached): [1] compiler_4.4.0 parallelly_1.36.0 tools_4.4.0 [4] parallel_4.4.0 future.apply_1.11.0 listenv_0.9.0 [7] codetools_0.2-19 iterators_1.0.14 digest_0.6.33 [10] globals_0.16.2 - plan('sequential') ... [08:12:45.223] doFuture() ... [08:12:45.225] - dummy globals (as locals): [2] 'i', '.doRNG.stream' [08:12:45.226] - R expression: [08:12:45.226] { [08:12:45.226] doFuture::registerDoFuture() [08:12:45.226] lapply(seq_along(...future.x_ii), FUN = function(jj) { [08:12:45.226] ...future.x_jj <- ...future.x_ii[[jj]] [08:12:45.226] { [08:12:45.226] { [08:12:45.226] NULL [08:12:45.226] i <- NULL [08:12:45.226] } [08:12:45.226] .doRNG.stream <- NULL [08:12:45.226] } [08:12:45.226] ...future.env <- environment() [08:12:45.226] local({ [08:12:45.226] for (name in names(...future.x_jj)) { [08:12:45.226] assign(name, ...future.x_jj[[name]], envir = ...future.env, [08:12:45.226] inherits = FALSE) [08:12:45.226] } [08:12:45.226] }) [08:12:45.226] tryCatch({ [08:12:45.226] { [08:12:45.226] rngtools::RNGseed(.doRNG.stream) [08:12:45.226] } [08:12:45.226] { [08:12:45.226] sample.int(n = 100L, size = 1L) [08:12:45.226] } [08:12:45.226] }, error = identity) [08:12:45.226] }) [08:12:45.226] } [08:12:45.227] - identifying globals and packages ... [08:12:45.248] List of 1 [08:12:45.248] $ ...future.x_ii: NULL [08:12:45.248] - attr(*, "where")=List of 1 [08:12:45.248] ..$ ...future.x_ii: [08:12:45.248] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [08:12:45.248] - attr(*, "resolved")= logi FALSE [08:12:45.248] - attr(*, "total_size")= num 0 [08:12:45.261] - R expression: [08:12:45.262] { [08:12:45.262] doFuture::registerDoFuture() [08:12:45.262] lapply(seq_along(...future.x_ii), FUN = function(jj) { [08:12:45.262] ...future.x_jj <- ...future.x_ii[[jj]] [08:12:45.262] { [08:12:45.262] { [08:12:45.262] NULL [08:12:45.262] i <- NULL [08:12:45.262] } [08:12:45.262] .doRNG.stream <- NULL [08:12:45.262] } [08:12:45.262] ...future.env <- environment() [08:12:45.262] local({ [08:12:45.262] for (name in names(...future.x_jj)) { [08:12:45.262] assign(name, ...future.x_jj[[name]], envir = ...future.env, [08:12:45.262] inherits = FALSE) [08:12:45.262] } [08:12:45.262] }) [08:12:45.262] tryCatch({ [08:12:45.262] { [08:12:45.262] rngtools::RNGseed(.doRNG.stream) [08:12:45.262] } [08:12:45.262] { [08:12:45.262] sample.int(n = 100L, size = 1L) [08:12:45.262] } [08:12:45.262] }, error = identity) [08:12:45.262] }) [08:12:45.262] } [08:12:45.262] - globals: [1] '...future.x_ii' [08:12:45.263] List of 1 [08:12:45.263] $ ...future.x_ii: NULL [08:12:45.263] - attr(*, "where")=List of 1 [08:12:45.263] ..$ ...future.x_ii: [08:12:45.263] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [08:12:45.263] - attr(*, "resolved")= logi FALSE [08:12:45.263] - attr(*, "total_size")= num 0 [08:12:45.266] - packages: [2] 'doFuture', 'doRNG' [08:12:45.266] - identifying globals and packages ... DONE [08:12:45.267] Number of chunks: 1 [08:12:45.267] Number of futures (= number of chunks): 1 [08:12:45.267] Launching 1 futures (chunks) ... [08:12:45.268] Chunk #1 of 1 ... [08:12:45.268] - Finding globals in 'args_list' chunk #1 ... [08:12:45.269] [08:12:45.270] [08:12:45.270] - Finding globals in 'args_list' for chunk #1 ... DONE [08:12:45.286] Chunk #1 of 1 ... DONE [08:12:45.286] Launching 1 futures (chunks) ... DONE [08:12:45.287] - resolving futures [08:12:45.287] - gathering results & relaying conditions (except errors) [08:12:45.289] - collecting values of futures [08:12:45.289] - accumulating results [08:12:45.291] - processing errors (handler = 'stop') [08:12:45.291] - extracting results [08:12:45.291] doFuture() ... DONE [08:12:45.298] doFuture() ... [08:12:45.300] - dummy globals (as locals): [2] 'i', '.doRNG.stream' [08:12:45.300] - R expression: [08:12:45.300] { [08:12:45.300] doFuture::registerDoFuture() [08:12:45.300] lapply(seq_along(...future.x_ii), FUN = function(jj) { [08:12:45.300] ...future.x_jj <- ...future.x_ii[[jj]] [08:12:45.300] { [08:12:45.300] { [08:12:45.300] NULL [08:12:45.300] i <- NULL [08:12:45.300] } [08:12:45.300] .doRNG.stream <- NULL [08:12:45.300] } [08:12:45.300] ...future.env <- environment() [08:12:45.300] local({ [08:12:45.300] for (name in names(...future.x_jj)) { [08:12:45.300] assign(name, ...future.x_jj[[name]], envir = ...future.env, [08:12:45.300] inherits = FALSE) [08:12:45.300] } [08:12:45.300] }) [08:12:45.300] tryCatch({ [08:12:45.300] { [08:12:45.300] rngtools::RNGseed(.doRNG.stream) [08:12:45.300] } [08:12:45.300] { [08:12:45.300] sample.int(n = 100L, size = 1L) [08:12:45.300] } [08:12:45.300] }, error = identity) [08:12:45.300] }) [08:12:45.300] } [08:12:45.301] - identifying globals and packages ... [08:12:45.314] List of 1 [08:12:45.314] $ ...future.x_ii: NULL [08:12:45.314] - attr(*, "where")=List of 1 [08:12:45.314] ..$ ...future.x_ii: [08:12:45.314] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [08:12:45.314] - attr(*, "resolved")= logi FALSE [08:12:45.314] - attr(*, "total_size")= num 0 [08:12:45.317] - R expression: [08:12:45.318] { [08:12:45.318] doFuture::registerDoFuture() [08:12:45.318] lapply(seq_along(...future.x_ii), FUN = function(jj) { [08:12:45.318] ...future.x_jj <- ...future.x_ii[[jj]] [08:12:45.318] { [08:12:45.318] { [08:12:45.318] NULL [08:12:45.318] i <- NULL [08:12:45.318] } [08:12:45.318] .doRNG.stream <- NULL [08:12:45.318] } [08:12:45.318] ...future.env <- environment() [08:12:45.318] local({ [08:12:45.318] for (name in names(...future.x_jj)) { [08:12:45.318] assign(name, ...future.x_jj[[name]], envir = ...future.env, [08:12:45.318] inherits = FALSE) [08:12:45.318] } [08:12:45.318] }) [08:12:45.318] tryCatch({ [08:12:45.318] { [08:12:45.318] rngtools::RNGseed(.doRNG.stream) [08:12:45.318] } [08:12:45.318] { [08:12:45.318] sample.int(n = 100L, size = 1L) [08:12:45.318] } [08:12:45.318] }, error = identity) [08:12:45.318] }) [08:12:45.318] } [08:12:45.318] - globals: [1] '...future.x_ii' [08:12:45.319] List of 1 [08:12:45.319] $ ...future.x_ii: NULL [08:12:45.319] - attr(*, "where")=List of 1 [08:12:45.319] ..$ ...future.x_ii: [08:12:45.319] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [08:12:45.319] - attr(*, "resolved")= logi FALSE [08:12:45.319] - attr(*, "total_size")= num 0 [08:12:45.322] - packages: [2] 'doFuture', 'doRNG' [08:12:45.322] - identifying globals and packages ... DONE [08:12:45.322] Number of chunks: 1 [08:12:45.323] Number of futures (= number of chunks): 1 [08:12:45.323] Launching 1 futures (chunks) ... [08:12:45.323] Chunk #1 of 1 ... [08:12:45.323] - Finding globals in 'args_list' chunk #1 ... [08:12:45.324] [08:12:45.325] [08:12:45.325] - Finding globals in 'args_list' for chunk #1 ... DONE [08:12:45.331] Chunk #1 of 1 ... DONE [08:12:45.331] Launching 1 futures (chunks) ... DONE [08:12:45.331] - resolving futures [08:12:45.332] - gathering results & relaying conditions (except errors) [08:12:45.332] - collecting values of futures [08:12:45.333] - accumulating results [08:12:45.334] - processing errors (handler = 'stop') [08:12:45.334] - extracting results [08:12:45.335] doFuture() ... DONE [1] 59.5 - plan('sequential') ... DONE - plan('multisession') ... [08:12:46.332] doFuture() ... [08:12:46.334] - dummy globals (as locals): [2] 'i', '.doRNG.stream' [08:12:46.335] - R expression: [08:12:46.335] { [08:12:46.335] doFuture::registerDoFuture() [08:12:46.335] lapply(seq_along(...future.x_ii), FUN = function(jj) { [08:12:46.335] ...future.x_jj <- ...future.x_ii[[jj]] [08:12:46.335] { [08:12:46.335] { [08:12:46.335] NULL [08:12:46.335] i <- NULL [08:12:46.335] } [08:12:46.335] .doRNG.stream <- NULL [08:12:46.335] } [08:12:46.335] ...future.env <- environment() [08:12:46.335] local({ [08:12:46.335] for (name in names(...future.x_jj)) { [08:12:46.335] assign(name, ...future.x_jj[[name]], envir = ...future.env, [08:12:46.335] inherits = FALSE) [08:12:46.335] } [08:12:46.335] }) [08:12:46.335] tryCatch({ [08:12:46.335] { [08:12:46.335] rngtools::RNGseed(.doRNG.stream) [08:12:46.335] } [08:12:46.335] { [08:12:46.335] sample.int(n = 100L, size = 1L) [08:12:46.335] } [08:12:46.335] }, error = identity) [08:12:46.335] }) [08:12:46.335] } [08:12:46.336] - identifying globals and packages ... [08:12:46.350] List of 1 [08:12:46.350] $ ...future.x_ii: NULL [08:12:46.350] - attr(*, "where")=List of 1 [08:12:46.350] ..$ ...future.x_ii: [08:12:46.350] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [08:12:46.350] - attr(*, "resolved")= logi FALSE [08:12:46.350] - attr(*, "total_size")= num 0 [08:12:46.354] - R expression: [08:12:46.354] { [08:12:46.354] doFuture::registerDoFuture() [08:12:46.354] lapply(seq_along(...future.x_ii), FUN = function(jj) { [08:12:46.354] ...future.x_jj <- ...future.x_ii[[jj]] [08:12:46.354] { [08:12:46.354] { [08:12:46.354] NULL [08:12:46.354] i <- NULL [08:12:46.354] } [08:12:46.354] .doRNG.stream <- NULL [08:12:46.354] } [08:12:46.354] ...future.env <- environment() [08:12:46.354] local({ [08:12:46.354] for (name in names(...future.x_jj)) { [08:12:46.354] assign(name, ...future.x_jj[[name]], envir = ...future.env, [08:12:46.354] inherits = FALSE) [08:12:46.354] } [08:12:46.354] }) [08:12:46.354] tryCatch({ [08:12:46.354] { [08:12:46.354] rngtools::RNGseed(.doRNG.stream) [08:12:46.354] } [08:12:46.354] { [08:12:46.354] sample.int(n = 100L, size = 1L) [08:12:46.354] } [08:12:46.354] }, error = identity) [08:12:46.354] }) [08:12:46.354] } [08:12:46.355] - globals: [1] '...future.x_ii' [08:12:46.355] List of 1 [08:12:46.355] $ ...future.x_ii: NULL [08:12:46.355] - attr(*, "where")=List of 1 [08:12:46.355] ..$ ...future.x_ii: [08:12:46.355] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [08:12:46.355] - attr(*, "resolved")= logi FALSE [08:12:46.355] - attr(*, "total_size")= num 0 [08:12:46.359] - packages: [2] 'doFuture', 'doRNG' [08:12:46.359] - identifying globals and packages ... DONE [08:12:46.366] Number of chunks: 2 [08:12:46.366] Number of futures (= number of chunks): 2 [08:12:46.366] Launching 2 futures (chunks) ... [08:12:46.366] Chunk #1 of 2 ... [08:12:46.367] - Finding globals in 'args_list' chunk #1 ... [08:12:46.368] [08:12:46.368] [08:12:46.368] - Finding globals in 'args_list' for chunk #1 ... DONE [08:12:46.391] Chunk #1 of 2 ... DONE [08:12:46.392] Chunk #2 of 2 ... [08:12:46.392] - Finding globals in 'args_list' chunk #2 ... [08:12:46.393] [08:12:46.393] [08:12:46.394] - Finding globals in 'args_list' for chunk #2 ... DONE [08:12:46.532] Chunk #2 of 2 ... DONE [08:12:46.533] Launching 2 futures (chunks) ... DONE [08:12:46.533] - resolving futures [08:12:46.533] - gathering results & relaying conditions (except errors) [08:12:46.783] - collecting values of futures [08:12:46.784] - accumulating results [08:12:46.785] - processing errors (handler = 'stop') [08:12:46.786] - extracting results [08:12:46.786] doFuture() ... DONE [1] 59.5 - plan('multisession') ... DONE - plan('cluster') ... [08:12:47.266] doFuture() ... [08:12:47.268] - dummy globals (as locals): [2] 'i', '.doRNG.stream' [08:12:47.268] - R expression: [08:12:47.268] { [08:12:47.268] doFuture::registerDoFuture() [08:12:47.268] lapply(seq_along(...future.x_ii), FUN = function(jj) { [08:12:47.268] ...future.x_jj <- ...future.x_ii[[jj]] [08:12:47.268] { [08:12:47.268] { [08:12:47.268] NULL [08:12:47.268] i <- NULL [08:12:47.268] } [08:12:47.268] .doRNG.stream <- NULL [08:12:47.268] } [08:12:47.268] ...future.env <- environment() [08:12:47.268] local({ [08:12:47.268] for (name in names(...future.x_jj)) { [08:12:47.268] assign(name, ...future.x_jj[[name]], envir = ...future.env, [08:12:47.268] inherits = FALSE) [08:12:47.268] } [08:12:47.268] }) [08:12:47.268] tryCatch({ [08:12:47.268] { [08:12:47.268] rngtools::RNGseed(.doRNG.stream) [08:12:47.268] } [08:12:47.268] { [08:12:47.268] sample.int(n = 100L, size = 1L) [08:12:47.268] } [08:12:47.268] }, error = identity) [08:12:47.268] }) [08:12:47.268] } [08:12:47.269] - identifying globals and packages ... [08:12:47.277] List of 1 [08:12:47.277] $ ...future.x_ii: NULL [08:12:47.277] - attr(*, "where")=List of 1 [08:12:47.277] ..$ ...future.x_ii: [08:12:47.277] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [08:12:47.277] - attr(*, "resolved")= logi FALSE [08:12:47.277] - attr(*, "total_size")= num 0 [08:12:47.280] - R expression: [08:12:47.280] { [08:12:47.280] doFuture::registerDoFuture() [08:12:47.280] lapply(seq_along(...future.x_ii), FUN = function(jj) { [08:12:47.280] ...future.x_jj <- ...future.x_ii[[jj]] [08:12:47.280] { [08:12:47.280] { [08:12:47.280] NULL [08:12:47.280] i <- NULL [08:12:47.280] } [08:12:47.280] .doRNG.stream <- NULL [08:12:47.280] } [08:12:47.280] ...future.env <- environment() [08:12:47.280] local({ [08:12:47.280] for (name in names(...future.x_jj)) { [08:12:47.280] assign(name, ...future.x_jj[[name]], envir = ...future.env, [08:12:47.280] inherits = FALSE) [08:12:47.280] } [08:12:47.280] }) [08:12:47.280] tryCatch({ [08:12:47.280] { [08:12:47.280] rngtools::RNGseed(.doRNG.stream) [08:12:47.280] } [08:12:47.280] { [08:12:47.280] sample.int(n = 100L, size = 1L) [08:12:47.280] } [08:12:47.280] }, error = identity) [08:12:47.280] }) [08:12:47.280] } [08:12:47.281] - globals: [1] '...future.x_ii' [08:12:47.281] List of 1 [08:12:47.281] $ ...future.x_ii: NULL [08:12:47.281] - attr(*, "where")=List of 1 [08:12:47.281] ..$ ...future.x_ii: [08:12:47.281] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [08:12:47.281] - attr(*, "resolved")= logi FALSE [08:12:47.281] - attr(*, "total_size")= num 0 [08:12:47.283] - packages: [2] 'doFuture', 'doRNG' [08:12:47.283] - identifying globals and packages ... DONE [08:12:47.288] Number of chunks: 2 [08:12:47.289] Number of futures (= number of chunks): 2 [08:12:47.289] Launching 2 futures (chunks) ... [08:12:47.289] Chunk #1 of 2 ... [08:12:47.290] - Finding globals in 'args_list' chunk #1 ... [08:12:47.291] [08:12:47.291] [08:12:47.291] - Finding globals in 'args_list' for chunk #1 ... DONE [08:12:47.315] Chunk #1 of 2 ... DONE [08:12:47.316] Chunk #2 of 2 ... [08:12:47.316] - Finding globals in 'args_list' chunk #2 ... [08:12:47.317] [08:12:47.317] [08:12:47.317] - Finding globals in 'args_list' for chunk #2 ... DONE [08:12:47.468] Chunk #2 of 2 ... DONE [08:12:47.468] Launching 2 futures (chunks) ... DONE [08:12:47.468] - resolving futures [08:12:47.469] - gathering results & relaying conditions (except errors) [08:12:47.691] - collecting values of futures [08:12:47.692] - accumulating results [08:12:47.693] - processing errors (handler = 'stop') [08:12:47.693] - extracting results [08:12:47.694] doFuture() ... DONE [1] 59.5 - plan('cluster') ... DONE *** withDoRNG() ... DONE > > source("incl/end.R") R Under development (unstable) (2023-12-19 r85710 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows Server 2022 x64 (build 20348) Matrix products: default locale: [1] LC_COLLATE=C LC_CTYPE=German_Germany.utf8 [3] LC_MONETARY=C LC_NUMERIC=C [5] LC_TIME=C time zone: Europe/Berlin tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] doRNG_1.8.6 rngtools_1.5.2 doFuture_1.0.1 future_1.33.0 foreach_1.5.2 loaded via a namespace (and not attached): [1] compiler_4.4.0 parallelly_1.36.0 tools_4.4.0 [4] parallel_4.4.0 future.apply_1.11.0 listenv_0.9.0 [7] codetools_0.2-19 iterators_1.0.14 digest_0.6.33 [10] globals_0.16.2 > > proc.time() user system elapsed 0.95 0.20 3.17