From: Pushpinder Singh Date: Mon, 7 Jun 2021 09:29:29 +0000 (+0000) Subject: [AMDGPU][Libomptarget] Remove atlc global X-Git-Tag: llvmorg-14-init~4704 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f8bc7caf4e5fcc1620b3fd4980ec8d671e9345b;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/openmp/libomptarget/plugins/amdgpu/impl/internal.h b/openmp/libomptarget/plugins/amdgpu/impl/internal.h index 0cdd5ee..81a4f8f 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 9377e3a..02b570c 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 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 gpu_agents; - int gpu_count = g_atl_machine.processorCount(); - for (int gpu = 0; gpu < gpu_count; gpu++) { - ATLGPUProcessor &proc = get_processor(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; }