StatMech
Loading...
Searching...
No Matches
mydebug.hpp
Go to the documentation of this file.
1#ifndef MYDEBUG_H
2#define MYDEBUG_H
3
4// #include "Headers/mytypes.hpp"
5#include <iostream>
6#include <iomanip>
7#include <sstream>
8#include <cstdio>
9#include <cassert>
10
11#if defined(NDEBUG) || defined(__CUDA_ARCH__) || true
12 #define debug_print(arg)
13#else
14 #define debug_print(arg) (std::cout << arg << std::endl)
15#endif
16
17#if defined(NDEBUG)
18 #define debug_printf(...)
19#else
20 #ifdef __CUDA_ARCH__
21 #define debug_printf(...) printf("(GPU) " __VA_ARGS__)
22 #else
23 #define debug_printf(...) printf(__VA_ARGS__)
24 #endif
25#endif
26
27#if defined(NDEBUG) && !defined(DEBUG_CONSTRUCTOR)
28 #define debug_constructor_printf(arg)
29 #define debug_destructor_printf(arg)
30#else
31 #ifdef __CUDA_ARCH__
32 #define debug_constructor_printf(arg) \
33 debug_printf("Constructor " #arg ": %s\n\n", __PRETTY_FUNCTION__);
34 #define debug_destructor_printf(arg) \
35 debug_printf("Destructor : %s\n\n", __PRETTY_FUNCTION__);
36 #else
37 #define debug_constructor_printf(arg) \
38 debug_printf("Constructor " #arg ": %s\n\n", __PRETTY_FUNCTION__);
39 #define debug_destructor_printf(arg) \
40 debug_printf("Destructor : %s\n\n", __PRETTY_FUNCTION__);
41 #endif
42#endif
43
44#ifndef cuCHECK
45 #define cuCHECK(call) \
46 { \
47 const cudaError_t error = call; \
48 if(error != cudaSuccess) { \
49 printf("cuCHECK Error: %s:%d, ", __FILE__, __LINE__); \
50 printf("code:%d, reason: %s\n", error, cudaGetErrorString(error)); \
51 assert(error == cudaSuccess); \
52 } \
53 };
54#endif // ifndef cuCHECK
55
56#include <sys/time.h>
57static inline double getETtime() {
58 struct timeval tv;
59 gettimeofday(&tv, NULL);
60 return tv.tv_sec + (double)tv.tv_usec * 1e-6;
61}
62#endif
63
64template<class T>
double getETtime()
Definition EnergySpectrum.c:14
Definition mydebug.hpp:65