Rupert Brooks, le Thu 22 Jul 2010 09:20:34 -0400, a écrit :
> So i apologize if this question has been asked many times before. Is
> there a way using hwloc (or otherwise) that i can identify which core
> of the machine a thread is currently using?
Hwloc provides a function to get the current affinity mask. This
doesn't however give which processor the thread is really currently
One issue with such function is that the returned value is potentially
outdated very quickly, when the OS is allowed to move threads. That's
probably why I haven't seen it provided by OSes. In the case of Linux,
you can check e.g. top's P column (Last used cpu), or you can also check
the 39th field of /proc/<pid>/stat which provides the same information.
In practice, I usually trust the OS in respecting the affinity mask, and
just use lstopo --top to get the affinity mask that the OS is supposed