Repository navigation
Conversation
Factor GPU/CPU agent discovery behind a polymorphic TopologyProvider
interface so the existing Linux/KFD path is preserved verbatim while
WSL and native Windows gain dedicated backends.
- topology/linux_kfd_provider: byte-identical move of read_topology()
and its helpers (parse_cpu_info, read_map, read_property, etc.) out
of agent.cpp. Linux behaviour is unchanged.
- topology/dxg_provider: WSL backend skeleton. Dlopens libdxcore.so
and probes CreateDXCoreAdapterFactory; full DXCore-to-agent
enumeration is left as a follow-up.
- topology/d3dkmt_provider: native Windows backend skeleton. All
D3DKMT calls are #ifdef _WIN32 guarded so the class still links on
Linux (stubs return empty + warning). The full enumeration body
is left as a follow-up.
- topology/topology_provider: factory make_default_provider() with
runtime selection precedence:
ROCPROFILER_FORCE_DXG -> ROCPROFILER_FORCE_D3DKMT -> sysfs ->
libdxcore.so loadable -> _WIN32 -> LinuxKfd fallback.
The ROCPROFILER_FORCE_* env vars are new and intended for triage.
- agent.cpp: read_topology() and its helpers deleted. The singleton
accessor and internal_refresh_topology() now go through the
provider. No other public function changed.
- agent_internal.hpp: minimal forward declaration of
update_agent_runtime_visibility so providers can call it without
touching the public header.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a TopologyProvider abstraction to decouple agent (CPU/GPU) discovery from agent.cpp, preserving the existing Linux/KFD enumeration while adding skeleton backends for WSL (DXCore) and native Windows (D3DKMT).
Changes:
- Adds a polymorphic
TopologyProviderinterface and a runtime-selected factory (make_default_provider()). - Moves the existing Linux/KFD sysfs topology parsing/enumeration into
LinuxKfdProvider(verbatim refactor). - Introduces WSL (
DxgProvider) and Windows (D3dkmtProvider) backend skeletons and routesagent.cpptopology refresh through the provider.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/topology/topology_provider.hpp | Defines the provider interface, unique_agent_t, and documents selection precedence. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/topology/topology_provider.cpp | Implements provider selection (make_default_provider) based on env/filesystem probes. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/topology/linux_kfd_provider.hpp | Declares the Linux/KFD provider implementation. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/topology/linux_kfd_provider.cpp | Contains the extracted Linux/KFD sysfs parsing + agent materialization logic. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/topology/dxg_provider.hpp | Declares the WSL/DXCore provider skeleton and availability probe. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/topology/dxg_provider.cpp | Implements libdxcore probing via dlopen/dlsym and a TODO enumerator. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/topology/d3dkmt_provider.hpp | Declares the Windows D3DKMT provider skeleton and helper stubs. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/topology/d3dkmt_provider.cpp | Provides Windows/non-Windows stub implementations and logging. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/topology/CMakeLists.txt | Adds topology sources/headers to the object library build. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/CMakeLists.txt | Adds the new topology/ subdirectory to the library build. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/agent.cpp | Removes embedded topology enumeration and routes through TopologyProvider. |
| projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/agent_internal.hpp | Introduces an internal declaration for update_agent_runtime_visibility() for providers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+7
to
+9
| set(ROCPROFILER_TOPOLOGY_SOURCES topology_provider.cpp linux_kfd_provider.cpp | ||
| dxg_provider.cpp d3dkmt_provider.cpp) | ||
|
|
Comment on lines
+57
to
+82
| } // namespace | ||
|
|
||
| std::unique_ptr<TopologyProvider> | ||
| make_default_provider() | ||
| { | ||
| const bool force_dxg = common::get_env("ROCPROFILER_FORCE_DXG", false); | ||
| const bool force_d3dkmt = common::get_env("ROCPROFILER_FORCE_D3DKMT", false); | ||
|
|
||
| if(force_dxg) | ||
| { | ||
| ROCP_INFO << "TopologyProvider: forced DxgProvider via ROCPROFILER_FORCE_DXG"; | ||
| return std::make_unique<DxgProvider>(); | ||
| } | ||
| if(force_d3dkmt) | ||
| { | ||
| ROCP_INFO << "TopologyProvider: forced D3dkmtProvider via ROCPROFILER_FORCE_D3DKMT"; | ||
| return std::make_unique<D3dkmtProvider>(); | ||
| } | ||
| if(sysfs_topology_present()) | ||
| { | ||
| ROCP_INFO << "TopologyProvider: selected LinuxKfdProvider (sysfs present)"; | ||
| return std::make_unique<LinuxKfdProvider>(); | ||
| } | ||
| if(DxgProvider::is_available()) | ||
| { | ||
| ROCP_INFO << "TopologyProvider: selected DxgProvider (libdxcore.so present)"; |
Comment on lines
+109
to
+113
| while(std::getline(ifs, line)) | ||
| { | ||
| if(ifs.eof()) | ||
| { | ||
| if(!current_block.empty()) blocks.emplace_back(std::move(current_block)); |
Fixes probe_libdxcore() to look up D3DKMTEnumAdapters3 (the symbol actually called) instead of CreateDXCoreAdapterFactory. Fills in DxgProvider::enumerate() using D3DKMTEnumAdapters3 + D3DKMTQueryAdapterInfo (PHYSICALADAPTERDEVICEIDS, ADAPTERADDRESS, ADAPTERREGISTRYINFO, GETSEGMENTSIZE). Filters AMD adapters only, packs PCI BDF into location_id, converts wide adapter names to UTF-8, and closes every adapter handle. Fields DXCore cannot supply (gfx_target_version, CU/SDMA counts, mem_banks/caches/io_links) are left zero/empty rather than fabricated. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Contributor
Author
|
Superseded by #6399 |
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.
Factor GPU/CPU agent discovery behind a polymorphic TopologyProvider interface so the existing Linux/KFD path is preserved verbatim while WSL and native Windows gain dedicated backends.
Motivation
Technical Details
JIRA ID
Test Plan
Test Result
Submission Checklist