Getting # Physical CPUs
dsimcha
dsimcha at yahoo.com
Wed Jul 14 10:55:45 PDT 2010
== Quote from eris (jvburnes at gmail.com)'s article
> This is a relatively difficult problem in general to do portably due to hardware
differences, topology differences, changes to hardware, OS variations. Even the
pthreads library doesn't reliably implement it in a portable manner.
> I came to the conclusion that the people most motivated to keep up to date on a
portable CPU core topology are the national supercomputing labs. INRIA and
various US labs came up with "Portable Hardware Locality" library. It gives you
*everything* you need to discover the number of CPU sockets, memory architecture,
number of cores per socket, control cpu affinity etc.
> The HWLoc C libraries are written by the open-mpi project here:
http://www.open-mpi.org/projects/hwloc/
I appreciate the help, but honestly, if detecting this properly requires adding
dependencies to my projects, I'm happier with the simple workaround of having a
manual command line switch to specify the number of CPUs. The projects in
question are internal research projects, not things that are going to be released
on the computer-illiterate masses. It would be nice to not have to manually
specify such a parameter on every run, but not nice enough to be worth introducing
a dependency.
More information about the Digitalmars-d
mailing list