[Openmp-commits] [openmp] 4f8bc7c - [AMDGPU][Libomptarget] Remove atlc global
Pushpinder Singh via Openmp-commits
openmp-commits at lists.llvm.org
Mon Jun 7 04:09:12 PDT 2021
Author: Pushpinder Singh
Date: 2021-06-07T11:09:01Z
New Revision: 4f8bc7caf4e5fcc1620b3fd4980ec8d671e9345b
URL: https://github.com/llvm/llvm-project/commit/4f8bc7caf4e5fcc1620b3fd4980ec8d671e9345b
DIFF: https://github.com/llvm/llvm-project/commit/4f8bc7caf4e5fcc1620b3fd4980ec8d671e9345b.diff
LOG: [AMDGPU][Libomptarget] Remove atlc global
This global struct used to hold various flags for monitoring the
initialization of hsa.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D103795
Added:
Modified:
openmp/libomptarget/plugins/amdgpu/impl/internal.h
openmp/libomptarget/plugins/amdgpu/impl/system.cpp
Removed:
################################################################################
diff --git a/openmp/libomptarget/plugins/amdgpu/impl/internal.h b/openmp/libomptarget/plugins/amdgpu/impl/internal.h
index 0cdd5ee9748da..81a4f8f8cc6e2 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/internal.h
+++ b/openmp/libomptarget/plugins/amdgpu/impl/internal.h
@@ -65,15 +65,6 @@ typedef struct hsa_signal_s {
} hsa_signal_t;
#endif
-/* All global values go in this global structure */
-typedef struct atl_context_s {
- bool struct_initialized;
- bool g_hsa_initialized;
- bool g_gpu_initialized;
- bool g_tasks_initialized;
-} atl_context_t;
-extern atl_context_t atlc;
-
#ifdef __cplusplus
}
#endif
diff --git a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
index 9377e3a96c433..02b570cf565a8 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
@@ -142,13 +142,6 @@ static const std::map<std::string, KernelArgMD::ValueKind> ArgValueKind = {
ATLMachine g_atl_machine;
-/*
- atlc is all internal global values.
- The structure atl_context_t is defined in atl_internal.h
- Most references will use the global structure prefix atlc.
-*/
-atl_context_t atlc = {.struct_initialized = false};
-
namespace core {
hsa_status_t allow_access_to_all_gpu_agents(void *ptr) {
@@ -161,13 +154,6 @@ hsa_status_t allow_access_to_all_gpu_agents(void *ptr) {
return hsa_amd_agents_allow_access(agents.size(), &agents[0], NULL, ptr);
}
-static void atmi_init_context_structs() {
- atlc.struct_initialized = true; /* This only gets called one time */
- atlc.g_hsa_initialized = false;
- atlc.g_gpu_initialized = false;
- atlc.g_tasks_initialized = false;
-}
-
// Implement memory_pool iteration function
static hsa_status_t get_memory_pool_info(hsa_amd_memory_pool_t memory_pool,
void *data) {
@@ -447,42 +433,27 @@ static hsa_status_t init_compute_and_memory() {
}
hsa_status_t init_hsa() {
- if (atlc.g_hsa_initialized == false) {
- DEBUG_PRINT("Initializing HSA...");
- hsa_status_t err = hsa_init();
- if (err != HSA_STATUS_SUCCESS) {
- printf("[%s:%d] %s failed: %s\n", __FILE__, __LINE__,
- "Initializing the hsa runtime", get_error_string(err));
- return err;
- }
- if (err != HSA_STATUS_SUCCESS)
- return err;
-
- err = init_compute_and_memory();
- if (err != HSA_STATUS_SUCCESS)
- return err;
- if (err != HSA_STATUS_SUCCESS) {
- printf("[%s:%d] %s failed: %s\n", __FILE__, __LINE__,
- "After initializing compute and memory", get_error_string(err));
- return err;
- }
-
- atlc.g_hsa_initialized = true;
- DEBUG_PRINT("done\n");
+ DEBUG_PRINT("Initializing HSA...");
+ hsa_status_t err = hsa_init();
+ if (err != HSA_STATUS_SUCCESS) {
+ printf("[%s:%d] %s failed: %s\n", __FILE__, __LINE__,
+ "Initializing the hsa runtime", get_error_string(err));
+ return err;
}
- return HSA_STATUS_SUCCESS;
-}
+ if (err != HSA_STATUS_SUCCESS)
+ return err;
-void init_tasks() {
- if (atlc.g_tasks_initialized != false)
- return;
- std::vector<hsa_agent_t> gpu_agents;
- int gpu_count = g_atl_machine.processorCount<ATLGPUProcessor>();
- for (int gpu = 0; gpu < gpu_count; gpu++) {
- ATLGPUProcessor &proc = get_processor<ATLGPUProcessor>(gpu);
- gpu_agents.push_back(proc.agent());
+ err = init_compute_and_memory();
+ if (err != HSA_STATUS_SUCCESS)
+ return err;
+ if (err != HSA_STATUS_SUCCESS) {
+ printf("[%s:%d] %s failed: %s\n", __FILE__, __LINE__,
+ "After initializing compute and memory", get_error_string(err));
+ return err;
}
- atlc.g_tasks_initialized = true;
+
+ DEBUG_PRINT("done\n");
+ return HSA_STATUS_SUCCESS;
}
hsa_status_t callbackEvent(const hsa_amd_event_t *event, void *data) {
@@ -526,11 +497,6 @@ hsa_status_t callbackEvent(const hsa_amd_event_t *event, void *data) {
}
hsa_status_t atl_init_gpu_context() {
- if (atlc.struct_initialized == false)
- atmi_init_context_structs();
- if (atlc.g_gpu_initialized != false)
- return HSA_STATUS_SUCCESS;
-
hsa_status_t err;
err = init_hsa();
if (err != HSA_STATUS_SUCCESS)
@@ -543,8 +509,6 @@ hsa_status_t atl_init_gpu_context() {
return HSA_STATUS_ERROR;
}
- init_tasks();
- atlc.g_gpu_initialized = true;
return HSA_STATUS_SUCCESS;
}
More information about the Openmp-commits
mailing list