[gmx-developers] checking CPU set

Szilárd Páll szilard.pall at cbr.su.se
Tue Oct 30 00:32:14 CET 2012


In order to be nice and not have mdrun override externally set CPU
affinities I want to check whether the affinity is default or it has been
changed (by taskset, OpenMP library, etc.). Initially I want to implement
this for GNU platforms with sched.h.

While I initially though if no affinity is set the cpu set should be empty,
in fact it in this case CPU_ISSET will give the same result as if all CPUs
were in the set -- which actually makes sense. However, this left me
quite clueless about how to distinguish between the case when all CPUs are
present in the cpu set and when e.g. all CPU are set by taskset, e.g.
$ taskset 0xF mdrun # quite useless on a quad-core machine

Does anybody have an idea how to distinguish these two cases. It would be
possible, because e.g. hwloc-ps can do it (but they do it based on their
own mask-representation which makes is a bit hard to figure out what I need
from their code).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.sys.kth.se/pipermail/gromacs.org_gmx-developers/attachments/20121030/cace0b55/attachment.html>

More information about the gromacs.org_gmx-developers mailing list