in reply to Re^2: PDL and srand puzzle - support needed in MCE
in thread PDL and srand puzzle

I will add PDL to the list in MCE, MCE::Child, and MCE::Hobo.

# Set the seed of the base generator uniquely between workers.
# The new seed is computed using the current seed and $_wid value.
# One may set the seed at the application level for predictable
# results (non-thread workers only). Ditto for PDL, Math::Prime::Util,
# Math::Random, and Math::Random::MT::Auto.
if ( !$self->{use_threads} ) { my $_wid = $_args[1]; my $_seed = abs($self->{_seed} - ($_wid * 100000)) % 2147483560; CORE::srand($_seed); # PDL 2.062 ~ 2.089 PDL::srand($_seed) if $INC{'PDL.pm'} && PDL->can('srand'); # PDL 2.089_01+ PDL::srandom($_seed) if $INC{'PDL.pm'} && PDL->can('srandom'); ... }

This resolves calling PDL->random at the application level and expecting repeatable results.