Bill Allombert on Wed, 07 Apr 2021 11:18:24 +0200


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

Re: pari_thread_sync missing in PARI/GP 2.13.0


On Wed, Apr 07, 2021 at 04:29:38AM -0400, Jeffrey Walton wrote:
> On Wed, Apr 7, 2021 at 4:05 AM Bill Allombert
> <Bill.Allombert@math.u-bordeaux.fr> wrote:
> >
> > On Wed, Apr 07, 2021 at 03:01:19AM -0400, Jeffrey Walton wrote:
> > > Hi Everyone,
> > >
> > > I'm using PARI/GP 2.13.0. I'm trying to build Jancar's ecgen. The
> > > build is failing due to a missing pari_thread_sync .
> > >
> > > I looked in the developer guide [1] but I don't see the replacement or
> > > what should be used nowadays.
> >
> > See COMPAT:
> >
> >   - pari_thread_sync is not needed anymore and has been removed.
> >
> > Just remove the call. Synchronization is done automatically by
> > pari_thread_alloc/pari_thread_start now.
> 
> Ack, thanks.
> 
> Does something like the following look about right?
> 
> #if PARI_VERSION_CODE < PARI_VERSION(2,12,0)
>     pari_thread_sync();
> #endif

Yes, this is about right.

--- A word of advice ---

It seems this code is using the pari_thread_alloc/pari_thread_start
interface.

If PARI is build with --mt=pthread (instead of just --enable-tls),
then the paralell code in libpari proper might interfer with the 
parallel code in the program, so it is usually safer to set
pari_mt_nbthreads to 1 (thus disabling libpari parallel code)
while the program parallel code is in use.

PARI 2.13 has much more paralell code in libpari than
PARI 2.11 so the probability of interference is much higher.
One symptom of interference is that the number of threads
is higher than what the program started.

We might find a better solution to this problem but few programs
are using pari_thread_alloc/pari_thread_start.

Cheers,
Bill