Repository navigation
Reapply "feat(hipfile): Add getStats functions to public api (#8252)"… - #9584
Conversation
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
There was a problem hiding this comment.
Pull request overview
This PR reintroduces the hipFile Stats API that had been temporarily reverted, restoring the public API surface and updating the API trace dispatch/ABI enforcement so CI (including TheRock) can validate the updated dispatch table.
Changes:
- Re-adds the public Stats API types and entrypoints (
hipFileGetStatsL1/L2/L3) tohipfile.h. - Implements
hipFileGetStatsL1/L2/L3in the runtime and wires the functions into the API trace dispatch table (including ABI offset/version enforcement). - Adds/extends tests to validate dispatch table population and Stats aggregation behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/hipfile/test/amd_detail/hipfile-api.cpp | Adds integration-style tests for the new Stats API levels and aggregation logic. |
| projects/hipfile/test/amd_detail/api_trace.cpp | Extends dispatch table test coverage to include Stats function pointers. |
| projects/hipfile/src/amd_detail/hipfile.cpp | Implements hipFileGetStatsL1/L2/L3 and derives basic latency/bandwidth fields. |
| projects/hipfile/src/amd_detail/api_trace/api-trace.cpp | Wires Stats functions into the dispatch table and updates ABI enforcement indices/versioning. |
| projects/hipfile/src/amd_detail/api_trace/api-trace-internal.h | Declares internal runtime entrypoints for Stats functions. |
| projects/hipfile/src/amd_detail/api_trace/api-dispatch-interface.cpp | Adds public C API wrappers that call through the dispatch table for Stats functions. |
| projects/hipfile/include/hipfile.h | Adds the public Stats API structs, constants, and function declarations. |
| projects/hipfile/include/hipfile-api-trace.h | Bumps dispatch table step version and adds Stats function pointer types/slots. |
Suppressed comments (1)
projects/hipfile/src/amd_detail/hipfile.cpp:722
- hipFileGetStatsL3 returns hipFileInternalError when the stats server is unavailable, but it returns without clearing the output struct. Clearing
*statsimmediately after the nullptr check avoids callers observing stale fields when the query fails.
if (stats == nullptr) {
return {hipFileInvalidValue, hipSuccess};
}
const Stats *s{Context<IStatsServer>::get()->getStats()};
if (s == nullptr) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hipFile appended pfn_hipfile_get_stats_l1/l2/l3 to hipFileDispatchTable (indices 31-33, STEP_VERSION 1). Update the rocprofiler-sdk side to match so the profiler builds against both the real and vendored headers: - abi.cpp: bump ROCP_SDK_ENFORCE_ABI_VERSIONING 31 -> 34 and add offset asserts for the three new stats entries. - details/hipfile_api_trace.h: bump STEP_VERSION to 1; add the PfnHipFile GetStatsL1/L2/L3 typedefs and dispatch-table members. - details/hipfile.h: port the stats prerequisites the typedefs reference (HIPFILE_MAX_GPUS, HIPFILE_GPU_UUID_LEN, hipFileOpCounter_t, hipFile StatsLevel1/2/3_t, hipFilePerGpuStats_t, and the hipFileGetStats* prototypes). Without the vendored-header updates, a standalone build (ROCPROFILER_SDK_USE_SYSTEM_HIPFILE=0) fails to compile abi.cpp. Verified that both USE_SYSTEM_HIPFILE=1 and =0 compile, and that the vendored and real hipFileDispatchTable layouts are byte-identical (size 280; stats members at offsets 256/264/272).
8b419ef to
2f68b29
Compare
`writes_bytes` is a cuFile typo. We don't need to preserve that.
hipFileStatsLevel3.per_gpu_stats is indexed by GPU ordinal (not packed) and num_gpus is a count, not the max index, so a 0..num_gpus-1 loop skips active GPUs. Document this in both the public header and the profiler's vendored copy. Comment-only; no layout or ABI change.
jrmadsen
left a comment
There was a problem hiding this comment.
We need to add tracing support for these functions in rocprofiler-sdk too.
jbonnell-amd
left a comment
There was a problem hiding this comment.
Approved for the .github/* changes
|
@venkat1361 i think this is good to go as soon as there is an answer to why the absence of stringify support didn't cause a compilation error. In theory, it should have caused a compilation error |
jrmadsen
left a comment
There was a problem hiding this comment.
@venkat1361 I'm approving so you can proceed once you've made the changes I noted in this review. While your changes weren't necessarily wrong, to an unfamiliar developer, the compiler error that would result from your changes would be very hard to understand. The static_assert pattern I recommended makes it a lot easier on those developers.
|
Will merge given code owner approval and the author's note that
The TheRock CI failures are only known infra issues, unrelated to this additive hipfile getStats public-API change (host-side metadata query; it does not alter code-object generation or module loading):
|
(#8252)" (#9260) This reverts commit 3aabde92853d1318d317e8457663e6a275353221. [rocm-systems] ROCm/rocm-systems#9584 (commit bcc63b3)
`writes_bytes` is a cuFile typo. We don't need to preserve that. [rocm-systems] ROCm/rocm-systems#9584 (commit bcc63b3)
stats hipFileStatsLevel3.per_gpu_stats is indexed by GPU ordinal (not packed) and num_gpus is a count, not the max index, so a 0..num_gpus-1 loop skips active GPUs. Document this in both the public header and the profiler's vendored copy. Comment-only; no layout or ABI change. [rocm-systems] ROCm/rocm-systems#9584 (commit bcc63b3)
TheRock Submodule Bump ActivityNewest first
|
## Motivation <!-- Explain the purpose of this PR and the goals it aims to achieve. --> ROCm Systems Profiler should be able to provide storage telemetry - letting users correlate file/buffer registrations, read/write throughput, fast-path vs. fallback usage, and I/O errors with GPU and application activity in a single Perfetto trace or RocPD database. This is increasingly important for GPU-direct storage workloads where the storage path is a common performance bottleneck that was previously invisible in the profiler. Depends on: - [x] #8252 - [x] #9584 - [x] #10548 - [x] ROCm/TheRock#7982 Todo: - [x] Ensure version gating for hipFile public API on 0.5.0? ## Technical Details <!-- Explain the changes along with any relevant GitHub links. --> - **hipFile backend wrapper** (`source/lib/backends/hipfile/`) - Thin policy seam around `hipFileGetStatsL3`; isolates the profiler from hipFile's C API and enables mock-based unit tests. - **PMC collector** (`library/pmc/collectors/hipfile/`) - Snapshots hipFile's per-GPU stats on the process-sampling thread and stores the whole snapshot as a single typed `hipfile_pmc_sample` per GPU per poll. - **Trace-cache sample type (`source/lib/core/trace_cache/`) - Adding the typed sample follows the existing `gpu_pmc_sample` / `ainic_pmc_sample` pattern and uses the shared plumbing. - **Metric groups and defaults** - `ROCPROFSYS_HIPFILE_METRICS` selects read/write pairs by group (`fastpath`, `fallback`, `bandwidth`, `bytes`, `ops`, `unaligned`, `errors`, or `all`/`none`). - Defaults to `fastpath, fallback, bandwidth, bytes, errors` so traces focus on path usage and transfer rate without collecting every counter. - `ROCPROFSYS_HIPFILE_METRICS=none` skips device enumeration.` - **Build-time and runtime gating** - `ROCPROFSYS_BUILD_HIPFILE` is tri-state `AUTO` / `ON` / `OFF` (default `AUTO`). - `cmake/Packages.cmake` sets a derived INTERNAL `ROCPROFSYS_HIPFILE_SUPPORT` (AINIC-style) and never shadows the user cache: AUTO + missing/too-old package → disable, STATUS ON + missing/too-old package → FATAL_ERROR (version found, version required, hipfile_DIR / CMAKE_PREFIX_PATH) OFF → never search - `ROCPROFSYS_USE_HIPFILE` (env/config, default OFF) enables collection at run time; zero overhead when disabled or when the target does not use hipFile. - The backend compiles against `hipfile.h` but does not link `libhipfile`. `wrapper.hpp` resolves the two entry points it uses (`hipFileGetVersion`, `hipFileGetStatsL3`) with `dlopen`/`dlsym` at first sample. - Consequently `libhipfile.so.0` is not required for the profiler to start. Absent library, missing stats API (`hipFile` 0.4 reuses SONAME .so.0), or a too-old reported version all degrade to a warning and no hipFile tracks. - **Runtime guards** - Does not set `HIPFILE_STATS_LEVEL` (hipFile already defaults to 1). `USE_HIPFILE=ON` with `HIPFILE_STATS_LEVEL=0`, or with `USE_PROCESS_SAMPLING=OFF`, logs a warning and produces no hipFile tracks. - **Version checks** - Requires hipFile 0.5.0+ at build time (for `hipFileGetStatsL3`) and re-checks the loaded `libhipfile` at run time; logs a warning and skips collection if the runtime is too old. - **Example workload and validation** - `examples//hipfile/hipfile-io.cpp` runs a short read/write loop for telemetry validation. - `hipfile-io` is skipped when `ROCPROFSYS_HIPFILE_SUPPORT` is off - `tests/pytest/test_hipfile_telemetry.py` plus RocPD/Perfetto validation rules under `tests/rocpd-validation-rules/hipfile-telemetry/`. - **Documentation and changelog** - How-to: `docs/how-to/hipfile-telemetry.rst` (build/run settings, metric interpretation, linking contract, troubleshooting). - CHANGELOG entry under the unreleased 1.9.0 section. - **Follow-up for future** - Expose remaining hipFile telemetry that is already collected but not shown to the user. - Emit process-scoped file/buffer registration counters on a process track (as the CPU collector does), if useful. - Add `rocprof-sys-avail` reporting of which hipFile metrics can be collected. - Add a `--hipfile[=metrics]` domain flag so storage telemetry composes with existing presets (do not enable hipFile inside `trace-gpu` / `--gpu`; no dedicated storage preset until that flag exists). - When hipFile fills per-slot UUID (AIHIPFILE-272), join those to SDK agents (same as AMD SMI) so permutations/HIP_VISIBLE_DEVICES UUID lists map correctly without parsing the env var. ## Issue Tracking <!-- Include a GitHub Issue and/or JIRA ID. Do not post any full JIRA links here. --> <!-- GitHub issue: #1234 --> <!-- JIRA ID: EXAMPLECOMPONENT-1234 --> JIRA ID: AIPROFSYST-710 ## Test Plan <!-- Explain any relevant testing done to verify this PR. --> - [ ] Unit tests: `hipfile-backend-tests`, `pmc-hipfile-collector-tests` - [ ] Integration: `ctest -R hipfile` / `pytest tests/pytest/test_hipfile_telemetry.py` (requires GPU + hipFile build) - [ ] Manual: profile a hipFile workload with `ROCPROFSYS_USE_HIPFILE=ON` and confirm `hipFile GPU<N> <metric>` tracks in Perfetto/RocPD ## Test Result <!-- Briefly summarize test outcomes. --> <img width="4062" height="952" alt="image" src="https://github.com/user-attachments/assets/db32f269-ad9e-4649-a958-807e72b604e7" /> <img width="4624" height="1164" alt="image" src="https://github.com/user-attachments/assets/d137757a-c3e9-4e4d-8ac8-b8201c57f6ea" /> ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md. --------- Signed-off-by: David Galiffi <David.Galiffi@amd.com> Co-authored-by: David Galiffi <David.Galiffi@amd.com>



Motivation
The hipFile stats API was temporarily reverted when TheRock CI failed due to issues with the profiler SDK, which includes a vendored version of hipfile.h that was not updated.
Technical Details
This reverts commit 3aabde9. This restores commit a3c059c, which added the hipFile Stats API.
This PR includes the necessary ABI checks that will be necessary for TheRock CI to pass.
Issue Tracking
JIRA ID : AIHIPFILE-240
Test Plan
CI passes
Test Result
Success
Submission Checklist