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

CPU socket detection for the current process #89

Closed
jaywonchung opened this issue Jun 3, 2024 · 1 comment · Fixed by #117
Closed

CPU socket detection for the current process #89

jaywonchung opened this issue Jun 3, 2024 · 1 comment · Fixed by #117
Labels
enhancement New feature or request

Comments

@jaywonchung
Copy link
Member

In a system, there can be multiple CPU sockets. Just like GPUs, after #36, Zeus will be able to measure the energy consumption of specific CPU packages. However, unlike GPUs, which socket the process ends up in is often not explicitly controlled by the user. So we want to have a utility function in Zeus that detects the CPU package the current process is running in, and allow the user to select the current CPU for measurement.

@jaywonchung jaywonchung added the enhancement New feature or request label Jun 3, 2024
@jaywonchung
Copy link
Member Author

# Get CPU ID
cat /proc/self/stat | awk '{print $39}'

# Map CPU ID to physical socket
cat /sys/devices/system/cpu/cpu60/topology/physical_package_id

Haven't checked how generic this is. I think relying on procfs should be fine in general.
See procfs manpage -- /proc/pid/stat -- (39) processor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant