-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmycuda.cuh
More file actions
40 lines (32 loc) · 713 Bytes
/
mycuda.cuh
File metadata and controls
40 lines (32 loc) · 713 Bytes
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
#ifndef MYCUDA_H
#define MYCUDA_H
#include <stdio.h>
#include <stdlib.h>
#define BLOCK_SIZE 256
static inline int ceildiv(int a, int b)
{
int c = a / b;
if (a % b)
++c;
return c;
}
#define CUDACALL2(f) \
do { \
cudaError_t err = f; \
if (err != cudaSuccess) { \
const char* errs = cudaGetErrorString(err); \
fprintf(stderr, "call %s failed at %s:%d : %s\n", \
#f, __FILE__, __LINE__, errs); \
abort(); \
} \
} while (0)
#define CUDACALL(f) \
do { \
CUDACALL2(f); \
} while (0)
#define CUDALAUNCH(fname,n,args) \
do { \
fname<<< ceildiv((n), BLOCK_SIZE), BLOCK_SIZE >>>args; \
} while (0)
#define CUDAINDEX (blockIdx.x * blockDim.x + threadIdx.x)
#endif