Project
Loading...
Searching...
No Matches
GPUCommonLogger.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef GPUCOMMONFAIRLOGGER_H
16#define GPUCOMMONFAIRLOGGER_H
17
18#include "GPUCommonDef.h"
19
20#if defined(GPUCA_GPUCODE_DEVICE)
21namespace o2::gpu::detail
22{
23struct DummyLogger {
24 template <typename... Args>
25 GPUd() DummyLogger& operator<<(Args... args)
26 {
27 return *this;
28 }
29};
30} // namespace o2::gpu::detail
31#endif
32
33#if defined(__OPENCL__) || (defined(GPUCA_GPUCODE_DEVICE) && !defined(GPUCA_GPU_DEBUG_PRINT))
34#define LOG(...) o2::gpu::detail::DummyLogger()
35#define LOGF(...)
36#define LOGP(...)
37
38#elif defined(GPUCA_GPUCODE_DEVICE)
39#define LOG(...) o2::gpu::detail::DummyLogger()
40// #define LOG(...) static_assert(false, "LOG(...) << ... unsupported in GPU code");
41#define LOGF(type, string, ...) \
42 { \
43 printf(string "\n", ##__VA_ARGS__); \
44 }
45#define LOGP(...)
46// #define LOGP(...) static_assert(false, "LOGP(...) unsupported in GPU code");
47
48#elif defined(GPUCA_STANDALONE)
49#include <iostream>
50#include <cstdio>
51#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 }
60
61#else
62#include <Framework/Logger.h>
63
64#endif
65
66#endif
#define GPUd()