fix(rocprofiler-sdk): emit CPU agents from the WSL topology enumerator - #11423
Open
ChrisLundquist wants to merge 1 commit into
Open
fix(rocprofiler-sdk): emit CPU agents from the WSL topology enumerator#11423ChrisLundquist wants to merge 1 commit into
ChrisLundquist wants to merge 1 commit into
Conversation
The wsl-dxcore enumerator only walks display adapters, so it emits GPU agents and nothing else. construct_agent_cache() pairs the HSA runtime's agents with ours by logical_node_id, and HSA reports one CPU agent per NUMA node ahead of the GPUs. Emitting GPUs alone therefore breaks the mapping twice over: the counts never match, and the GPUs land on node ids the runtime handed to CPUs. On a single-GPU WSL2 system that is fatal: F agent.cpp:706] Found 1 rocprofiler agents and 2 HSA agents. HSA agents contained 1 internal node ids not found by rocprofiler: 1 which aborts every rocprofv3 invocation before the target runs. Enumerate the host CPU agents from /sys/devices/system/node first, one per NUMA node with cpu_cores_count taken from the node's cpulist, then continue GPU node numbering from there — the same ordering the gnulinux enumerator produces from the KFD topology. logical_node_type_id keeps a separate per-type counter so GPUs are still numbered from 0 within their type. CPU emission happens before the adapter queries so that a topology that fails to find its GPUs still accounts for the agents HSA reports. Validated on WSL2 with an RX 9070 XT (gfx1201), ROCm 7.2: before: Found 1 rocprofiler agents and 2 HSA agents -> SIGABRT (134) after: agent node maps: 2 -> exit 0 rocprofv3 --kernel-trace --hip-trace now completes and records both agents (CPU absolute_index 0, GPU absolute_index 1) along with the kernel dispatches. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01951qQBesgNWcb8t9rZf1b3
❌ PR Check — Action Required
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🚫 Please fix the failed policies before requesting reviews. The following policy checks failed:
The |
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.
Problem
The
wsl-dxcoretopology enumerator (platform/wsl/agent.cpp) walks display adapters viaD3DKMTEnumAdapters3, so it emitsROCPROFILER_AGENT_TYPE_GPUagents and nothing else.construct_agent_cache()pairs the HSA runtime's agents with rocprofiler's bylogical_node_id, and HSA reports one CPU agent per NUMA node ahead of the GPUs. Emitting GPUs alone breaks that mapping twice over:On a single-GPU WSL2 system this is fatal — every
rocprofv3invocation aborts before the target process runs:Shifting the GPU numbering by one does not fix it; it just moves the unmatched node from 1 to 0. The missing agent is the CPU.
Fix
Enumerate the host CPU agents from
/sys/devices/system/nodefirst — one per NUMA node, withcpu_cores_countparsed from that node'scpulistandsimd_count = 0— then continue GPU node numbering from there. This is the same ordering thegnulinuxenumerator produces from the KFD topology.Details:
logical_node_type_idnow uses a separate per-type counter, so GPUs are still numbered from 0 within their type whilelogical_node_idspans both types.D3DKMTEnumAdapters3) still accounts for the CPU agents HSA reports rather than returning an empty topology into the same fatal.cpulistis unreadable or empty are skipped; if no usable NUMA node is found at all, a warning is logged and behaviour is unchanged from today.Validation
WSL2, Radeon RX 9070 XT (gfx1201), ROCm 7.2, built from this branch and run via
rocprofv3 --rocm-root=<local prefix>:developFound 1 rocprofiler agents and 2 HSA agents ... not found by rocprofiler: 1# agent node maps: 2With the fix,
rocprofv3 --kernel-trace --hip-tracecompletes and the results database contains both agents and the dispatches:Also verified the GPU program's own output is still correct under the profiler, and that
clang-formatv11 (the versionrocprofiler_formatting.cmakerequires) reports no changes.This is Linux/WSL-only and touches no code path reachable when
platform::gnulinux::is_available()is true, which is every non-WSL Linux system.🤖 Generated with Claude Code
https://claude.ai/code/session_01951qQBesgNWcb8t9rZf1b3