|
16 | 16 | #define GPUCOMMONFAIRLOGGER_H |
17 | 17 |
|
18 | 18 | #include "GPUCommonDef.h" |
| 19 | +#ifndef GPUCA_GPUCODE_DEVICE |
| 20 | +#include <cstdio> |
| 21 | +#endif |
19 | 22 |
|
20 | | -#if defined(GPUCA_GPUCODE_DEVICE) |
21 | | -namespace o2::gpu::detail |
| 23 | +namespace o2::gpu::internal |
22 | 24 | { |
| 25 | +#if defined(GPUCA_GPUCODE_DEVICE) |
23 | 26 | struct DummyLogger { |
24 | 27 | template <typename... Args> |
25 | 28 | GPUd() DummyLogger& operator<<(Args... args) |
26 | 29 | { |
27 | 30 | return *this; |
28 | 31 | } |
29 | 32 | }; |
30 | | -} // namespace o2::gpu::detail |
| 33 | +#else |
| 34 | +template <typename... Args> |
| 35 | +void LOGP_internal(const char* str, Args... args) |
| 36 | +{ |
| 37 | + printf("%s\n", str); |
| 38 | +} |
31 | 39 | #endif |
| 40 | +} // namespace o2::gpu::internal |
32 | 41 |
|
33 | | -#if defined(__OPENCL__) || (defined(GPUCA_GPUCODE_DEVICE) && !defined(GPUCA_GPU_DEBUG_PRINT)) |
34 | | -#define LOG(...) o2::gpu::detail::DummyLogger() |
| 42 | +#ifdef GPUCA_GPUCODE_DEVICE |
| 43 | +// ---------- begin GPUCA_GPUCODE_DEVICE ---------- |
| 44 | + |
| 45 | +#if defined(__OPENCL__) || !defined(GPUCA_GPU_DEBUG_PRINT) |
| 46 | +#define LOG(...) o2::gpu::internal::DummyLogger() |
35 | 47 | #define LOGF(...) |
36 | 48 | #define LOGP(...) |
37 | 49 |
|
38 | | -#elif defined(GPUCA_GPUCODE_DEVICE) |
39 | | -#define LOG(...) o2::gpu::detail::DummyLogger() |
| 50 | +#else |
| 51 | +#define LOG(...) o2::gpu::internal::DummyLogger() |
40 | 52 | // #define LOG(...) static_assert(false, "LOG(...) << ... unsupported in GPU code"); |
41 | 53 | #define LOGF(type, string, ...) \ |
42 | 54 | { \ |
43 | 55 | printf(string "\n", ##__VA_ARGS__); \ |
44 | 56 | } |
45 | 57 | #define LOGP(...) |
46 | 58 | // #define LOGP(...) static_assert(false, "LOGP(...) unsupported in GPU code"); |
| 59 | +#endif |
47 | 60 |
|
| 61 | +// ---------- end GPUCA_GPUCODE_DEVICE ---------- |
48 | 62 | #elif defined(GPUCA_STANDALONE) || defined(GPUCA_GPUCODE_COMPILEKERNELS) || defined(GPUCA_COMPILEKERNELS) |
| 63 | +// ---------- begin GPUCA_STANDALONE / COMPILEKERNELS ---------- |
| 64 | + |
49 | 65 | #include <iostream> |
50 | 66 | #include <cstdio> |
51 | 67 | #define LOG(type) std::cout |
52 | | -#define LOGF(type, string, ...) \ |
53 | | - { \ |
54 | | - printf(string "\n", ##__VA_ARGS__); \ |
55 | | - } |
56 | | -#define LOGP(type, string, ...) \ |
57 | | - { \ |
58 | | - printf("%s\n", string); \ |
59 | | - } |
| 68 | +#define LOGF(type, string, ...) printf(string "\n", ##__VA_ARGS__); |
| 69 | +#if !defined(GPUCA_NO_FMT) && !defined(GPUCA_GPUCODE) |
| 70 | +#define LOGP(type, string, ...) fmt::print(string, ##__VA_ARGS__) |
| 71 | +#else |
| 72 | +#define LOGP(type, string, ...) o2::gpu::internal::LOGP_internal(string, ##__VA_ARGS__) |
| 73 | +#endif |
| 74 | +#if defined(GPUCA_STANDALONE) && !defined(GPUCA_GPUCODE) |
| 75 | +#if !defined(GPUCA_NO_FMT) |
| 76 | +#include <fmt/format.h> |
| 77 | +#else |
| 78 | +namespace fmt |
| 79 | +{ |
| 80 | +template <typename... Args> |
| 81 | +static const char* format(Args... args) |
| 82 | +{ |
| 83 | + return ""; |
| 84 | +} |
| 85 | +} // namespace fmt |
| 86 | +#endif |
| 87 | +#endif |
60 | 88 |
|
| 89 | +// ---------- end GPUCA_STANDALONE / COMPILEKERNELS ---------- |
61 | 90 | #else |
62 | 91 | #include <Framework/Logger.h> |
63 | | - |
64 | 92 | #endif |
65 | 93 |
|
66 | 94 | #endif |
0 commit comments