[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
This commit is contained in:
Jon Chesterfield 2021-06-30 22:23:34 +01:00
parent a601b308d9
commit d86b0073cf
7 changed files with 12 additions and 90 deletions

View File

@ -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;
}

View File

@ -10,7 +10,6 @@
#include <cassert>
#include <hsa.h>
#include <hsa_ext_amd.h>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <thread>

View File

@ -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_

View File

@ -8,7 +8,6 @@
#include "atmi_runtime.h"
#include "hsa.h"
#include <cstdarg>
#include <string>
namespace core {

View File

@ -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;
}

View File

@ -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");

View File

@ -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) {