question on implementing an atomic operation in GP Pari

American Citizen <[email protected]> Thu, 21 Aug 2025 13:04:46 -0700
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <[email protected]>
Hello:

Currently I am using 6 cores to run though a long list of primes or 
product of primes congruent to 1 mod 4. (such as 5, 37, 65, etc)

I split the list according to the assigned processor number 0..5 by 
using modulus 6 values.

While this method works, some of the processors are climbing up the list 
faster than others.

Currently I have

n:88181
n:90889
n:87145
n:88285
n:88633
n:89245

and you can see that the 2nd processor at 90,889 is ahead of the others. 
The 3rd processor is behind at 87,145.

I can use an alternate scheme, having all 6 cores access an atomic 
operator and receiving just one unique number from the list, then 
incrementing the index to the list, this would insure that all numbers 
are bunched closely together.

This requires an atomic "get and increment" operator. I do have C code 
which does this, would this be the right way to go, to implement an 
external call into the gp code?

Has anyone worked with atomic "get and increment" functions running 
under pari?

Randall