diff --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp --- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp +++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp @@ -2620,13 +2620,20 @@ void *Ptr = NULL; assert(DeviceId < DeviceInfo().NumberOfDevices && "Device ID too large"); - if (Kind != TARGET_ALLOC_DEFAULT) { + hsa_amd_memory_pool_t MemoryPool; + switch (Kind) { + case TARGET_ALLOC_DEFAULT: + MemoryPool = DeviceInfo().getDeviceMemoryPool(DeviceId); + break; + case TARGET_ALLOC_HOST: + MemoryPool = DeviceInfo().getHostMemoryPool(); + break; + default: REPORT("Invalid target data allocation kind or requested allocator not " "implemented yet\n"); return NULL; } - hsa_amd_memory_pool_t MemoryPool = DeviceInfo().getDeviceMemoryPool(DeviceId); hsa_status_t Err = hsa_amd_memory_pool_allocate(MemoryPool, Size, 0, &Ptr); DP("Tgt alloc data %ld bytes, (tgt:%016llx).\n", Size, (long long unsigned)(Elf64_Addr)Ptr); @@ -2677,6 +2684,10 @@ int32_t __tgt_rtl_data_delete(int DeviceId, void *TgtPtr) { assert(DeviceId < DeviceInfo().NumberOfDevices && "Device ID too large"); + + // TgtPtr is either a TARGET_ALLOC_DEFAULT or a TARGET_ALLOC_HOST, either way + // code::runtime::Memfree can handle it + hsa_status_t Err; DP("Tgt free data (tgt:%016llx).\n", (long long unsigned)(Elf64_Addr)TgtPtr); Err = core::Runtime::Memfree(TgtPtr);