diff --git a/openmp/libomptarget/plugins/amdgpu/impl/data.cpp b/openmp/libomptarget/plugins/amdgpu/impl/data.cpp --- a/openmp/libomptarget/plugins/amdgpu/impl/data.cpp +++ b/openmp/libomptarget/plugins/amdgpu/impl/data.cpp @@ -39,20 +39,16 @@ } } // namespace -hsa_status_t register_allocation(void *ptr, size_t size, - atmi_devtype_t DeviceType) { - if (DeviceType == ATMI_DEVTYPE_CPU) - return allow_access_to_all_gpu_agents(ptr); - else - return HSA_STATUS_SUCCESS; -} - hsa_status_t Runtime::DeviceMalloc(void **ptr, size_t size, int DeviceId) { return Runtime::Malloc(ptr, size, DeviceId, ATMI_DEVTYPE_GPU); } hsa_status_t Runtime::HostMalloc(void **ptr, size_t size) { - return Runtime::Malloc(ptr, size, 0, ATMI_DEVTYPE_CPU); + hsa_status_t Err = Runtime::Malloc(ptr, size, 0, ATMI_DEVTYPE_CPU); + if (Err == HSA_STATUS_SUCCESS) { + Err = core::allow_access_to_all_gpu_agents(*ptr); + } + return Err; } hsa_status_t Runtime::Malloc(void **ptr, size_t size, int DeviceId, @@ -62,11 +58,6 @@ hsa_status_t err = hsa_amd_memory_pool_allocate(pool, size, 0, ptr); DEBUG_PRINT("Malloced [%s %d] %p\n", DeviceType == ATMI_DEVTYPE_CPU ? "CPU" : "GPU", DeviceId, *ptr); - - if (err == HSA_STATUS_SUCCESS) { - err = register_allocation(*ptr, size, DeviceType); - } - return (err == HSA_STATUS_SUCCESS) ? HSA_STATUS_SUCCESS : HSA_STATUS_ERROR; } diff --git a/openmp/libomptarget/plugins/amdgpu/impl/internal.h b/openmp/libomptarget/plugins/amdgpu/impl/internal.h --- a/openmp/libomptarget/plugins/amdgpu/impl/internal.h +++ b/openmp/libomptarget/plugins/amdgpu/impl/internal.h @@ -197,9 +197,6 @@ alignDown((intptr_t)(value + alignment - 1), alignment)); } -hsa_status_t register_allocation(void *addr, size_t size, - atmi_devtype_t DeviceType); - extern bool atl_is_atmi_initialized(); bool handle_group_signal(hsa_signal_value_t value, void *arg); diff --git a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp --- a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp +++ b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp @@ -144,16 +144,6 @@ namespace core { -hsa_status_t allow_access_to_all_gpu_agents(void *ptr) { - std::vector &gpu_procs = - g_atl_machine.processors(); - std::vector agents; - for (uint32_t i = 0; i < gpu_procs.size(); i++) { - agents.push_back(gpu_procs[i].agent()); - } - return hsa_amd_agents_allow_access(agents.size(), &agents[0], NULL, ptr); -} - // Implement memory_pool iteration function static hsa_status_t get_memory_pool_info(hsa_amd_memory_pool_t memory_pool, void *data) { @@ -937,11 +927,6 @@ DEBUG_PRINT("Symbol %s = %p (%u bytes)\n", name, (void *)info.addr, info.size); - err = register_allocation(reinterpret_cast(info.addr), - (size_t)info.size, ATMI_DEVTYPE_GPU); - if (err != HSA_STATUS_SUCCESS) { - return err; - } SymbolInfoTable[std::string(name)] = info; free(name); } else { 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 @@ -2118,3 +2118,11 @@ } return OFFLOAD_SUCCESS; } + +namespace core { +hsa_status_t allow_access_to_all_gpu_agents(void *ptr) { + return hsa_amd_agents_allow_access(DeviceInfo.HSAAgents.size(), + &DeviceInfo.HSAAgents[0], NULL, ptr); +} + +} // namespace core \ No newline at end of file