diff --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp --- a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp +++ b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp @@ -62,7 +62,7 @@ void *tempHostPtr; hsa_status_t ret = core::Runtime::HostMalloc(&tempHostPtr, size); if (ret != HSA_STATUS_SUCCESS) { - DEBUG_PRINT("HostMalloc: Unable to alloc %d bytes for temp scratch\n", + DEBUG_PRINT("HostMalloc: Unable to alloc %zu bytes for temp scratch\n", size); return ret; } @@ -89,10 +89,9 @@ } void *tempHostPtr; - hsa_status_t ret = core::Runtime::HostMalloc(&tempHostPtr, size); if (ret != HSA_STATUS_SUCCESS) { - DEBUG_PRINT("HostMalloc: Unable to alloc %d bytes for temp scratch\n", + DEBUG_PRINT("HostMalloc: Unable to alloc %zu bytes for temp scratch\n", size); return ret; } diff --git a/openmp/libomptarget/plugins/amdgpu/impl/data.cpp b/openmp/libomptarget/plugins/amdgpu/impl/data.cpp --- a/openmp/libomptarget/plugins/amdgpu/impl/data.cpp +++ b/openmp/libomptarget/plugins/amdgpu/impl/data.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include 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 @@ -205,6 +205,5 @@ } // namespace core const char *get_error_string(hsa_status_t err); -const char *get_atmi_error_string(hsa_status_t err); #endif // SRC_RUNTIME_INCLUDE_INTERNAL_H_ diff --git a/openmp/libomptarget/plugins/amdgpu/impl/rt.h b/openmp/libomptarget/plugins/amdgpu/impl/rt.h --- a/openmp/libomptarget/plugins/amdgpu/impl/rt.h +++ b/openmp/libomptarget/plugins/amdgpu/impl/rt.h @@ -8,7 +8,6 @@ #include "atmi_runtime.h" #include "hsa.h" -#include #include namespace core { 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 @@ -7,11 +7,10 @@ #include #include -#include #include #include -#include #include +#include #include #include "internal.h" @@ -999,7 +998,7 @@ if (atmi_err != HSA_STATUS_SUCCESS) { printf("[%s:%d] %s failed: %s\n", __FILE__, __LINE__, "Error in deserialized_data callback", - get_atmi_error_string(atmi_err)); + get_error_string(atmi_err)); return atmi_err; } diff --git a/openmp/libomptarget/plugins/amdgpu/impl/utils.cpp b/openmp/libomptarget/plugins/amdgpu/impl/utils.cpp --- a/openmp/libomptarget/plugins/amdgpu/impl/utils.cpp +++ b/openmp/libomptarget/plugins/amdgpu/impl/utils.cpp @@ -6,85 +6,13 @@ #include "internal.h" #include "rt.h" -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include #include - -/* - * Helper functions - */ -const char *get_atmi_error_string(hsa_status_t err) { - switch (err) { - case HSA_STATUS_SUCCESS: - return "HSA_STATUS_SUCCESS"; - case HSA_STATUS_ERROR: - return "HSA_STATUS_ERROR"; - default: - return ""; - } -} +#include const char *get_error_string(hsa_status_t err) { - switch (err) { - case HSA_STATUS_SUCCESS: - return "HSA_STATUS_SUCCESS"; - case HSA_STATUS_INFO_BREAK: - return "HSA_STATUS_INFO_BREAK"; - case HSA_STATUS_ERROR: - return "HSA_STATUS_ERROR"; - case HSA_STATUS_ERROR_INVALID_ARGUMENT: - return "HSA_STATUS_ERROR_INVALID_ARGUMENT"; - case HSA_STATUS_ERROR_INVALID_QUEUE_CREATION: - return "HSA_STATUS_ERROR_INVALID_QUEUE_CREATION"; - case HSA_STATUS_ERROR_INVALID_ALLOCATION: - return "HSA_STATUS_ERROR_INVALID_ALLOCATION"; - case HSA_STATUS_ERROR_INVALID_AGENT: - return "HSA_STATUS_ERROR_INVALID_AGENT"; - case HSA_STATUS_ERROR_INVALID_REGION: - return "HSA_STATUS_ERROR_INVALID_REGION"; - case HSA_STATUS_ERROR_INVALID_SIGNAL: - return "HSA_STATUS_ERROR_INVALID_SIGNAL"; - case HSA_STATUS_ERROR_INVALID_QUEUE: - return "HSA_STATUS_ERROR_INVALID_QUEUE"; - case HSA_STATUS_ERROR_OUT_OF_RESOURCES: - return "HSA_STATUS_ERROR_OUT_OF_RESOURCES"; - case HSA_STATUS_ERROR_INVALID_PACKET_FORMAT: - return "HSA_STATUS_ERROR_INVALID_PACKET_FORMAT"; - case HSA_STATUS_ERROR_RESOURCE_FREE: - return "HSA_STATUS_ERROR_RESOURCE_FREE"; - case HSA_STATUS_ERROR_NOT_INITIALIZED: - return "HSA_STATUS_ERROR_NOT_INITIALIZED"; - case HSA_STATUS_ERROR_REFCOUNT_OVERFLOW: - return "HSA_STATUS_ERROR_REFCOUNT_OVERFLOW"; - case HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS: - return "HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS"; - case HSA_STATUS_ERROR_INVALID_INDEX: - return "HSA_STATUS_ERROR_INVALID_INDEX"; - case HSA_STATUS_ERROR_INVALID_ISA: - return "HSA_STATUS_ERROR_INVALID_ISA"; - case HSA_STATUS_ERROR_INVALID_ISA_NAME: - return "HSA_STATUS_ERROR_INVALID_ISA_NAME"; - case HSA_STATUS_ERROR_INVALID_CODE_OBJECT: - return "HSA_STATUS_ERROR_INVALID_CODE_OBJECT"; - case HSA_STATUS_ERROR_INVALID_EXECUTABLE: - return "HSA_STATUS_ERROR_INVALID_EXECUTABLE"; - case HSA_STATUS_ERROR_FROZEN_EXECUTABLE: - return "HSA_STATUS_ERROR_FROZEN_EXECUTABLE"; - case HSA_STATUS_ERROR_INVALID_SYMBOL_NAME: - return "HSA_STATUS_ERROR_INVALID_SYMBOL_NAME"; - case HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED: - return "HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED"; - case HSA_STATUS_ERROR_VARIABLE_UNDEFINED: - return "HSA_STATUS_ERROR_VARIABLE_UNDEFINED"; - case HSA_STATUS_ERROR_EXCEPTION: - return "HSA_STATUS_ERROR_EXCEPTION"; - } + const char *res; + hsa_status_t rc = hsa_status_string(err, &res); + return (rc == HSA_STATUS_SUCCESS) ? res : "HSA_STATUS UNKNOWN."; } namespace core { @@ -94,9 +22,8 @@ void Environment::GetEnvAll() { std::string var = GetEnv("ATMI_HELP"); if (!var.empty()) { - std::cout << "ATMI_MAX_HSA_QUEUE_SIZE : positive integer" << std::endl - << "ATMI_DEBUG : 1 for printing out trace/debug info" - << std::endl; + printf("ATMI_MAX_HSA_QUEUE_SIZE : positive integer\n" + "ATMI_DEBUG : 1 for printing out trace/debug info\n"); } var = GetEnv("ATMI_MAX_HSA_QUEUE_SIZE"); diff --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp --- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp +++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp @@ -1199,11 +1199,11 @@ return nullptr; } -typedef struct { +struct symbol_info { void *addr = nullptr; uint32_t size = UINT32_MAX; uint32_t sh_type = SHT_NULL; -} symbol_info; +}; int get_symbol_info_without_loading(Elf *elf, char *base, const char *symname, symbol_info *res) {