R Under development (unstable) (2023-12-20 r85711 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-20 r85711 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.1 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-20 r85711 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.1 listenv_0.9.0 [7] codetools_0.2-19 iterators_1.0.14 digest_0.6.33 [10] globals_0.16.2 - plan('sequential') ... [13:12:04.445] doFuture() ... [13:12:04.447] - dummy globals (as locals): [2] 'i', '.doRNG.stream' [13:12:04.448] - R expression: [13:12:04.448] { [13:12:04.448] doFuture::registerDoFuture() [13:12:04.448] lapply(seq_along(...future.x_ii), FUN = function(jj) { [13:12:04.448] ...future.x_jj <- ...future.x_ii[[jj]] [13:12:04.448] { [13:12:04.448] { [13:12:04.448] NULL [13:12:04.448] i <- NULL [13:12:04.448] } [13:12:04.448] .doRNG.stream <- NULL [13:12:04.448] } [13:12:04.448] ...future.env <- environment() [13:12:04.448] local({ [13:12:04.448] for (name in names(...future.x_jj)) { [13:12:04.448] assign(name, ...future.x_jj[[name]], envir = ...future.env, [13:12:04.448] inherits = FALSE) [13:12:04.448] } [13:12:04.448] }) [13:12:04.448] tryCatch({ [13:12:04.448] { [13:12:04.448] rngtools::RNGseed(.doRNG.stream) [13:12:04.448] } [13:12:04.448] { [13:12:04.448] sample.int(n = 100L, size = 1L) [13:12:04.448] } [13:12:04.448] }, error = identity) [13:12:04.448] }) [13:12:04.448] } [13:12:04.449] - identifying globals and packages ... [13:12:04.467] List of 1 [13:12:04.467] $ ...future.x_ii: NULL [13:12:04.467] - attr(*, "where")=List of 1 [13:12:04.467] ..$ ...future.x_ii: [13:12:04.467] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [13:12:04.467] - attr(*, "resolved")= logi FALSE [13:12:04.467] - attr(*, "total_size")= num 0 [13:12:04.475] - R expression: [13:12:04.476] { [13:12:04.476] doFuture::registerDoFuture() [13:12:04.476] lapply(seq_along(...future.x_ii), FUN = function(jj) { [13:12:04.476] ...future.x_jj <- ...future.x_ii[[jj]] [13:12:04.476] { [13:12:04.476] { [13:12:04.476] NULL [13:12:04.476] i <- NULL [13:12:04.476] } [13:12:04.476] .doRNG.stream <- NULL [13:12:04.476] } [13:12:04.476] ...future.env <- environment() [13:12:04.476] local({ [13:12:04.476] for (name in names(...future.x_jj)) { [13:12:04.476] assign(name, ...future.x_jj[[name]], envir = ...future.env, [13:12:04.476] inherits = FALSE) [13:12:04.476] } [13:12:04.476] }) [13:12:04.476] tryCatch({ [13:12:04.476] { [13:12:04.476] rngtools::RNGseed(.doRNG.stream) [13:12:04.476] } [13:12:04.476] { [13:12:04.476] sample.int(n = 100L, size = 1L) [13:12:04.476] } [13:12:04.476] }, error = identity) [13:12:04.476] }) [13:12:04.476] } [13:12:04.476] - globals: [1] '...future.x_ii' [13:12:04.476] List of 1 [13:12:04.476] $ ...future.x_ii: NULL [13:12:04.476] - attr(*, "where")=List of 1 [13:12:04.476] ..$ ...future.x_ii: [13:12:04.476] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [13:12:04.476] - attr(*, "resolved")= logi FALSE [13:12:04.476] - attr(*, "total_size")= num 0 [13:12:04.479] - packages: [2] 'doFuture', 'doRNG' [13:12:04.479] - identifying globals and packages ... DONE [13:12:04.479] Number of chunks: 1 [13:12:04.479] Number of futures (= number of chunks): 1 [13:12:04.480] Launching 1 futures (chunks) ... [13:12:04.480] Chunk #1 of 1 ... [13:12:04.480] - Finding globals in 'args_list' chunk #1 ... [13:12:04.481] [13:12:04.481] [13:12:04.481] - Finding globals in 'args_list' for chunk #1 ... DONE [13:12:04.492] Chunk #1 of 1 ... DONE [13:12:04.492] Launching 1 futures (chunks) ... DONE [13:12:04.492] - resolving futures [13:12:04.492] - gathering results & relaying conditions (except errors) [13:12:04.494] - collecting values of futures [13:12:04.494] - accumulating results [13:12:04.495] - processing errors (handler = 'stop') [13:12:04.495] - extracting results [13:12:04.496] doFuture() ... DONE [13:12:04.500] doFuture() ... [13:12:04.501] - dummy globals (as locals): [2] 'i', '.doRNG.stream' [13:12:04.501] - R expression: [13:12:04.501] { [13:12:04.501] doFuture::registerDoFuture() [13:12:04.501] lapply(seq_along(...future.x_ii), FUN = function(jj) { [13:12:04.501] ...future.x_jj <- ...future.x_ii[[jj]] [13:12:04.501] { [13:12:04.501] { [13:12:04.501] NULL [13:12:04.501] i <- NULL [13:12:04.501] } [13:12:04.501] .doRNG.stream <- NULL [13:12:04.501] } [13:12:04.501] ...future.env <- environment() [13:12:04.501] local({ [13:12:04.501] for (name in names(...future.x_jj)) { [13:12:04.501] assign(name, ...future.x_jj[[name]], envir = ...future.env, [13:12:04.501] inherits = FALSE) [13:12:04.501] } [13:12:04.501] }) [13:12:04.501] tryCatch({ [13:12:04.501] { [13:12:04.501] rngtools::RNGseed(.doRNG.stream) [13:12:04.501] } [13:12:04.501] { [13:12:04.501] sample.int(n = 100L, size = 1L) [13:12:04.501] } [13:12:04.501] }, error = identity) [13:12:04.501] }) [13:12:04.501] } [13:12:04.502] - identifying globals and packages ... [13:12:04.510] List of 1 [13:12:04.510] $ ...future.x_ii: NULL [13:12:04.510] - attr(*, "where")=List of 1 [13:12:04.510] ..$ ...future.x_ii: [13:12:04.510] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [13:12:04.510] - attr(*, "resolved")= logi FALSE [13:12:04.510] - attr(*, "total_size")= num 0 [13:12:04.513] - R expression: [13:12:04.513] { [13:12:04.513] doFuture::registerDoFuture() [13:12:04.513] lapply(seq_along(...future.x_ii), FUN = function(jj) { [13:12:04.513] ...future.x_jj <- ...future.x_ii[[jj]] [13:12:04.513] { [13:12:04.513] { [13:12:04.513] NULL [13:12:04.513] i <- NULL [13:12:04.513] } [13:12:04.513] .doRNG.stream <- NULL [13:12:04.513] } [13:12:04.513] ...future.env <- environment() [13:12:04.513] local({ [13:12:04.513] for (name in names(...future.x_jj)) { [13:12:04.513] assign(name, ...future.x_jj[[name]], envir = ...future.env, [13:12:04.513] inherits = FALSE) [13:12:04.513] } [13:12:04.513] }) [13:12:04.513] tryCatch({ [13:12:04.513] { [13:12:04.513] rngtools::RNGseed(.doRNG.stream) [13:12:04.513] } [13:12:04.513] { [13:12:04.513] sample.int(n = 100L, size = 1L) [13:12:04.513] } [13:12:04.513] }, error = identity) [13:12:04.513] }) [13:12:04.513] } [13:12:04.513] - globals: [1] '...future.x_ii' [13:12:04.514] List of 1 [13:12:04.514] $ ...future.x_ii: NULL [13:12:04.514] - attr(*, "where")=List of 1 [13:12:04.514] ..$ ...future.x_ii: [13:12:04.514] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [13:12:04.514] - attr(*, "resolved")= logi FALSE [13:12:04.514] - attr(*, "total_size")= num 0 [13:12:04.516] - packages: [2] 'doFuture', 'doRNG' [13:12:04.516] - identifying globals and packages ... DONE [13:12:04.516] Number of chunks: 1 [13:12:04.517] Number of futures (= number of chunks): 1 [13:12:04.517] Launching 1 futures (chunks) ... [13:12:04.517] Chunk #1 of 1 ... [13:12:04.517] - Finding globals in 'args_list' chunk #1 ... [13:12:04.518] [13:12:04.518] [13:12:04.518] - Finding globals in 'args_list' for chunk #1 ... DONE [13:12:04.522] Chunk #1 of 1 ... DONE [13:12:04.522] Launching 1 futures (chunks) ... DONE [13:12:04.523] - resolving futures [13:12:04.523] - gathering results & relaying conditions (except errors) [13:12:04.523] - collecting values of futures [13:12:04.523] - accumulating results [13:12:04.524] - processing errors (handler = 'stop') [13:12:04.524] - extracting results [13:12:04.525] doFuture() ... DONE [1] 59.5 - plan('sequential') ... DONE - plan('multisession') ... [13:12:05.383] doFuture() ... [13:12:05.385] - dummy globals (as locals): [2] 'i', '.doRNG.stream' [13:12:05.385] - R expression: [13:12:05.385] { [13:12:05.385] doFuture::registerDoFuture() [13:12:05.385] lapply(seq_along(...future.x_ii), FUN = function(jj) { [13:12:05.385] ...future.x_jj <- ...future.x_ii[[jj]] [13:12:05.385] { [13:12:05.385] { [13:12:05.385] NULL [13:12:05.385] i <- NULL [13:12:05.385] } [13:12:05.385] .doRNG.stream <- NULL [13:12:05.385] } [13:12:05.385] ...future.env <- environment() [13:12:05.385] local({ [13:12:05.385] for (name in names(...future.x_jj)) { [13:12:05.385] assign(name, ...future.x_jj[[name]], envir = ...future.env, [13:12:05.385] inherits = FALSE) [13:12:05.385] } [13:12:05.385] }) [13:12:05.385] tryCatch({ [13:12:05.385] { [13:12:05.385] rngtools::RNGseed(.doRNG.stream) [13:12:05.385] } [13:12:05.385] { [13:12:05.385] sample.int(n = 100L, size = 1L) [13:12:05.385] } [13:12:05.385] }, error = identity) [13:12:05.385] }) [13:12:05.385] } [13:12:05.385] - identifying globals and packages ... [13:12:05.394] List of 1 [13:12:05.394] $ ...future.x_ii: NULL [13:12:05.394] - attr(*, "where")=List of 1 [13:12:05.394] ..$ ...future.x_ii: [13:12:05.394] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [13:12:05.394] - attr(*, "resolved")= logi FALSE [13:12:05.394] - attr(*, "total_size")= num 0 [13:12:05.397] - R expression: [13:12:05.397] { [13:12:05.397] doFuture::registerDoFuture() [13:12:05.397] lapply(seq_along(...future.x_ii), FUN = function(jj) { [13:12:05.397] ...future.x_jj <- ...future.x_ii[[jj]] [13:12:05.397] { [13:12:05.397] { [13:12:05.397] NULL [13:12:05.397] i <- NULL [13:12:05.397] } [13:12:05.397] .doRNG.stream <- NULL [13:12:05.397] } [13:12:05.397] ...future.env <- environment() [13:12:05.397] local({ [13:12:05.397] for (name in names(...future.x_jj)) { [13:12:05.397] assign(name, ...future.x_jj[[name]], envir = ...future.env, [13:12:05.397] inherits = FALSE) [13:12:05.397] } [13:12:05.397] }) [13:12:05.397] tryCatch({ [13:12:05.397] { [13:12:05.397] rngtools::RNGseed(.doRNG.stream) [13:12:05.397] } [13:12:05.397] { [13:12:05.397] sample.int(n = 100L, size = 1L) [13:12:05.397] } [13:12:05.397] }, error = identity) [13:12:05.397] }) [13:12:05.397] } [13:12:05.397] - globals: [1] '...future.x_ii' [13:12:05.397] List of 1 [13:12:05.397] $ ...future.x_ii: NULL [13:12:05.397] - attr(*, "where")=List of 1 [13:12:05.397] ..$ ...future.x_ii: [13:12:05.397] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [13:12:05.397] - attr(*, "resolved")= logi FALSE [13:12:05.397] - attr(*, "total_size")= num 0 [13:12:05.400] - packages: [2] 'doFuture', 'doRNG' [13:12:05.400] - identifying globals and packages ... DONE [13:12:05.404] Number of chunks: 2 [13:12:05.404] Number of futures (= number of chunks): 2 [13:12:05.404] Launching 2 futures (chunks) ... [13:12:05.405] Chunk #1 of 2 ... [13:12:05.405] - Finding globals in 'args_list' chunk #1 ... [13:12:05.405] [13:12:05.405] [13:12:05.406] - Finding globals in 'args_list' for chunk #1 ... DONE [13:12:05.423] Chunk #1 of 2 ... DONE [13:12:05.423] Chunk #2 of 2 ... [13:12:05.423] - Finding globals in 'args_list' chunk #2 ... [13:12:05.424] [13:12:05.424] [13:12:05.424] - Finding globals in 'args_list' for chunk #2 ... DONE [13:12:05.535] Chunk #2 of 2 ... DONE [13:12:05.535] Launching 2 futures (chunks) ... DONE [13:12:05.535] - resolving futures [13:12:05.535] - gathering results & relaying conditions (except errors) [13:12:05.686] - collecting values of futures [13:12:05.687] - accumulating results [13:12:05.688] - processing errors (handler = 'stop') [13:12:05.688] - extracting results [13:12:05.688] doFuture() ... DONE [1] 59.5 - plan('multisession') ... DONE - plan('cluster') ... [13:12:06.018] doFuture() ... [13:12:06.020] - dummy globals (as locals): [2] 'i', '.doRNG.stream' [13:12:06.020] - R expression: [13:12:06.020] { [13:12:06.020] doFuture::registerDoFuture() [13:12:06.020] lapply(seq_along(...future.x_ii), FUN = function(jj) { [13:12:06.020] ...future.x_jj <- ...future.x_ii[[jj]] [13:12:06.020] { [13:12:06.020] { [13:12:06.020] NULL [13:12:06.020] i <- NULL [13:12:06.020] } [13:12:06.020] .doRNG.stream <- NULL [13:12:06.020] } [13:12:06.020] ...future.env <- environment() [13:12:06.020] local({ [13:12:06.020] for (name in names(...future.x_jj)) { [13:12:06.020] assign(name, ...future.x_jj[[name]], envir = ...future.env, [13:12:06.020] inherits = FALSE) [13:12:06.020] } [13:12:06.020] }) [13:12:06.020] tryCatch({ [13:12:06.020] { [13:12:06.020] rngtools::RNGseed(.doRNG.stream) [13:12:06.020] } [13:12:06.020] { [13:12:06.020] sample.int(n = 100L, size = 1L) [13:12:06.020] } [13:12:06.020] }, error = identity) [13:12:06.020] }) [13:12:06.020] } [13:12:06.021] - identifying globals and packages ... [13:12:06.030] List of 1 [13:12:06.030] $ ...future.x_ii: NULL [13:12:06.030] - attr(*, "where")=List of 1 [13:12:06.030] ..$ ...future.x_ii: [13:12:06.030] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [13:12:06.030] - attr(*, "resolved")= logi FALSE [13:12:06.030] - attr(*, "total_size")= num 0 [13:12:06.032] - R expression: [13:12:06.032] { [13:12:06.032] doFuture::registerDoFuture() [13:12:06.032] lapply(seq_along(...future.x_ii), FUN = function(jj) { [13:12:06.032] ...future.x_jj <- ...future.x_ii[[jj]] [13:12:06.032] { [13:12:06.032] { [13:12:06.032] NULL [13:12:06.032] i <- NULL [13:12:06.032] } [13:12:06.032] .doRNG.stream <- NULL [13:12:06.032] } [13:12:06.032] ...future.env <- environment() [13:12:06.032] local({ [13:12:06.032] for (name in names(...future.x_jj)) { [13:12:06.032] assign(name, ...future.x_jj[[name]], envir = ...future.env, [13:12:06.032] inherits = FALSE) [13:12:06.032] } [13:12:06.032] }) [13:12:06.032] tryCatch({ [13:12:06.032] { [13:12:06.032] rngtools::RNGseed(.doRNG.stream) [13:12:06.032] } [13:12:06.032] { [13:12:06.032] sample.int(n = 100L, size = 1L) [13:12:06.032] } [13:12:06.032] }, error = identity) [13:12:06.032] }) [13:12:06.032] } [13:12:06.033] - globals: [1] '...future.x_ii' [13:12:06.033] List of 1 [13:12:06.033] $ ...future.x_ii: NULL [13:12:06.033] - attr(*, "where")=List of 1 [13:12:06.033] ..$ ...future.x_ii: [13:12:06.033] - attr(*, "class")= chr [1:3] "FutureGlobals" "Globals" "list" [13:12:06.033] - attr(*, "resolved")= logi FALSE [13:12:06.033] - attr(*, "total_size")= num 0 [13:12:06.035] - packages: [2] 'doFuture', 'doRNG' [13:12:06.036] - identifying globals and packages ... DONE [13:12:06.039] Number of chunks: 2 [13:12:06.039] Number of futures (= number of chunks): 2 [13:12:06.039] Launching 2 futures (chunks) ... [13:12:06.040] Chunk #1 of 2 ... [13:12:06.040] - Finding globals in 'args_list' chunk #1 ... [13:12:06.040] [13:12:06.040] [13:12:06.041] - Finding globals in 'args_list' for chunk #1 ... DONE [13:12:06.058] Chunk #1 of 2 ... DONE [13:12:06.058] Chunk #2 of 2 ... [13:12:06.058] - Finding globals in 'args_list' chunk #2 ... [13:12:06.059] [13:12:06.059] [13:12:06.059] - Finding globals in 'args_list' for chunk #2 ... DONE [13:12:06.149] Chunk #2 of 2 ... DONE [13:12:06.149] Launching 2 futures (chunks) ... DONE [13:12:06.150] - resolving futures [13:12:06.150] - gathering results & relaying conditions (except errors) [13:12:06.307] - collecting values of futures [13:12:06.307] - accumulating results [13:12:06.308] - processing errors (handler = 'stop') [13:12:06.309] - extracting results [13:12:06.309] doFuture() ... DONE [1] 59.5 - plan('cluster') ... DONE *** withDoRNG() ... DONE > > source("incl/end.R") R Under development (unstable) (2023-12-20 r85711 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.1 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.62 0.15 2.29