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 @@ -65,15 +65,6 @@ } 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 --- a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp +++ b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp @@ -142,13 +142,6 @@ 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 @@ 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 @@ } 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 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 @@ return HSA_STATUS_ERROR; } - init_tasks(); - atlc.g_gpu_initialized = true; return HSA_STATUS_SUCCESS; }