wraithx on Sat, 13 May 2023 15:42:31 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Question about random() and threads... |
Hello,I was wondering how the random() function was implemented? I see in the documentation it mentions "a single internal generator", but if I use threads, with parfor() or similar, then I was wondering:
1) Is there a unique internal generator per thread? ie Each thread can have it's own starting seed and produce it's own sequence of random values?
or2) Is there a single internal generator per pari/gp instance, and each thread calling random() gets the next random value from that single internal generator?
Also, if 2 is the case, then is there a worry that two (or more) different threads calling random() will get the same value? Or is random atomic and thread-safe? Thanks for any insights you can provide!
-David C.