in reply to Re^9: PDL and srand puzzle - uniqueness PDL->random vs CORE::rand
in thread PDL and srand puzzle

I'd have expected calling srandom inside new threads to behave better. Could you take a look at the srand code and see if anything is obviously wrong? Also, are you able to see if the duplicates are in groups i.e. sequences?

Replies are listed 'Best First'.
Re^11: PDL and srand puzzle - PDL::srand/srandom not working
by marioroy (Prior) on Jun 08, 2024 at 06:40 UTC

    See my reply to Rob. In short, calling PDL::srandom before spawning workers has no effect. The workaround is to call CORE::srand instead.

    See also, non-thread testing.

    Edit: MCE checks for PDL::Primitive->can('srand'), but missed checking PDL::Primitive->can('srandom'). Resolved in MCE v1.894 and MCE::Shared v1.889.

      Calling srand cannot be a workaround for this, because there is no interaction between Perl's RNG and PDL's. They are separate systems.