diff --git a/src/header/TransferBench.hpp b/src/header/TransferBench.hpp index 8b635e2..5c16a78 100644 --- a/src/header/TransferBench.hpp +++ b/src/header/TransferBench.hpp @@ -7776,21 +7776,6 @@ static bool IsConfiguredGid(union ibv_gid const& gid) return HSA_STATUS_SUCCESS; }; - // Index CPU agents - hsa_init(); - std::map cpuAgentMap; - hsa_iterate_agents(cpuAgentCallback, &cpuAgentMap); - hsa_shut_down(); - - cpuAgents.clear(); - int numCpus = numa_num_configured_nodes(); - cpuAgents.resize(numCpus); - for (int i = 0; i < numCpus; i++) { - if (cpuAgentMap.count(i)) { - cpuAgents[i] = cpuAgentMap[i]; - } - } - // Index GPU agents int numGpus = 0; hipError_t status = hipGetDeviceCount(&numGpus); @@ -7803,6 +7788,19 @@ static bool IsConfiguredGid(union ibv_gid const& gid) gpuAgents.push_back(info.agentOwner); DeallocateMemory(MEM_GPU, tempBuffer, 1024); } + + // Index CPU agents (done after HIP initialization) + std::map cpuAgentMap; + hsa_iterate_agents(cpuAgentCallback, &cpuAgentMap); + + cpuAgents.clear(); + int numCpus = numa_num_configured_nodes(); + cpuAgents.resize(numCpus); + for (int i = 0; i < numCpus; i++) { + if (cpuAgentMap.count(i)) { + cpuAgents[i] = cpuAgentMap[i]; + } + } } #endif