1 #ifndef CAFFEINE_COMMON_HPP_
2 #define CAFFEINE_COMMON_HPP_
4 #include <iostream>
6 #include <boost/shared_ptr.hpp>
8 #include "driver_types.h"
10 namespace caffeine {
11 using boost::shared_ptr;
12 }
14 static std::ostream nullout(0);
16 // TODO(Yangqing): make a better logging scheme
17 #define LOG_IF(condition) \
18 !(condition) ? nullout : std::cout
20 #define CHECK(condition) \
21 LOG_IF(condition) << "Check failed: " #condition " "
23 #ifndef NDEBUG
25 #define DCHECK(condition) CHECK(condition)
27 #else
29 #define DCHECK(condition)
31 #endif // NDEBUG
34 #define CUDA_CHECK(condition) \
35 CUDA_LOG_IF(condition) << "Check failed: " #condition " "
38 // TODO(Yangqing): make a better logging scheme
39 #define CUDA_LOG_IF(condition) \
40 ((condition) != cudaSuccess) ? nullout : std::cout
42 #define CUDA_CHECK(condition) \
43 CUDA_LOG_IF(condition) << "Check failed: " #condition " "
45 #ifndef NDEBUG
47 #define CUDA_DCHECK(condition) CUDA_CHECK(condition)
49 #else
51 #define CUDA_DCHECK(condition)
53 #endif // NDEBUG
55 #endif // CAFFEINE_COMMON_HPP_