Bill Allombert on Sun, 03 Dec 2023 15:31:39 +0100


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

Re: PARI/GP pthread questions


On Sun, Dec 03, 2023 at 03:09:49PM +0100, Karim Belabas wrote:
> * Bill Allombert [2023-12-03 13:15]:
> [...]
> > > 2)
> > > Under 3.4.22 nbthreads
> > > ...
> > > * pthread: number of threads (unlimited, default: number of cores)
> > > ...
> > > 
> > > On 16C/32T AMD 7950X CPU I see 3200% CPU in top when starting
> > > GP script with parforeach.
> > > 
> > > So should above doc be corrected to
> > > 
> > > "default: #cores * #threads_per_cor"
> > > 
> > > or better to be correct for multi-CPU systems:
> > 
> > When we wrote that, hyperthreading was only used in mainframes.
> > It would be much better if the default was the number of cores instead of the number
> > of hyperthreads.
> > Unfortunately the GNU C library only report the number of CPU threads
> > see getconf "_NPROCESSORS_CONF".
> > I recommends to set nbthreads to the total number of cores.
> 
> Is there a difference with the simpler 'nproc' (from coreutils) ?

from looking at the source code, nproc is actually more complex and still count
hyperthreads.

> For systems with hyper-threading, one can get the number of physical cores
> as follows on my laptop:
> 
> # grep '^cpu cores' /proc/cpuinfo | uniq
> cpu cores	: 4

This is only work if you have a single CPU!

Cheers,
-- 
Bill Allombert
Ingénieur de recherche en calcul scientifique ❄
CNRS/IMB UMR 5251