summaryrefslogtreecommitdiff
path: root/kernels/compiler_basic_arithmetic.cl
blob: 3e145d8acb3380d148e60d277800ba4d23ba8c0a (plain)
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
47
48
49
50
51
52
53
#define DECL_KERNEL_SUB(type)\
__kernel void \
compiler_sub_##type(__global type *src0, __global type *src1, __global type *dst) \
{ \
  int id = (int)get_global_id(0); \
  dst[id] = src0[id] - src1[id]; \
}

#define DECL_KERNEL_ADD(type)\
__kernel void \
compiler_add_##type(__global type *src0, __global type *src1, __global type *dst) \
{ \
  int id = (int)get_global_id(0); \
  dst[id] = src0[id] + src1[id]; \
}

#define DECL_KERNEL_MUL(type)\
__kernel void \
compiler_mul_##type(__global type *src0, __global type *src1, __global type *dst) \
{ \
  int id = (int)get_global_id(0); \
  dst[id] = src0[id] * src1[id]; \
}

#define DECL_KERNEL_DIV(type)\
__kernel void \
compiler_div_##type(__global type *src0, __global type *src1, __global type *dst) \
{ \
  int id = (int)get_global_id(0); \
  dst[id] = src0[id] / src1[id]; \
}

#define DECL_KERNEL_REM(type)\
__kernel void \
compiler_rem_##type(__global type *src0, __global type *src1, __global type *dst) \
{ \
  int id = (int)get_global_id(0); \
  dst[id] = src0[id] % src1[id]; \
}

#define DECL_KERNEL_FOR_ALL_TYPE(op) \
DECL_KERNEL_##op(char)               \
DECL_KERNEL_##op(uchar)              \
DECL_KERNEL_##op(short)              \
DECL_KERNEL_##op(ushort)             \
DECL_KERNEL_##op(int)                \
DECL_KERNEL_##op(uint)

DECL_KERNEL_FOR_ALL_TYPE(SUB)
DECL_KERNEL_FOR_ALL_TYPE(ADD)
DECL_KERNEL_FOR_ALL_TYPE(MUL)
DECL_KERNEL_FOR_ALL_TYPE(DIV)
DECL_KERNEL_FOR_ALL_TYPE(REM)