Conversation
Standardize AMD SMI error variable names
Normalize AMD SMI return code variable names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Description
AMD SMI PAPI Component
Overview
This component adds AMD SMI to PAPI. It discovers GPUs at runtime and exposes AMD SMI-reported metrics (temperatures, power, fans, PCIe, RAS/ECC, cache/VRAM info, utilization, counters, etc.) as PAPI native events.
Targeted for ROCm 6.4.0 (AMD SMI ~25.3) and expected to work with ROCm(6.3.4 ~ 6.4.3) releases as well.
Tested on a combination of MI210 & MI300 for ROCm:
Usage
How it fits together (high-level)
linux-amd-smi.c: implements the PAPI vector (init/start/stop/read/reset/etc.) and delegates to the internalamds_*APIs.amds.c:dlopenAMD SMI, discover devices, build the native event table, and wire up accessors.amds_accessors.c: one function per metric — actually calls AMD SMI library to read and write values.amds_ctx.c: per-eventset lifecycle — open/close/start/stop/read/write/reset groups of events and enforce device usage.amds_evtapi.c: native event enumeration — code↔name↔description helpers for PAPI.amds_priv.h: internal types (e.g.,native_event_t), globals, and AMD SMI function-pointer declarations.amds_funcs.h: list of AMD SMI API calls used (generates the function-pointer declarations/definitions).htable.h: lightweight string→event lookup (for fast name→code mapping).amds.h: public “component-internal” API used across the above files.Rules.amd_smi: build glue to include this component in PAPI.File-by-file (concise)
linux-amd-smi.cDeclares the
papi_vector_tfor this component; initializes on first use; hands off work toamds_*for device/event management; implements PAPI hooks (init_component,update_control_state,start,read,stop,reset,shutdown, and native-event queries).amds.cDynamically loads
libamd_smi.so, resolves AMD SMI symbols, discovers sockets/devices, and builds the native event table. Defines helpers to add simple and counter-based events. Manages global teardown (destroy event table, close library).amds_accessors.cImplements the accessors that read/write individual metrics (e.g., temperatures, fans, PCIe, energy, power caps, RAS/ECC, clocks, VRAM, link topology, XGMI/PCIe metrics, firmware/board info, etc.). Each accessor maps an event’s
(variant, subvariant)to the right SMI call and returns the value.amds_ctx.cProvides the per-eventset context:
amds_ctx_open/close— acquire/release devices, run per-event open/close hooks.amds_ctx_start/stop— start/stop counters where needed.amds_ctx_read/write/reset— read current values, optionally write supported controls (e.g., power cap), zero software view.amds_evtapi.cImplements native-event enumeration for PAPI (
enum,code_to_name,name_to_code,code_to_descr) using the in-memory event table and a small hash map for fast lookups.amds_priv.hInternal definitions:
native_event_t(name/descr/device/mode/value + open/close/start/stop/access callbacks), global getters, and the AMD SMI function-pointer declarations (viaamds_funcs.h).amds_funcs.hCentralized macro list of AMD SMI APIs used by the component; generates function-pointer declarations/definitions so
amds.ccandlsym()them at runtime. Conditional entries handle newer SMI features.htable.hMinimal chained hash table for name→event mapping; used by
amds_evtapi.cto resolve native event names quickly.amds.hPublic, component-internal API across files: init/shutdown, native-event queries, context ops, and error-string retrieval.
Rules.amd_smiBuild integration for PAPI’s make system; compiles this component and sets include/library paths for AMD SMI.
Author Checklist
Why this PR exists. Reference all relevant information, including background, issues, test failures, etc
Commits are self contained and only do one thing
Commits have a header of the form:
module: short descriptionCommits have a body (whenever relevant) containing a detailed description of the addressed problem and its solution
The PR needs to pass all the tests