Bill Allombert on Fri, 22 Aug 2025 10:34:38 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: question on implementing an atomic operation in GP Pari
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: question on implementing an atomic operation in GP Pari
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Fri, 22 Aug 2025 10:34:32 +0200
- Delivery-date: Fri, 22 Aug 2025 10:34:38 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=math.u-bordeaux.fr; s=2022; t=1755851675; bh=Gm3cE6Eb2xiKickMVidhz7ZnYH41LMvl3awvhs11rCk=; h=Date:From:To:Subject:References:In-Reply-To:From; b=c61fvMRfd4fq2iy7HslBB/+OPG1yhJBO4TjLQT0+h1osk2tt0sKiBIZ0SQlX4BERJ L8fRJt0zy0iiTBSV6OjG6gr5s1Ko1X3aa5ww26D90vBWbULh8L5mjzBRWWfLaWA66G cKfT2cADieTVGGi6oec6Hc32F9RPzg11gXm9su0tPMVve0rwjucbWBnUJ9aPJYUfnq ztJn6P3lPpgOdFnP4h+RpuDh/ss46Tbtp8k1FYhlK+JpdRl8LOSGZXqLo09sIHb3SF 5ksFWliYQ7vAJuxI5YB50VhqNA24WC+qAqtjTXxvE46CrBn3iErJ+ahJVdVlkoutXU oqwk+Xg4DI6Mwzfm5jlTS7w4BXAdEVJ8aC3dFlZ29M0sCYa1EZo7WewSPkHgs06osX +SBtbUn2PWp0xCB3jZ7SMvaPJfpTHAgl/1y+BvXXvgBMgJPjwP7tiWEuV6pVT5zj6s wFA2jIAFt2Di3ZTCeA8L2mLRYcAt0B/Tbes/v/LsdFNpAM0Ei8JhnubcFOMQV4uSvd nCy62jaUi/HLWJUynAGVdRto5w7kwnZCP+xuWkopl5KX669WBaLGKiZ11HCkR0U2qn J0IMJofZFU/5L4khfa0VbN2/F8SNnI8CGYcOUGBfGsJ4h1HgcuP6OLF/geb5elgv1O L+sxLoVEKGQIoEOwRvAcdums=
- In-reply-to: <b9d1fa1d-9c24-4f61-9e4e-a08307d7ebfa@gmail.com>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <b9d1fa1d-9c24-4f61-9e4e-a08307d7ebfa@gmail.com>
On Thu, Aug 21, 2025 at 01:04:46PM -0700, American Citizen wrote:
> 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?
You can do that directly in GP using parfor or parforeach.
Cheers,
Bill.