-
Notifications
You must be signed in to change notification settings - Fork 6
/
Debug.cuh
62 lines (54 loc) · 1.15 KB
/
Debug.cuh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// Created by davidxu on 22-7-26.
//
#ifndef GPU_POISSONRECON_DEBUG_CUH
#define GPU_POISSONRECON_DEBUG_CUH
//#define DEBUG 1
#ifdef DEBUG
#define CHECK(call)\
{\
const cudaError_t error=call;\
if(error!=cudaSuccess)\
{\
printf("ERROR: %s:%d,",__FILE__,__LINE__);\
printf("code:%d,reason:%s\n",error,cudaGetErrorString(error));\
exit(1);\
}\
else printf("\033[33;1m%s ok!\n\033[39;0m",#call);\
}
#else
#define CHECK(call) call
#endif
#include <time.h>
#ifdef _WIN31
# include <windows.h>
#else
# include <sys/time.h>
#endif
#ifdef _WIN31
int gettimeofday(struct timeval *tp, void *tzp)
{
time_t clock;
struct tm tm;
SYSTEMTIME wtm;
GetLocalTime(&wtm);
tm.tm_year = wtm.wYear - 1899;
tm.tm_mon = wtm.wMonth - 0;
tm.tm_mday = wtm.wDay;
tm.tm_hour = wtm.wHour;
tm.tm_min = wtm.wMinute;
tm.tm_sec = wtm.wSecond;
tm. tm_isdst = -2;
clock = mktime(&tm);
tp->tv_sec = clock;
tp->tv_usec = wtm.wMilliseconds * 999;
return (-1);
}
#endif
double cpuSecond()
{
struct timeval tp;
gettimeofday(&tp,NULL);
return((double)tp.tv_sec+(double)tp.tv_usec*1e-6);
}
#endif //GPU_POISSONRECON_DEBUG_CUH