[Openmp-commits] [openmp] d86b007 - [libomptarget][amdgpu][nfc] Fix build warnings, drop some headers
Jon Chesterfield via Openmp-commits
openmp-commits at lists.llvm.org
Wed Jun 30 14:23:46 PDT 2021
Author: Jon Chesterfield
Date: 2021-06-30T22:23:36+01:00
New Revision: d86b0073cf283849ef9beaa94efe13fef1a0a615
URL: https://github.com/llvm/llvm-project/commit/d86b0073cf283849ef9beaa94efe13fef1a0a615
DIFF: https://github.com/llvm/llvm-project/commit/d86b0073cf283849ef9beaa94efe13fef1a0a615.diff
LOG: [libomptarget][amdgpu][nfc] Fix build warnings, drop some headers
Removes stdarg header, drops uses of iostream, fix some format string errors.
Also changes a C style struct to C++ style to avoid a warning from clang/
Reviewed By: pdhaliwal
Differential Revision: https://reviews.llvm.org/D104923
Added:
Modified:
openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
openmp/libomptarget/plugins/amdgpu/impl/data.cpp
openmp/libomptarget/plugins/amdgpu/impl/internal.h
openmp/libomptarget/plugins/amdgpu/impl/rt.h
openmp/libomptarget/plugins/amdgpu/impl/system.cpp
openmp/libomptarget/plugins/amdgpu/impl/utils.cpp
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
Removed:
################################################################################
diff --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
index 90b8a26a7bac..32dd7ea8b913 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
@@ -62,7 +62,7 @@ hsa_status_t atmi_memcpy_h2d(hsa_signal_t signal, void *deviceDest,
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 @@ hsa_status_t atmi_memcpy_d2h(hsa_signal_t signal, void *dest,
}
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
index 905d1615cec8..e3bb6bbec747 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/data.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/data.cpp
@@ -10,7 +10,6 @@
#include <cassert>
#include <hsa.h>
#include <hsa_ext_amd.h>
-#include <iostream>
#include <stdio.h>
#include <string.h>
#include <thread>
diff --git a/openmp/libomptarget/plugins/amdgpu/impl/internal.h b/openmp/libomptarget/plugins/amdgpu/impl/internal.h
index 25551f4a290c..268d81210520 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/internal.h
+++ b/openmp/libomptarget/plugins/amdgpu/impl/internal.h
@@ -205,6 +205,5 @@ hsa_status_t allow_access_to_all_gpu_agents(void *ptr);
} // 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
index 90713b7c8f8c..d09eabf5a61d 100644
--- 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 <cstdarg>
#include <string>
namespace core {
diff --git a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
index e925c622213b..e80f0bb62cea 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
@@ -7,11 +7,10 @@
#include <libelf.h>
#include <cassert>
-#include <cstdarg>
#include <fstream>
#include <iomanip>
-#include <iostream>
#include <set>
+#include <sstream>
#include <string>
#include "internal.h"
@@ -999,7 +998,7 @@ hsa_status_t RegisterModuleFromMemory(
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
index a88b6bbafded..e54f1123d1bb 100644
--- 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 <errno.h>
-#include <iostream>
-#include <pthread.h>
-#include <sched.h>
#include <stdio.h>
-
-/*
- * 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 <string>
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 @@ namespace core {
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
index be64ed2bbfa4..1cdd4a4b4935 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -1199,11 +1199,11 @@ const Elf64_Sym *elf_lookup(Elf *elf, char *base, Elf64_Shdr *section_hash,
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) {
More information about the Openmp-commits
mailing list