Make hsaKmtAllocMemory more compliant with the Thunk spec
Allocations from GPU nodes will return VRAM, not system memory.
Only non-paged allocation from GPU nodes is supported. System
memory can only be allocated from CPU nodes (usually node 0).
The HostAccess flag is no longer used to distinguish the memory
type. It only indicates, whether the memory is mapped for CPU
access.
Maintain compatibility with broken KfdTests by returning system
memory for paged-memory requested from GPU nodes.
Change-Id: I514defede735f55e6de436f41944125b6f2c4ccf
[ROCm/ROCR-Runtime commit: 887b32fe86]
This commit is contained in:
committed by
Gerrit Code Review
orang tua
8359dc3119
melakukan
03720306b9
@@ -132,30 +132,16 @@ hsaKmtAllocMemory(
|
||||
return HSAKMT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
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 (gpu_id == 0 && !MemFlags.ui32.Scratch) {
|
||||
*MemoryAddress = fmm_allocate_host(SizeInBytes, MemFlags);
|
||||
|
||||
if (*MemoryAddress == NULL)
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (!MemFlags.ui32.HostAccess && MemFlags.ui32.NonPaged && !MemFlags.ui32.Scratch) {
|
||||
if (gpu_id && MemFlags.ui32.NonPaged && !MemFlags.ui32.Scratch) {
|
||||
*MemoryAddress = fmm_allocate_device(gpu_id, SizeInBytes);
|
||||
|
||||
if (*MemoryAddress == NULL)
|
||||
@@ -172,6 +158,17 @@ hsaKmtAllocMemory(
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Backwards compatibility hack: Allocate system memory if app
|
||||
* asks for paged memory from a GPU node. */
|
||||
if (gpu_id && !MemFlags.ui32.NonPaged && !MemFlags.ui32.Scratch) {
|
||||
*MemoryAddress = fmm_allocate_host(SizeInBytes, MemFlags);
|
||||
|
||||
if (*MemoryAddress == NULL)
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return HSAKMT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user