Adding support for mGPU
Change-Id: I5ed184e6a58b38d9dde48867f14513d161cf41a9
Signed-off-by: Ben Goz <ben.goz@amd.com>
[ROCm/ROCR-Runtime commit: ea0f9d2a0b]
This commit is contained in:
@@ -187,7 +187,8 @@ static void* allocate_exec_aligned_memory_cpu(uint32_t size, uint32_t align)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align, uint32_t NodeId)
|
||||
void* allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align,
|
||||
uint32_t NodeId, bool peer_to_peer)
|
||||
{
|
||||
void *mem;
|
||||
HSAuint64 gpu_va;
|
||||
@@ -205,6 +206,14 @@ void* allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align, uint32_t N
|
||||
if (ret != HSAKMT_STATUS_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (peer_to_peer) {
|
||||
if (hsaKmtRegisterMemory(mem, size) != HSAKMT_STATUS_SUCCESS) {
|
||||
hsaKmtFreeMemory(mem, size);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (hsaKmtMapMemoryToGPU(mem, size, &gpu_va) != HSAKMT_STATUS_SUCCESS) {
|
||||
hsaKmtFreeMemory(mem, size);
|
||||
return NULL;
|
||||
@@ -220,6 +229,7 @@ void free_exec_aligned_memory_gpu(void *addr, uint32_t size, uint32_t align)
|
||||
if (hsaKmtUnmapMemoryToGPU(addr) == HSAKMT_STATUS_SUCCESS) {
|
||||
hsaKmtFreeMemory(addr, size);
|
||||
}
|
||||
hsaKmtDeregisterMemory(addr);
|
||||
}
|
||||
|
||||
static void* allocate_exec_aligned_memory(uint32_t size,
|
||||
@@ -228,7 +238,7 @@ static void* allocate_exec_aligned_memory(uint32_t size,
|
||||
uint32_t NodeId)
|
||||
{
|
||||
if (IS_DGPU(type))
|
||||
return allocate_exec_aligned_memory_gpu(size, TONGA_PAGE_SIZE, NodeId);
|
||||
return allocate_exec_aligned_memory_gpu(size, TONGA_PAGE_SIZE, NodeId, false);
|
||||
return allocate_exec_aligned_memory_cpu(size, align);
|
||||
}
|
||||
|
||||
@@ -236,6 +246,7 @@ static void release_exec_aligned_memory_gpu(void *addr, uint32_t size)
|
||||
{
|
||||
if (hsaKmtUnmapMemoryToGPU(addr) == HSAKMT_STATUS_SUCCESS)
|
||||
hsaKmtFreeMemory(addr, (HSAuint64)size);
|
||||
hsaKmtDeregisterMemory(addr);
|
||||
}
|
||||
|
||||
static void release_exec_aligned_memory(void *addr, uint32_t size, enum asic_family_type type)
|
||||
|
||||
Reference in New Issue
Block a user