Max Alekseyev on Fri, 17 Jan 2025 21:31:58 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

shared variables in parfor()


Hello,

I naively thought that the following code would print a few zeros, which would then follow by all ones:

my(q=0); parfor(i=1,10^6, print(q); 0, R, q=1)

but it constantly prints zeros. So, the value of q is not shared between threads. 
What is the right way to create a shared variable (with pthreads if that matters)?

Regards,
Max