Skip to content

Commit 11f041c

Browse files
committed
GPU: GPULooger should suppress messages below info level in standalone benchmark
1 parent 52dfbee commit 11f041c

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

GPU/Common/GPUCommonLogger.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,18 @@ void LOGP_internal(const char* str, Args... args)
3737
printf("%s\n", str);
3838
}
3939
#endif
40+
enum class loglevel : int32_t {
41+
debug = 0,
42+
info = 1,
43+
warning = 2,
44+
important = 3,
45+
alarm = 4,
46+
error = 5,
47+
fatal = 6
48+
};
4049
} // namespace o2::gpu::internal
4150

42-
#ifdef GPUCA_GPUCODE_DEVICE
51+
#ifdef GPUCA_GPUCODE_DEVICE // clang-format off
4352
// ---------- begin GPUCA_GPUCODE_DEVICE ----------
4453

4554
#if defined(__OPENCL__) || !defined(GPUCA_GPU_DEBUG_PRINT)
@@ -50,10 +59,7 @@ void LOGP_internal(const char* str, Args... args)
5059
#else
5160
#define LOG(...) o2::gpu::internal::DummyLogger()
5261
// #define LOG(...) static_assert(false, "LOG(...) << ... unsupported in GPU code");
53-
#define LOGF(type, string, ...) \
54-
{ \
55-
printf(string "\n", ##__VA_ARGS__); \
56-
}
62+
#define LOGF(type, string, ...) do { if (o2::gpu::internal::loglevel::type >= o2::gpu::internal::loglevel::info) { printf(string "\n", ##__VA_ARGS__); }} while (false);
5763
#define LOGP(...)
5864
// #define LOGP(...) static_assert(false, "LOGP(...) unsupported in GPU code");
5965
#endif
@@ -65,11 +71,11 @@ void LOGP_internal(const char* str, Args... args)
6571
#include <iostream>
6672
#include <cstdio>
6773
#define LOG(type) std::cout
68-
#define LOGF(type, string, ...) printf(string "\n", ##__VA_ARGS__);
74+
#define LOGF(type, string, ...) do { if (o2::gpu::internal::loglevel::type >= o2::gpu::internal::loglevel::info) { printf(string "\n", ##__VA_ARGS__); }} while (false);
6975
#if !defined(GPUCA_NO_FMT) && !defined(GPUCA_GPUCODE)
70-
#define LOGP(type, string, ...) fmt::print(string, ##__VA_ARGS__)
76+
#define LOGP(type, string, ...) do { if (o2::gpu::internal::loglevel::type >= o2::gpu::internal::loglevel::info) { fmt::print(string, ##__VA_ARGS__); printf("\n"); }} while (false);
7177
#else
72-
#define LOGP(type, string, ...) o2::gpu::internal::LOGP_internal(string, ##__VA_ARGS__)
78+
#define LOGP(type, string, ...) do { if (o2::gpu::internal::loglevel::type >= o2::gpu::internal::loglevel::info) { o2::gpu::internal::LOGP_internal(string, ##__VA_ARGS__); }} while (false);
7379
#endif
7480
#if defined(GPUCA_STANDALONE) && !defined(GPUCA_GPUCODE)
7581
#if !defined(GPUCA_NO_FMT)
@@ -89,6 +95,6 @@ static const char* format(Args... args)
8995
// ---------- end GPUCA_STANDALONE / COMPILEKERNELS ----------
9096
#else
9197
#include <Framework/Logger.h>
92-
#endif
98+
#endif // clang-format on
9399

94100
#endif

0 commit comments

Comments
 (0)