-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.h
43 lines (33 loc) · 1.43 KB
/
helpers.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
36
37
38
39
40
41
42
43
#ifndef HELPERS_H
#define HELPERS_H
#include <stdlib.h>
#include <stdio.h>
/*
* Macros
*/
inline void cudaPrintError(cudaError_t cudaerr, const char *file, int line)
{
if (cudaerr != cudaSuccess) {
fprintf(stderr, "CUDA error: \"%s\" in file %s at line %d.\n", cudaGetErrorString(cudaerr), file, line);
exit(cudaerr);
}
}
#define cudaErr(ans) \
do { \
cudaPrintError((ans), __FILE__, __LINE__); \
} while (0)
#define cudaLastErr() \
do { \
cudaError_t cudaerr = cudaDeviceSynchronize(); \
cudaPrintError(cudaerr, __FILE__, __LINE__); \
} while (0)
/*
* Stop clangd from complaining of missing symbols in .cu files
*/
#ifdef __CUDA_ARCH__
#define syncthreads() __syncthreads()
#else
#define syncthreads()
#endif
__global__ void zero_array(unsigned int *, size_t);
#endif