open-mpi / hwloc

Hardware locality (hwloc)
https://www.open-mpi.org/projects/hwloc
Other
569 stars 173 forks source link

get_last_cpu_location improvements #147

Open bgoglin opened 8 years ago

bgoglin commented 8 years ago

The thisthread version could return the os_index instead of a bitmap, to simplify work in the caller.

On Linux, we only use sched_getcpu() in thisthread, not in the current thread among all threads of the current process. The fallback using /proc is very slow according to #261.

As a arch-specific fallback when there's no OS hook, x86 could use cpuid's apicid to implement get_last_cpu_location(THREAD). This arch-specific callback would be set by calling a new hwloc_set_x86_hooks() at the end of hwloc_set_binding_hooks() to set callbacks that are still NULL. Would require to store every PU APIC id during x86 discovery.

As discussed in #261 , x86 rdtscp/rdpid could help, but it's not that easy so sched_getcpu() is better for now (but Linux only).

~~For FreeBSD: https://lists.freebsd.org/pipermail/freebsd-current/2011-October/028713.html "The kern.proc sysctls do provide oncpu and lastcpu information, which, I believe, is used by top. But this is very slow way to get cpu id."~~ FreeBSD uses sysctl to retrieve infos about all threads in a process (just like libprocps). Might be slow.

bgoglin commented 4 years ago

FreeBSD part will be in hwloc v2.2, commit 875793986faf4797940611b57cd8abb2598ee553 PR #387.