Bill Allombert on Wed, 24 Feb 2016 11:20:11 +0100


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

Re: Multi-threading safe?


On Wed, Feb 24, 2016 at 10:05:21AM +0100, Rafael Guglielmetti wrote:
> Dear PARI users,
> I would like to know if the PARI library is thread safe? More
> precisely I would like to know if I can use the library from inside a
> parallelized loop (via OpenMP) or if I may get problem with PARI's
> stack?

Hello Rafael,
You need to build PARI with the Configure flag --enable_tls or
--mt=pthread (Debian and Ubuntu packages are built this way),
then you need to allocate separate PARI stacks for each threads,
using pari_thread_alloc()/pari_thread_start().

See the example file 'examples/openmp.c' in the PARI distribution
and the appendix 'PARI and threads' in the documentation.

Cheers,
Bill.