From 55bd82cd8961d942ad33a0b47ccf62102d5654eb Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Wed, 21 Oct 2015 20:00:01 -0400 Subject: [PATCH] Fix node 0 system memory allocation for dGPU This is a hack to allow the Runtime to allocate system memory with PreferredNode=0 on a dGPU system. We allocated it from Node 1 instead so that the node 1 GPU can map the memory. A proper fix will be implemented together with multi-GPU support. Change-Id: Ieb52599e5275781c04ee34405ea850bf782c523a [ROCm/ROCR-Runtime commit: 590c8e522cad5e98a687a46c26fd27fd8b226563] --- projects/rocr-runtime/src/memory.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/projects/rocr-runtime/src/memory.c b/projects/rocr-runtime/src/memory.c index e42848db45..3314c82195 100644 --- a/projects/rocr-runtime/src/memory.c +++ b/projects/rocr-runtime/src/memory.c @@ -133,6 +133,21 @@ hsaKmtAllocMemory( } if (MemFlags.ui32.HostAccess && !MemFlags.ui32.NonPaged && !MemFlags.ui32.Scratch) { + if (gpu_id == 0 && PreferredNode == 0) { + /* HACK: Currently we need a GPU node for + * system memory allocations on dGPUs and + * MapMemoryToGPU will always map to the same + * GPU used for allocation. Therefore we need + * to allocate system memory from node 1 if + * we're running on a dGPU (indicated by node + * 0 being a CPU with gpu_id==0). This will be + * cleaned up when multi-GPU support is + * implemented. */ + PreferredNode = 1; + result = validate_nodeid(PreferredNode, &gpu_id); + if (result != HSAKMT_STATUS_SUCCESS) + return result; + } *MemoryAddress = fmm_allocate_host(gpu_id, SizeInBytes, MemFlags, get_device_id_by_node(PreferredNode)); if (*MemoryAddress == NULL)