forked from OSchip/llvm-project
[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
This commit is contained in:
parent
13140120dc
commit
fb113264a8
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue