From fb113264a8da1d8e456e64f99920fac6b4fae548 Mon Sep 17 00:00:00 2001 From: Pushpinder Singh Date: Tue, 1 Jun 2021 09:23:10 +0000 Subject: [PATCH] [AMDGPU][Libomptarget] Remove g_atmi_machine global Turns out the only purpose of this class was verify if device ID was in range or not which could be done easily by using g_atl_machine. Still getting rid of g_atl_machine is pending which would be done in a later patch. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D103443 --- openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp | 7 ------- .../plugins/amdgpu/impl/atmi_interop_hsa.cpp | 15 +++++++++------ .../libomptarget/plugins/amdgpu/impl/atmi_runtime.h | 17 ----------------- openmp/libomptarget/plugins/amdgpu/impl/rt.h | 2 -- openmp/libomptarget/plugins/amdgpu/impl/system.cpp | 20 -------------------- 5 files changed, 9 insertions(+), 52 deletions(-) diff --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp index a7066a0..90b8a26 100644 --- a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp +++ b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp @@ -11,13 +11,6 @@ #include /* - * Machine Info - */ -atmi_machine_t *atmi_machine_get_info() { - return core::Runtime::GetMachineInfo(); -} - -/* * Data */ diff --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.cpp b/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.cpp index 1359d7d..791b0b3 100644 --- a/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.cpp +++ b/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.cpp @@ -5,6 +5,11 @@ *===------------------------------------------------------------------------*/ #include "atmi_interop_hsa.h" #include "internal.h" +#include "machine.h" + +// TODO: need to get rid of this as well + +extern ATLMachine g_atl_machine; hsa_status_t atmi_interop_hsa_get_symbol_info( const std::map &SymbolInfoTable, @@ -18,11 +23,10 @@ hsa_status_t atmi_interop_hsa_get_symbol_info( atmi_memcpy(signal, host_add, var_addr, var_size); */ - atmi_machine_t *machine = atmi_machine_get_info(); - if (!symbol || !var_addr || !var_size || !machine) + if (!symbol || !var_addr || !var_size) return HSA_STATUS_ERROR; if (DeviceId < 0 || - DeviceId >= machine->device_count_by_type[ATMI_DEVTYPE_GPU]) + DeviceId >= g_atl_machine.processors().size()) return HSA_STATUS_ERROR; // get the symbol info @@ -52,11 +56,10 @@ hsa_status_t atmi_interop_hsa_get_kernel_info( &val); */ - atmi_machine_t *machine = atmi_machine_get_info(); - if (!kernel_name || !value || !machine) + if (!kernel_name || !value) return HSA_STATUS_ERROR; if (DeviceId < 0 || - DeviceId >= machine->device_count_by_type[ATMI_DEVTYPE_GPU]) + DeviceId >= g_atl_machine.processors().size()) return HSA_STATUS_ERROR; hsa_status_t status = HSA_STATUS_SUCCESS; diff --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h b/openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h index 92e2cc3..c180ec7 100644 --- a/openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h +++ b/openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h @@ -58,23 +58,6 @@ hsa_status_t atmi_module_register_from_memory_to_place( /** @} */ -/** \defgroup machine ATMI Machine - * @{ - */ -/** - * @brief ATMI's device discovery function to get the current machine's - * topology. - * - * @detail The @p atmi_machine_t structure is a tree-based representation of the - * compute and memory elements in the current node. Once ATMI is initialized, - * this function can be called to retrieve the pointer to this global structure. - * - * @return Returns a pointer to a global structure of tyoe @p atmi_machine_t. - * Returns NULL if ATMI is not initialized. - */ -atmi_machine_t *atmi_machine_get_info(); -/** @} */ - hsa_status_t atmi_memcpy_h2d(hsa_signal_t signal, void *deviceDest, const void *hostSrc, size_t size, hsa_agent_t agent); diff --git a/openmp/libomptarget/plugins/amdgpu/impl/rt.h b/openmp/libomptarget/plugins/amdgpu/impl/rt.h index fbde60f..fb33db9 100644 --- a/openmp/libomptarget/plugins/amdgpu/impl/rt.h +++ b/openmp/libomptarget/plugins/amdgpu/impl/rt.h @@ -49,8 +49,6 @@ public: return instance; } - // machine info - static atmi_machine_t *GetMachineInfo(); // modules static hsa_status_t RegisterModuleFromMemory( void *, size_t, atmi_place_t, diff --git a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp index de06640..cbea4ac 100644 --- a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp +++ b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp @@ -140,8 +140,6 @@ static const std::map ArgValueKind = { {"hidden_hostcall_buffer", KernelArgMD::ValueKind::HiddenHostcallBuffer}, }; -// global variables. TODO: Get rid of these -atmi_machine_t g_atmi_machine; ATLMachine g_atl_machine; std::vector atl_gpu_kernarg_pools; @@ -154,12 +152,6 @@ std::vector atl_gpu_kernarg_pools; atl_context_t atlc = {.struct_initialized = false}; namespace core { -/* Machine Info */ -atmi_machine_t *Runtime::GetMachineInfo() { - if (!atlc.g_hsa_initialized) - return NULL; - return &g_atmi_machine; -} hsa_status_t allow_access_to_all_gpu_agents(void *ptr) { std::vector &gpu_procs = @@ -362,12 +354,7 @@ static hsa_status_t init_compute_and_memory() { } } - g_atmi_machine.device_count_by_type[ATMI_DEVTYPE_CPU] = cpu_procs.size(); - g_atmi_machine.device_count_by_type[ATMI_DEVTYPE_GPU] = gpu_procs.size(); - size_t num_procs = cpu_procs.size() + gpu_procs.size(); - // g_atmi_machine.devices = (atmi_device_t *)malloc(num_procs * - // sizeof(atmi_device_t)); atmi_device_t *all_devices = reinterpret_cast( malloc(num_procs * sizeof(atmi_device_t))); int num_iGPUs = 0; @@ -385,17 +372,10 @@ static hsa_status_t init_compute_and_memory() { DEBUG_PRINT("dGPU Agents: %d\n", num_dGPUs); DEBUG_PRINT("GPU Agents: %lu\n", gpu_procs.size()); - g_atmi_machine.device_count_by_type[ATMI_DEVTYPE_iGPU] = num_iGPUs; - g_atmi_machine.device_count_by_type[ATMI_DEVTYPE_dGPU] = num_dGPUs; - int cpus_begin = 0; int cpus_end = cpu_procs.size(); int gpus_begin = cpu_procs.size(); int gpus_end = cpu_procs.size() + gpu_procs.size(); - g_atmi_machine.devices_by_type[ATMI_DEVTYPE_CPU] = &all_devices[cpus_begin]; - g_atmi_machine.devices_by_type[ATMI_DEVTYPE_GPU] = &all_devices[gpus_begin]; - g_atmi_machine.devices_by_type[ATMI_DEVTYPE_iGPU] = &all_devices[gpus_begin]; - g_atmi_machine.devices_by_type[ATMI_DEVTYPE_dGPU] = &all_devices[gpus_begin]; int proc_index = 0; for (int i = cpus_begin; i < cpus_end; i++) { all_devices[i].type = cpu_procs[proc_index].type(); -- 2.7.4