-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPU_Commons.cuh
41 lines (33 loc) · 1.43 KB
/
GPU_Commons.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
#ifndef _GPU_COMMONS_CUH_
#define _GPU_COMMONS_CUH_
#include "cuda_runtime_api.h" // For CUDA
#include "math.h"
/* Conditional Compilation Constants */
#define _MATLAB_DISPLAY_CUDA_SETTING_INFO_ // Display the CUDA configuration
/* Macros for CUDA threads and blocks indices */
#define tidx threadIdx.x
#define bidx blockIdx.x
#define bdim blockDim.x
#define gdim gridDim.x
/* Specify the functions for single precision data type */
#define cuFABS fabsf
#define cuSQRT sqrtf
#define cuRSQRT rsqrtf
#define cuEXP expf
#define cuPOW powf
#define cuCEIL ceilf
#define log2f(x) (logf(x+0.0f)/logf(2.0f))
#define nearest_pow2(x) (powf(2.0f, floorf(log2f(x))))
/* Utility macros */
#ifndef _CUTIL_INLINE_FUNCTIONS_RUNTIME_H_ // To avoid the definition confliction in cutil_inline.h
#define MIN(a, b)((a)<(b)?(a):(b))
#define MAX(a, b)((a)>(b)?(a):(b))
#endif
#define SIGN(a)((a)>0?1:-1)
/* **********************************************************************************************************
Commonly used functions
*************************************************************************************************************/
extern bool CheckCudaError(cudaError, char *, char *);
extern bool CuDeviceInit(struct cudaDeviceProp *, int, char *);
extern bool Get_Kernel_Basic_Config(int, struct cudaDeviceProp, struct cudaFuncAttributes, int *, size_t *, char *);
#endif //_GPU_COMMONS_H_