Bill Allombert on Sat, 12 Oct 2024 20:38:40 +0200


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

Re: PARI with --enable-tls


On Sat, Oct 12, 2024 at 08:55:31AM -0400, Max Alekseyev wrote:
> Hello,
> 
> Pari can be compiled with the option:
> --enable-tls  enable thread-local stack
> 
> What are the advantages/disadvantages of using it? (with combination of
> --mt=pthread if that matters)

As Karim says, --mt=pthread implies --enable-tls.

With --enable-tls without --mt=pthread, gp will behave exactly as --mt=single,
but it will be possible to write multi-threaded libpari programs that use the
raw POSIX thread interface, see example examples/thread.c.

This is also possible with --mt=pthread, but --mt=pthread also allow to write
multi-threaded libpari program that use the PARI mt interface, see
examples/pari-mt.c.

As Karim says again, using --enable-tls and --mt=pthread incur a slowdown of
libpari due to the use of TLS variables. 
To reduce it, two options that are cumulatives:
- use gp-sta instead of gp-dyn
- use the compiler/linker flag -flto 

Cheers,
Bill.