Find out CPU core of specific thread at runtime
Frage
I am running CC compiler over SUN/Solaris, I have more then 64 threads assigned by the OS to different cores. I am interested to know if there is method to get the core id for different threads during run time?
I am not setting affinity for those threads, i use psrset to create the processor set.
Lösung
I found the answer: getcpuid() on Solaris returns the core id (even for hyper thread): i have tested it and it works great. http://www.unix.com/man-page/all/3c/getcpuid/
Andere Tipps
I don't know if there are Solaris-specific system calls for this, but you could use the portable hwloc library and its hwloc_get_last_cpu_location
function.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow