|
6 | 6 | // |
7 | 7 | //===----------------------------------------------------------------------===// |
8 | 8 |
|
9 | | -#include <clc/clcmacro.h> |
10 | 9 | #include <clc/internal/clc.h> |
11 | | -#include <clc/relational/clc_isnan.h> |
| 10 | +#include <clc/math/clc_fmin.h> |
12 | 11 |
|
13 | | -_CLC_DEF _CLC_OVERLOAD float __clc_fmin(float x, float y) { |
14 | | - // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise |
15 | | - // fmin instruction flushes the values for comparison, but outputs original |
16 | | - // denormal |
17 | | - x = __builtin_canonicalizef(x); |
18 | | - y = __builtin_canonicalizef(y); |
19 | | - return __builtin_fminf(x, y); |
20 | | -} |
21 | | -_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __clc_fmin, float, float) |
| 12 | +#define __CLC_FUNCTION __clc_fmin |
| 13 | +#define __CLC_BUILTIN __ocml_fmin |
22 | 14 |
|
23 | | -#ifdef cl_khr_fp64 |
| 15 | +float __ocml_fmin_f32(float, float); |
| 16 | +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, _f32) |
24 | 17 |
|
| 18 | +#ifdef cl_khr_fp64 |
25 | 19 | #pragma OPENCL EXTENSION cl_khr_fp64 : enable |
26 | | - |
27 | | -_CLC_DEF _CLC_OVERLOAD double __clc_fmin(double x, double y) { |
28 | | - x = __builtin_canonicalize(x); |
29 | | - y = __builtin_canonicalize(y); |
30 | | - return __builtin_fmin(x, y); |
31 | | -} |
32 | | -_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __clc_fmin, double, |
33 | | - double) |
34 | | - |
35 | | -#endif |
| 20 | +double __ocml_fmin_f64(double, double); |
| 21 | +#define __CLC_BUILTIN_D __CLC_XCONCAT(__CLC_BUILTIN, _f64) |
| 22 | +#endif // cl_khr_fp64 |
36 | 23 |
|
37 | 24 | #ifdef cl_khr_fp16 |
38 | | - |
39 | 25 | #pragma OPENCL EXTENSION cl_khr_fp16 : enable |
| 26 | +half __ocml_fmin_f16(half, half); |
| 27 | +#define __CLC_BUILTIN_H __CLC_XCONCAT(__CLC_BUILTIN, _f16) |
| 28 | +#endif // cl_khr_fp16 |
40 | 29 |
|
41 | | -_CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) { |
42 | | - if (__clc_isnan(x)) |
43 | | - return y; |
44 | | - if (__clc_isnan(y)) |
45 | | - return x; |
46 | | - return (y < x) ? y : x; |
47 | | -} |
48 | | -_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_fmin, half, half) |
49 | | - |
50 | | -#endif |
| 30 | +#include <clc/math/binary_builtin.inc> |
0 commit comments