Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return number of numa nodes #1610

Closed
santagada opened this issue Oct 21, 2019 · 8 comments
Closed

Return number of numa nodes #1610

santagada opened this issue Oct 21, 2019 · 8 comments

Comments

@santagada
Copy link

Add a function like cpu_count but numa_count(), and on windows also a groups_count() could be very handy.

@Porges
Copy link

Porges commented Feb 3, 2020

It would be nice to also have physical CPU count, since the code to do this on Windows is rather gnarly and requires dropping to ctypes.

@giampaolo
Copy link
Owner

giampaolo commented Feb 3, 2020

It would be nice to also have physical CPU count

cpu_count(logical=False) is supposed to do it.

Back to the original request: is there an actual use case for NUMA nodes or it would just be for display (e.g. task manager apps)? Also, what do you mean by groups_count()?

@Porges
Copy link

Porges commented Feb 3, 2020

@giampaolo that is physical core count, I’m meaning actual CPU/socket count.

@giampaolo
Copy link
Owner

Oh! Socket count. Mmm... That sounds sort of low levelish (would it really be useful?). Does Windows provide an API for this? I'm not sure we can support other platforms other than Windows.

Also (perhaps a personal consideration): the definition of what a CPU count really means is a bit confusing. The definition I ad-here to is this:
https://www.sqlskills.com/blogs/glenn/what-is-the-difference-between-physical-sockets-physical-cores-and-logical-cores/
...so 3 kinds:

  1. socket count = number of sockets on the motherboard
  2. physical count = number of physical CPU cores (can have more than 1 per socket)
  3. logical count = physical count * number of hyper threading cores (hyper threading = INTEL's way to make 1 processor look like many processors)

psutil currently supports 2 and 3.

@santagada
Copy link
Author

if you have more than 64 logical cpus, windows will put them on different groups, as an affinity mask is 64 bits (so you can only turn on and off 64 cpus). Knowing the group_count on windows is useful. More useful is the total logical cpus in all numa nodes, IIRC cpu_count() only return the number of logical cpu on the first numa node.

@giampaolo
Copy link
Owner

if you have more than 64 logical cpus, windows will put them on different groups, as an affinity mask is 64 bits (so you can only turn on and off 64 cpus).

Are you sure? On Windows cpu_logical() is implemented by using GetActiveProcessorCount(ALL_PROCESSOR_GROUPS). The name suggests all groups should be included.

ncpus = GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);

As for NUMA: I'm no expert. Is it something which exists in Windows only?

@akrus
Copy link

akrus commented Jun 30, 2020

One small note on NUMA nodes, it's not equal to socket count, e.g. 2x AMD EPYC 7601:

# numactl --hardware                                                                                                                                                     
available: 8 nodes (0-7)

And it depends on BIOS settings (Node Interleaving and a few more options for AMD CPUs).

In Linux you can get the info from sysfs:

# ls -1 /sys/devices/system/node/                                                                                                                                                                                         
has_cpu                                                                                                                                                                                                                                      
has_memory
has_normal_memory
node0
node1
node2
node3
node4
node5
node6
node7
online
possible
power
uevent

@giampaolo
Copy link
Owner

Closing as duplicate of #1392.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants