RandomTask#

class caput.pipeline.tasklib.random.RandomTask[source]#

Bases: caput.pipeline.tasklib.base.MPILoggedTask

A base class for MPI tasks that need to generate random numbers.

Attributes:
seedint

Set the seed for use in the task. If not set, a random seed is generated and broadcast to all ranks. The seed being used is logged, to repeat a previous run, simply set this as the seed parameter.

threadsint

Set the number of threads to use for the random number generator. If not explicitly set this will use the value of the OMP_NUM_THREADS environment variable, or fall back to four.

property local_seed[source]#

Get the seed to be used on this rank.

Returns:
rank_local_seedint

Seed local to this rank.

property rng[source]#

A random number generator for this task.

Warning

Initialising the RNG is a collective operation if the seed is not set, and so all ranks must participate in the first access of this property.

Returns:
rngMultiThreadedRNG

A deterministically seeded random number generator suitable for use in MPI jobs.