1f0d5016ed
SWDEV-198863 - Options for hip-clang-vdi path to provide the chicken bits, or functional equivalents to HCC_DB (phase 3) Use ClPrint to implement other log functions. Move some funtion to use new log functions. This is the final change of the JIRA. Tests: 1. Linux HIP ROCM platform. VEGA10. Driver is release build. 1.1 export LOG_LEVEL=3 ./hipModule There are many logs. 1.2 export GPU_LOG_MASK=0 ./hipModule There is no log 2. Windows HIP PAL platform. VEGA10, Driver is release build. 2.1 set LOG_LEVEL=3 run test hipPrintfKernel There are many logs 2.2 set GPU_LOG_MASK=0 run test hipPrintfKernel There is no log 3. http://ocltc.amd.com:8111/viewModification.html?modId=128588&personal=true&tab=vcsModificationBuilds ReviewBoard: http://ocltc.amd.com/reviews/r/18259/ Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#177 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#157 edit ... //depot/stg/opencl/drivers/opencl/runtime/utils/debug.cpp#6 edit ... //depot/stg/opencl/drivers/opencl/runtime/utils/debug.hpp#14 edit
79 lines
1.8 KiB
C++
79 lines
1.8 KiB
C++
//
|
|
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
|
|
#include "top.hpp"
|
|
#include "utils/debug.hpp"
|
|
#include "os/os.hpp"
|
|
|
|
#if !defined(LOG_LEVEL)
|
|
#include "utils/flags.hpp"
|
|
#endif
|
|
|
|
#include <cstdlib>
|
|
#include <cstdio>
|
|
#include <cstdarg>
|
|
|
|
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#endif // _WIN32
|
|
|
|
namespace amd {
|
|
|
|
//! \cond ignore
|
|
extern "C" void breakpoint(void) {
|
|
#ifdef _MSC_VER
|
|
DebugBreak();
|
|
#endif // _MSC_VER
|
|
}
|
|
//! \endcond
|
|
|
|
void report_fatal(const char* file, int line, const char* message) {
|
|
// FIXME_lmoriche: Obfuscate the message string
|
|
fprintf(stderr, "%s:%d: %s\n", file, line, message);
|
|
::abort();
|
|
}
|
|
|
|
void report_warning(const char* message) { fprintf(stderr, "Warning: %s\n", message); }
|
|
|
|
void log_entry(LogLevel level, const char* file, int line, const char* message) {
|
|
if (level == LOG_NONE) {
|
|
return;
|
|
}
|
|
fprintf(stderr, ":%d:%s:%d: %s\n", level, file, line, message);
|
|
}
|
|
|
|
void log_timestamped(LogLevel level, const char* file, int line, const char* message) {
|
|
static bool gotstart = false; // not thread-safe, but not scary if fails
|
|
static uint64_t start;
|
|
|
|
if (!gotstart) {
|
|
start = Os::timeNanos();
|
|
gotstart = true;
|
|
}
|
|
|
|
uint64_t time = Os::timeNanos() - start;
|
|
if (level == LOG_NONE) {
|
|
return;
|
|
}
|
|
#if 0
|
|
fprintf(stderr, ":%d:%s:%d: (%010lld) %s\n", level, file, line, time, message);
|
|
#else // if you prefer fixed-width fields
|
|
fprintf(stderr, ":% 2d:%15s:% 5d: (%010lld) %s\n", level, file, line, time / 100ULL,
|
|
message); // timestamp is 100ns units
|
|
#endif
|
|
}
|
|
|
|
void log_printf(LogLevel level, const char* file, int line, const char* format, ...) {
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
|
char message[4096];
|
|
vsnprintf(message, sizeof(message), format, ap);
|
|
va_end(ap);
|
|
|
|
fprintf(stderr, ":%d:%s:%d: %s\n", level, file, line, message);
|
|
}
|
|
|
|
} // namespace amd
|