summaryrefslogtreecommitdiff
path: root/kernels/compiler_abs.cl
blob: 549575c2485ae0ad52a1d8b321e0cd8832b5a192 (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
#define COMPILER_ABS_FUNC_1(TYPE, UTYPE) \
    kernel void compiler_abs_##TYPE ( \
           global TYPE* src, global UTYPE* dst) { \
        int i = get_global_id(0); \
        dst[i] = abs(src[i]);     \
    }

#define COMPILER_ABS_FUNC_N(TYPE, UTYPE, N) \
    kernel void compiler_abs_##TYPE##N ( \
           global TYPE##N* src, global UTYPE##N* dst) { \
        int i = get_global_id(0); \
        dst[i] = abs(src[i]);     \
    }

#define COMPILER_ABS(TYPE, UTYPE)  \
    COMPILER_ABS_FUNC_1(TYPE, UTYPE) \
    COMPILER_ABS_FUNC_N(TYPE, UTYPE, 2) \
    COMPILER_ABS_FUNC_N(TYPE, UTYPE, 3) \
    COMPILER_ABS_FUNC_N(TYPE, UTYPE, 4) \
    COMPILER_ABS_FUNC_N(TYPE, UTYPE, 8) \
    COMPILER_ABS_FUNC_N(TYPE, UTYPE, 16)

COMPILER_ABS(int, uint)
COMPILER_ABS(uint, uint)
COMPILER_ABS(char, uchar)
COMPILER_ABS(uchar, uchar)
COMPILER_ABS(short, ushort)
COMPILER_ABS(ushort, ushort)