Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: PDL and srand puzzle - support needed in MCE

by marioroy (Prior)
on Jun 04, 2024 at 23:57 UTC ( [id://11159782]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11159782]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2025-02-09 14:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (96 votes). Check out past polls.