-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.h
More file actions
46 lines (35 loc) · 867 Bytes
/
utils.h
File metadata and controls
46 lines (35 loc) · 867 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
41
42
43
44
45
46
/*
* utils.h
*
* Created on: Jan 3, 2016
* Author: matan
*/
#ifndef UTILS_H_
#define UTILS_H_
#include <cstdio>
#include <cstdlib>
#ifdef __CUDACC__
#define DEVICE_FUNCTION __device__
#define HOST_FUNCTION __host__
#define HOST_DEVICE_FUNCTION __host__ __device__
#else
#define DEVICE_FUNCTION
#define HOST_FUNCTION
#define HOST_DEVICE_FUNCTION
#endif
#define WARP_SIZE 32
#define LOG_WARP_SIZE 5
#ifndef MAX_THREADBLOCK_SIZE
#define MAX_THREADBLOCK_SIZE 1024
#endif
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
#define regsPerThread(n) (((n) + (WARP_SIZE - 1))/WARP_SIZE)
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort = true)
{
if (code != cudaSuccess)
{
fprintf(stdout, "GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
if (abort) exit(code);
}
}
#endif /* UTILS_H_ */