Rhpc_setupRNG: Setup random number generators for worker processes

View source: R/RhpcRNG.R

Rhpc_setupRNGR Documentation

Setup random number generators for worker processes

Description

Initializes independent random number streams for each worker process using L'Ecuyer-CMRG algorithm.

Usage

Rhpc_setupRNG(cl, iseed = NULL)

Arguments

cl

external pointer to MPI communicator

iseed

optional integer seed for reproducibility. If NULL, uses current .Random.seed

Details

This function sets up independent random number streams for each worker to ensure they produce different but reproducible random sequences. It uses the L'Ecuyer-CMRG (Combined Multiple Recursive Generator) algorithm.

The master process's original .Random.seed is saved to options("Rhpc.oldseed") but is NOT automatically restored due to CRAN policy. Users should manually restore if needed: assign(".Random.seed", getOption("Rhpc.oldseed"), envir = globalenv())

Value

Returns invisibly the original .Random.seed that was saved.

See Also

Rhpc_getHandle, Rhpc_lapply


Rhpc documentation built on Aug. 4, 2026, 1:07 a.m.