Blame view

src/utils/cu_syntax.h 1.04 KB
94b2b13d   Pedro Roque   PHACT source
1
2
3
4
/*
 * cu_syntax.h
 *
 *  Created on: 21/09/2019
4d26a735   Pedro Roque   Increased recogni...
5
 *      Author: Pedro
94b2b13d   Pedro Roque   PHACT source
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
 */

#ifndef SRC_UTILS_CU_SYNTAX_H_
#define SRC_UTILS_CU_SYNTAX_H_

// To avoid cuda syntax errors
#if CUDA_VERSION
#define __global
#define __kernel extern "C" __global__
#define __local
#define __constant
#define atomic_add atomicAdd
#define atomic_inc(a) atomicAdd(a,1)
#define get_local_id(a) threadIdx.x
#define get_local_size(a) blockDim.x
#define get_global_id(a) blockIdx.x * blockDim.x + threadIdx.x
#define get_global_size(a) gridDim.x * blockDim.x
#define atomic_cmpxchg atomicCAS
#define atomic_xchg atomicExch
#define atomic_dec(a) atomicSub(a,1)
#define atomic_and atomicAnd
#define CUDA_FUNC __device__
#define convert_ushort (ushort)
#define convert_int (int)
#define convert_uint (uint)
#define convert_ulong (ulong)
#define barrier(a) __syncthreads()
#define CLK_GLOBAL_MEM_FENCE
#define CLK_GLOBAL_MEM_FENCE

#if CL_D_MAX < 32
#define popcount __popc
#define clz __clz
#else
#define popcount __popcll
#define clz __clzll
#endif

#endif

#endif /* SRC_UTILS_CU_SYNTAX_H_ */