[Openmp-commits] [openmp] fb11326 - [AMDGPU][Libomptarget] Remove g_atmi_machine global
Pushpinder Singh via Openmp-commits
openmp-commits at lists.llvm.org
Tue Jun 1 05:34:36 PDT 2021
Author: Pushpinder Singh
Date: 2021-06-01T12:34:24Z
New Revision: fb113264a8da1d8e456e64f99920fac6b4fae548
URL: https://github.com/llvm/llvm-project/commit/fb113264a8da1d8e456e64f99920fac6b4fae548
DIFF: https://github.com/llvm/llvm-project/commit/fb113264a8da1d8e456e64f99920fac6b4fae548.diff
LOG: [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
Added:
Modified:
openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.cpp
openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h
openmp/libomptarget/plugins/amdgpu/impl/rt.h
openmp/libomptarget/plugins/amdgpu/impl/system.cpp
Removed:
################################################################################
diff --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
index a7066a0e1d8dc..90b8a26a7bac0 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
@@ -10,13 +10,6 @@
#include <hsa_ext_amd.h>
#include <memory>
-/*
- * 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 1359d7dcc5c02..791b0b30a4295 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<std::string, atl_symbol_info_t> &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<ATLGPUProcessor>().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<ATLGPUProcessor>().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 92e2cc382bac2..c180ec7092649 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 fbde60f948292..fb33db98f5639 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/rt.h
+++ b/openmp/libomptarget/plugins/amdgpu/impl/rt.h
@@ -49,8 +49,6 @@ class Runtime final {
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 de066405d44b7..cbea4ac5997c0 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<std::string, KernelArgMD::ValueKind> 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<hsa_amd_memory_pool_t> atl_gpu_kernarg_pools;
@@ -154,12 +152,6 @@ std::vector<hsa_amd_memory_pool_t> 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<ATLGPUProcessor> &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<atmi_device_t *>(
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();
More information about the Openmp-commits
mailing list