diff --git a/libclc/generic/include/clc/math/fmin.h b/libclc/generic/include/clc/math/fmin.h index 5588ba93a8b8..d45f572e08b0 100644 --- a/libclc/generic/include/clc/math/fmin.h +++ b/libclc/generic/include/clc/math/fmin.h @@ -1,8 +1,5 @@ -#undef fmin -#define fmin __clc_fmin - #define __CLC_BODY -#define __CLC_FUNCTION __clc_fmin +#define __CLC_FUNCTION fmin #include diff --git a/libclc/generic/lib/math/fmin.cl b/libclc/generic/lib/math/fmin.cl index a61ad4757289..28c7d0125a93 100644 --- a/libclc/generic/lib/math/fmin.cl +++ b/libclc/generic/lib/math/fmin.cl @@ -1,11 +1,16 @@ #include +#include "../clcmacro.h" + +_CLC_DEFINE_BINARY_BUILTIN(float, fmin, __builtin_fminf, float, float); + #ifdef cl_khr_fp64 + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEFINE_BINARY_BUILTIN(double, fmin, __builtin_fmin, double, double); + #endif -#define FUNCTION __clc_fmin -#define FUNCTION_IMPL(x, y) ((y) < (x) ? (y) : (x)) - -#define __CLC_BODY +#define __CLC_BODY #include diff --git a/libclc/generic/lib/math/fmin.inc b/libclc/generic/lib/math/fmin.inc new file mode 100644 index 000000000000..d4b5ac2d62a7 --- /dev/null +++ b/libclc/generic/lib/math/fmin.inc @@ -0,0 +1,18 @@ + +#if !defined(__CLC_SCALAR) + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fmin(__CLC_GENTYPE x, float y) { + return fmin(x, (__CLC_GENTYPE)((__CLC_SCALAR_GENTYPE)y)); +} + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fmin(__CLC_GENTYPE x, double y) { + return fmin(x, (__CLC_GENTYPE)((__CLC_SCALAR_GENTYPE)y)); +} + +#endif // ifdef cl_khr_fp64 + +#endif // !defined(__CLC_SCALAR)