-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_common.h
35 lines (32 loc) · 992 Bytes
/
my_common.h
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
#ifndef _MY_COMMON_H_
#define _MY_COMMON_H_
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <cuda.h>
#define get_global_base() (blockDim.x * blockIdx.x)
#define get_global_id() (blockDim.x * blockIdx.x + threadIdx.x)
#define get_global_size() (blockDim.x * gridDim.x)
#define get_local_id() (threadIdx.x)
#define get_local_size() (blockDim.x)
#define WARP_SIZE 32
#define Min(x,y) ((x)<(y) ? (x) : (y))
#define Max(x,y) ((x)>(y) ? (x) : (y))
/* error handling */
#define __(stmt) \
do { \
cudaError_t __rc = stmt; \
\
if (__rc != cudaSuccess) \
{ \
fprintf(stderr, \
"[%s:%d] failed on " #stmt " = %s (%s)\n", \
__FILE__, __LINE__, \
cudaGetErrorName(__rc), \
cudaGetErrorString(__rc)); \
_exit(1); \
} \
} while(0)
#endif /* _MY_COMMON_H_ */