psutil icon indicating copy to clipboard operation
psutil copied to clipboard

[OS] Get core id of specific cpu_id

Open aouinizied opened this issue 1 year ago • 1 comments

Summary

  • OS: All
  • Type: core

Description

I do not find a way to get the core id of a specific cpu id.

Example:

psutil.Process().cpu_affinity()
# returns [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

# But how to know the core id of each cpu? Something like the following will make such operation possible
psutils.core_id(2)
#returns 1

# This will allow knowing if we are runnig on 12 Cores or 6 out of the set of allowed CPUs.

aouinizied avatar Mar 01 '23 16:03 aouinizied