Adding new macro for HIP using ClPrint

calculates duration of a call

Change-Id: I7cca673f6dabc618ec543e3bd6c5102aa76edc3a
This commit is contained in:
Payam
2020-07-03 10:27:48 -04:00
committed by Payam Ghafari
parent 1e349179e2
commit 47088fea0d
2 changed files with 40 additions and 1 deletions
+21
View File
@@ -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)) { \