Add agent query for nearest CPU agent
Add agent info query to return nearest CPU agent. This can be used to determine which CPU agent is in the same NUMA region as the GPU agent. Change-Id: I5400b4347ffbf4d2a836df31c4de443a38b0ecd1
이 커밋은 다음에 포함됨:
@@ -289,6 +289,8 @@ class GpuAgent : public GpuAgentInt {
|
||||
return current_coherency_type_;
|
||||
}
|
||||
|
||||
core::Agent* GetNearestCpuAgent(void) const;
|
||||
|
||||
// Getter & setters.
|
||||
|
||||
// @brief Returns Hive ID
|
||||
|
||||
@@ -391,6 +391,9 @@ hsa_status_t CpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
|
||||
case HSA_AMD_AGENT_INFO_DRIVER_UID:
|
||||
*((uint32_t*)value) = 0;
|
||||
break;
|
||||
case HSA_AMD_AGENT_INFO_NEAREST_CPU:
|
||||
((hsa_agent_t*)value)->handle = 0;
|
||||
break;
|
||||
default:
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
break;
|
||||
|
||||
@@ -1367,6 +1367,9 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
|
||||
case HSA_AMD_AGENT_INFO_DRIVER_UID:
|
||||
*((uint32_t*)value) = KfdGpuID();
|
||||
break;
|
||||
case HSA_AMD_AGENT_INFO_NEAREST_CPU:
|
||||
*((hsa_agent_t*)value) = GetNearestCpuAgent()->public_handle();
|
||||
break;
|
||||
default:
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
break;
|
||||
@@ -1985,18 +1988,7 @@ void GpuAgent::Trim() {
|
||||
}
|
||||
|
||||
void GpuAgent::InitNumaAllocator() {
|
||||
Agent* nearCpu = nullptr;
|
||||
uint32_t dist = -1u;
|
||||
for (auto cpu : core::Runtime::runtime_singleton_->cpu_agents()) {
|
||||
const core::Runtime::LinkInfo link_info =
|
||||
core::Runtime::runtime_singleton_->GetLinkInfo(node_id(), cpu->node_id());
|
||||
if (link_info.info.numa_distance < dist) {
|
||||
dist = link_info.info.numa_distance;
|
||||
nearCpu = cpu;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto pool : nearCpu->regions()) {
|
||||
for (auto pool : GetNearestCpuAgent()->regions()) {
|
||||
if (pool->kernarg()) {
|
||||
system_allocator_ = [pool](size_t size, size_t alignment,
|
||||
MemoryRegion::AllocateFlags alloc_flags) -> void* {
|
||||
@@ -2016,5 +2008,19 @@ void GpuAgent::InitNumaAllocator() {
|
||||
assert(false && "Nearest NUMA node did not have a kernarg pool.");
|
||||
}
|
||||
|
||||
core::Agent* GpuAgent::GetNearestCpuAgent() const {
|
||||
core::Agent* nearCpu = nullptr;
|
||||
uint32_t dist = -1u;
|
||||
for (auto cpu : core::Runtime::runtime_singleton_->cpu_agents()) {
|
||||
const core::Runtime::LinkInfo link_info =
|
||||
core::Runtime::runtime_singleton_->GetLinkInfo(node_id(), cpu->node_id());
|
||||
if (link_info.info.numa_distance < dist) {
|
||||
dist = link_info.info.numa_distance;
|
||||
nearCpu = cpu;
|
||||
}
|
||||
}
|
||||
return nearCpu;
|
||||
}
|
||||
|
||||
} // namespace amd
|
||||
} // namespace rocr
|
||||
|
||||
@@ -399,7 +399,12 @@ typedef enum hsa_amd_agent_info_s {
|
||||
* Queries for driver unique identifier.
|
||||
* The type of this attribute is uint32_t.
|
||||
*/
|
||||
HSA_AMD_AGENT_INFO_DRIVER_UID = 0xA112
|
||||
HSA_AMD_AGENT_INFO_DRIVER_UID = 0xA112,
|
||||
/**
|
||||
* Returns the hsa_agent_t of the nearest CPU agent
|
||||
* The type of this attribute is hsa_agent_t.
|
||||
*/
|
||||
HSA_AMD_AGENT_INFO_NEAREST_CPU = 0xA113
|
||||
} hsa_amd_agent_info_t;
|
||||
|
||||
/**
|
||||
|
||||
새 이슈에서 참조
사용자 차단