Bill Allombert on Sun, 03 Dec 2023 13:15:32 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: PARI/GP pthread questions |
On Sun, Dec 03, 2023 at 12:47:16PM +0100, hermann@stamm-wilbrandt.de wrote: > 1) > single threaded I can measure runtime: > > my(t0=getabstime()); > foursquares(2^p-1); > print(getabstime()-t0,"ms"); > > How can I measure runtime in a thread executed with parforeach(...)? > I want to output the results a thread computed, with its own thread runtime. > I tried getabstime() asa above, but that reported always icreasing deltas. Not sure I understand: ? parforeach([1..8],v,my(t0=getabstime());factor(2^128+1);print(getabstime()-t0,"ms")) 32ms 35ms 35ms 35ms 35ms 36ms 35ms 32ms Obviously if you do foursquares(2^p-1); for increasing p, this will take longer and longer. > 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. Cheers, Bill