1#include <clc/clc.h> 2#include "../clcmacro.h" 3 4#define SIGN(TYPE, F) \ 5_CLC_DEF _CLC_OVERLOAD TYPE sign(TYPE x) { \ 6 if (isnan(x)) { \ 7 return 0.0F; \ 8 } \ 9 if (x > 0.0F) { \ 10 return 1.0F; \ 11 } \ 12 if (x < 0.0F) { \ 13 return -1.0F; \ 14 } \ 15 return x; /* -0.0 or +0.0 */ \ 16} 17 18SIGN(float, f) 19_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, sign, float) 20 21#ifdef cl_khr_fp64 22 23#pragma OPENCL EXTENSION cl_khr_fp64 : enable 24 25SIGN(double, ) 26_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, sign, double) 27 28#endif 29