Skip to content

Commit 7c36c20

Browse files
committed
SWDEV-548034 - Log correct numa node on host alloc
1 parent d79ebea commit 7c36c20

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

projects/clr/rocclr/device/device.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ class Device : public RuntimeObject {
18031803
*/
18041804
virtual void* hostAlloc(size_t size, size_t alignment,
18051805
MemorySegment mem_seg = kNoAtomics,
1806-
const void* agentInfo = nullptr) const {
1806+
const void* agent_info = nullptr) const {
18071807
ShouldNotCallThis();
18081808
return NULL;
18091809
}

projects/clr/rocclr/device/rocm/rocdevice.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ hsa_status_t Device::iterateAgentCallback(hsa_agent_t agent, void* data) {
307307
}
308308

309309
if (dev_type == HSA_DEVICE_TYPE_CPU) {
310-
AgentInfo info = {agent, {0}, {0}, {0}};
310+
AgentInfo info = {agent, {0}, {0}, {0}, {0}, static_cast<uint32_t>(cpu_agents_.size())};
311311
stat = Hsa::agent_iterate_memory_pools(agent, Device::iterateCpuMemoryPoolCallback,
312312
reinterpret_cast<void*>(&info));
313313
if (stat == HSA_STATUS_SUCCESS) {
@@ -2014,21 +2014,23 @@ hsa_amd_memory_pool_t Device::getHostMemoryPool(MemorySegment mem_seg,
20142014

20152015
// ================================================================================================
20162016
void* Device::hostAlloc(size_t size, size_t alignment, MemorySegment mem_seg,
2017-
const void* agentInfo) const {
2017+
const void* agent_info) const {
20182018
void* ptr = nullptr;
20192019
uint32_t memFlags = 0;
20202020
if (mem_seg == kKernArg) {
20212021
memFlags |= HSA_AMD_MEMORY_POOL_EXECUTABLE_FLAG;
20222022
}
2023-
2024-
hsa_amd_memory_pool_t pool =
2025-
getHostMemoryPool(mem_seg, static_cast<const amd::roc::AgentInfo*>(agentInfo));
2023+
auto cpu_agent_info = static_cast<const amd::roc::AgentInfo*>(agent_info);
2024+
if (cpu_agent_info == nullptr) {
2025+
cpu_agent_info = cpu_agent_info_;
2026+
}
2027+
hsa_amd_memory_pool_t pool = getHostMemoryPool(mem_seg, cpu_agent_info);
20262028
hsa_status_t stat = Hsa::memory_pool_allocate(pool, size, memFlags, &ptr);
20272029

20282030
ClPrint(amd::LOG_DEBUG, amd::LOG_MEM,
20292031
"Allocate hsa host memory %p, size 0x%zx,"
2030-
" numa_node = %d, mem_seg = %d",
2031-
ptr, size, preferred_numa_node_, static_cast<int>(mem_seg));
2032+
" numa_node = %u, mem_seg = %d",
2033+
ptr, size, cpu_agent_info->id, static_cast<int>(mem_seg));
20322034
if (stat != HSA_STATUS_SUCCESS) {
20332035
LogPrintfError("Fail allocation host memory with err %d", stat);
20342036
return nullptr;

projects/clr/rocclr/device/rocm/rocdevice.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ struct AgentInfo {
325325
hsa_amd_memory_pool_t coarse_grain_pool;
326326
hsa_amd_memory_pool_t kern_arg_pool;
327327
hsa_amd_memory_pool_t ext_fine_grain_pool;
328+
uint32_t id;
328329
};
329330

330331
//! A HSA device ordinal (physical HSA device)
@@ -418,7 +419,7 @@ class Device : public NullDevice {
418419
virtual bool globalFreeMemory(size_t* freeMemory) const override;
419420
virtual void* hostAlloc(size_t size, size_t alignment,
420421
MemorySegment mem_seg = MemorySegment::kNoAtomics,
421-
const void* agentInfo = nullptr) const override; // nullptr uses default CPU agent
422+
const void* agent_info = nullptr) const override; // nullptr uses default CPU agent
422423
virtual void hostFree(void* ptr, size_t size = 0) const override;
423424

424425
virtual bool amdFileRead(amd::Os::FileDesc handle, void* devicePtr, uint64_t size, int64_t file_offset,

projects/clr/rocclr/device/rocm/rocvirtual.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void Timestamp::checkGpuTime() {
166166

167167
ClPrint(amd::LOG_INFO, amd::LOG_TS,
168168
"Signal = (0x%lx), Translated start/end = %ld / %ld, Elapsed = %ld ns, "
169-
"ticks start/end = %ld / %ld, Ticks elapsed = %ld, Engine = %u",
169+
"ticks start/end = %ld / %ld, Ticks elapsed = %ld, Engine Type = %u",
170170
it->signal_.handle, time.start, time.end, time.end - time.start,
171171
amdSignal->start_ts, amdSignal->end_ts, amdSignal->end_ts - amdSignal->start_ts,
172172
it->engine_);

0 commit comments

Comments
 (0)