libhsakmt: use the closest NUMA node to allocate queue ctx area
On NUMA system, allocate queue ctx save restore area on the closest NUMA
node to the GPU which the queue is going to run. This will improve
performance on NUMA system generally by reducing schedule latency and
fix the multi-node rccl-tests unstable performance issue.
If the closest NUMA node has no memory available, set flags NoNUMABind=1
to bypass mbind, to use default NUMA memory policy to allocate system
memory.
Change-Id: Ic62bfa5bb2efbf4f6ae79ff403e9610ddf18d45c
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
[ROCm/ROCR-Runtime commit: 59c857476f]
This commit is contained in:
@@ -424,6 +424,7 @@ void *allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align,
|
||||
HSAuint64 gpu_va;
|
||||
HsaMemFlags flags;
|
||||
HSAKMT_STATUS ret;
|
||||
HSAuint32 cpu_id = 0;
|
||||
|
||||
flags.Value = 0;
|
||||
flags.ui32.HostAccess = !DeviceLocal;
|
||||
@@ -431,11 +432,21 @@ void *allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align,
|
||||
flags.ui32.NonPaged = nonPaged;
|
||||
flags.ui32.PageSize = HSA_PAGE_SIZE_4KB;
|
||||
flags.ui32.CoarseGrain = DeviceLocal;
|
||||
flags.ui32.NoNUMABind = 1;
|
||||
|
||||
/* Get the closest cpu_id to GPU NodeId for system memory allocation
|
||||
* nonPaged=1 system memory allocation uses GTT path
|
||||
*/
|
||||
if (!DeviceLocal && !nonPaged) {
|
||||
cpu_id = get_direct_link_cpu(NodeId);
|
||||
if (cpu_id == INVALID_NODEID) {
|
||||
flags.ui32.NoNUMABind = 1;
|
||||
cpu_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
size = ALIGN_UP(size, align);
|
||||
|
||||
ret = hsaKmtAllocMemory(DeviceLocal ? NodeId : 0, size, flags, &mem);
|
||||
ret = hsaKmtAllocMemory(DeviceLocal ? NodeId : cpu_id, size, flags, &mem);
|
||||
if (ret != HSAKMT_STATUS_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user