Adding new macro for HIP using ClPrint

calculates duration of a call

Change-Id: I7cca673f6dabc618ec543e3bd6c5102aa76edc3a
Этот коммит содержится в:
Payam
2020-07-03 10:27:48 -04:00
коммит произвёл Payam Ghafari
родитель 1e349179e2
Коммит 47088fea0d
2 изменённых файлов: 40 добавлений и 1 удалений
+19 -1
Просмотреть файл
@@ -87,8 +87,26 @@ void log_printf(LogLevel level, const char* file, int line, const char* format,
char message[4096];
vsnprintf(message, sizeof(message), format, ap);
va_end(ap);
uint64_t timeUs = Os::timeNanos() / 1000ULL;
fprintf(stderr, ":%d:%-25s:%-4d: %010lld us: %s\n", level, file, line, timeUs, message);
fprintf(stderr, ":%d:%-25s:%-4d: %010lld us: %s\n", level, file, line, Os::timeNanos() / 1000ULL, message);
}
void log_printf(LogLevel level, const char* file, int line, uint64_t* start, const char* format, ...) {
va_list ap;
va_start(ap, format);
char message[4096];
vsnprintf(message, sizeof(message), format, ap);
va_end(ap);
uint64_t timeUs = Os::timeNanos() / 1000ULL;
if (start == 0 || *start == 0) {
fprintf(stderr, ":%d:%-25s:%-4d: %010lld us: %s\n", level, file, line, timeUs, message);
} else {
fprintf(stderr, ":%d:%-25s:%-4d: %010lld us: %s: duration: %d us\n", level, file, line, timeUs, message,timeUs - *start);
}
if (*start == 0) {
*start = timeUs;
}
}
} // namespace amd
+21
Просмотреть файл
@@ -24,7 +24,13 @@
#include <cassert>
#include <string.h>
#include <cstdint>
//! \addtogroup Utils
#ifdef _WIN32
#include <process.h>
#else
#include <unistd.h>
#endif
namespace amd { /*@{*/
@@ -69,6 +75,7 @@ extern void log_timestamped(LogLevel level, const char* file, int line, const ch
//! \brief Insert a printf-style log entry.
extern void log_printf(LogLevel level, const char* file, int line, const char* format, ...);
extern void log_printf(LogLevel level, const char* file, int line, uint64_t *start, const char* format, ...);
/*@}*/} // namespace amd
@@ -190,6 +197,20 @@ inline void warning(const char* msg) { amd::report_warning(msg); }
} \
} while (false)
//called on entry and exit, calculates duration with local starttime variable defined in HIP_INIT_API
#define HIPPrintDuration(level, mask, startTimeUs, format, ...) \
do { \
if (AMD_LOG_LEVEL >= level) { \
if (AMD_LOG_MASK & mask || mask == amd::LOG_ALWAYS) { \
if (AMD_LOG_MASK & amd::LOG_LOCATION) { \
amd::log_printf(level, __FILENAME__, __LINE__, startTimeUs,format, ##__VA_ARGS__); \
} else { \
amd::log_printf(level, "", 0, startTimeUs, format, ##__VA_ARGS__); \
} \
} \
} \
} while (false)
#define ClCondPrint(level, mask, condition, format, ...) \
do { \
if (AMD_LOG_LEVEL >= level && (condition)) { \