cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

netbear
Journeyman III

How can I know which core is running

Hi All, I am doing some research on an AMD opteron 4X4 server . Now I need to know which cores are running in a thread . Besides , I need to know whether these cores are on the same die . So is it possible for me to get these information and how? Thank you!

0 Likes
6 Replies
avk
Adept III

Which OS?
0 Likes

both ubuntu 8.04 server and windows server 2008

 

0 Likes
avk
Adept III

Well, in case of Windows, if I was you, I would pay attention at GetProcessAffinityMask Win32 API function (and so on) and, probably, at RDTSCP instruction. I'm sure that you'll need to experiment in order to recognize which core on which die, because I never did this too .
0 Likes

If you want to see where threads and processes are running under Linux then I would suggest you use the tool named top.  There are two feature to turn on that help.  The first is to add the CPU core field the process last ran on by hitting 'f' (to edit the fields) and the 'j' (to toggle last used core field).  Second you can press 'H' in the main window to toggle if it shows threads or just processes.

Now if you want to set the affinity of a thread to a specific core than you should use the POSIX sched_{get,set}affinity().  There does not seam to be an interface from the OS to find out in a program where you are executing (except by getting your affinity and seeing it limits you to one core) so avk's response about RDTSCP is a good way to do that.  But be warned that with no limitation to the affinity then the OS could reschedule that thread on a different core at any instance. 

Is you work somehow NUMA related?  I am just wondering if you really need to know which core your threads are on.

I almost forgot you can find out if the cores are on the same die by looking at /proc/cpuinfo where one sees for each core which 'phyiscal id' it has and this the socket id as seen from Linux.

0 Likes

How can you tell which thread/core/package relates to which affinity bit?

On non-AMD, you need a whole library!

0 Likes
stevengarcia
Journeyman III

I like your site. This is very informative. Thank you everyone.

0 Likes