Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/rocr-runtime/libhsakmt/librocdxg.pc.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
prefix=${pcfiledir}/../../..
prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Expand Down
3 changes: 2 additions & 1 deletion projects/rocr-runtime/libhsakmt/src/dxg/openclose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,9 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtOpenKFD(void) {
return result;
dxcore_loader_failed:
#if defined(__linux__)
close(fd);
if (dxg_runtime->dxg_fd >= 0) close(dxg_runtime->dxg_fd);
#endif
dxg_runtime->dxg_fd = -1;
open_failed:

return result;
Expand Down
37 changes: 30 additions & 7 deletions projects/rocr-runtime/libhsakmt/src/dxg/topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,26 @@ HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id, HsaNodeProperties&
props.WaveFrontSize = device->WavefrontSize();
props.NumShaderBanks = device->NumShaderEngine();
props.NumArrays = device->ShaderArrayPerShaderEngine();
if (props.NumArrays == 0) {
pr_warn("NumArrays is 0 for node %u, forcing NumCUPerArray to 0\n",
node_id);
props.NumCUPerArray = 0;
} else {
props.NumCUPerArray = device->ComputeUnitCount() / props.NumArrays;
/* NumArrays counts shader arrays per shader engine, so the number of arrays
* on the whole GPU is NumShaderBanks * NumArrays.
*/
{
const uint32_t total_arrays = props.NumShaderBanks * props.NumArrays;
if (total_arrays == 0) {
pr_warn(
"NumShaderBanks(%u)*NumArrays(%u) is 0 for node %u, forcing "
"NumCUPerArray to 0\n",
props.NumShaderBanks, props.NumArrays, node_id);
props.NumCUPerArray = 0;
} else {
const uint32_t cu_count = device->ComputeUnitCount();
if (cu_count % total_arrays != 0)
pr_warn(
"ComputeUnitCount(%u) is not a multiple of the %u shader "
"arrays on node %u; NumCUPerArray is truncated\n",
cu_count, total_arrays, node_id);
props.NumCUPerArray = cu_count / total_arrays;
}
}
props.NumSIMDPerCU = simd_per_cu;
props.MaxSlotsScratchCU = device->MaxScratchSlotsPerCu();
Expand Down Expand Up @@ -950,7 +964,16 @@ HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id, HsaNodeProperties&
props.Domain = device->Domain();
props.UniqueID = device->Uuid();
props.NumXcc = device->NumXcc();
props.KFDGpuID = device->DeviceId(); // TODO
/*
* KFDGpuID is a nonzero snapshot-local key: not the PCI device ID, and not a
* kernel gpu_id, which only the native sysfs path supplies. Uniqueness and
* nonzeroness are all the DXG consumers require: a "node is a GPU" predicate
* and the gpuid<->nodeid lookups in this file. It becomes externally visible
* only through amd_core_dump.cpp, which writes it as the core dump's gpu_id,
* so a debugger correlating that field against kernel state will not match
* on WSL.
*/
props.KFDGpuID = node_id + 1;
props.FamilyID = device->GfxFamily();
props.LuidLowPart = device->GetLuid().LowPart;
props.LuidHighPart = device->GetLuid().HighPart;
Expand Down
Loading