Skip to content

Commit ce099c8

Browse files
committed
use builtins
1 parent 8cd4a8e commit ce099c8

File tree

2 files changed

+16
-67
lines changed

2 files changed

+16
-67
lines changed

libclc/clc/lib/spirv/math/clc_fmax.cl

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,25 @@
88

99
#include <clc/clcmacro.h>
1010
#include <clc/internal/clc.h>
11-
#include <clc/relational/clc_isnan.h>
1211

13-
#define __FLOAT_ONLY
14-
#define __CLC_MIN_VECSIZE 1
15-
#define FUNCTION __clc_fmax
16-
#define __IMPL_FUNCTION __builtin_fmaxf
17-
#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
18-
#include <clc/math/gentype.inc>
19-
#undef __CLC_MIN_VECSIZE
20-
#undef FUNCTION
21-
#undef __IMPL_FUNCTION
12+
_CLC_DEF _CLC_OVERLOAD float __clc_fmax(float x, float y) {
13+
return __builtin_fmaxf(x, y);
14+
}
2215

2316
#ifdef cl_khr_fp64
24-
2517
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
26-
27-
#define __DOUBLE_ONLY
28-
#define __CLC_MIN_VECSIZE 1
29-
#define FUNCTION __clc_fmax
30-
#define __IMPL_FUNCTION __builtin_fmax
31-
#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
32-
#include <clc/math/gentype.inc>
33-
#undef __CLC_MIN_VECSIZE
34-
#undef FUNCTION
35-
#undef __IMPL_FUNCTION
36-
18+
_CLC_DEF _CLC_OVERLOAD double __clc_fmax(double x, double y) {
19+
return __builtin_fmax(x, y);
20+
}
3721
#endif
3822

3923
#ifdef cl_khr_fp16
40-
4124
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
42-
4325
_CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) {
44-
if (__clc_isnan(x))
45-
return y;
46-
if (__clc_isnan(y))
47-
return x;
48-
return (x < y) ? y : x;
26+
return __builtin_fmaxf16(x, y);
4927
}
28+
#endif
5029

51-
#define __HALF_ONLY
52-
#define __CLC_SUPPORTED_VECSIZE_OR_1 2
5330
#define FUNCTION __clc_fmax
5431
#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
5532
#include <clc/math/gentype.inc>
56-
#undef FUNCTION
57-
58-
#endif

libclc/clc/lib/spirv/math/clc_fmin.cl

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,25 @@
88

99
#include <clc/clcmacro.h>
1010
#include <clc/internal/clc.h>
11-
#include <clc/relational/clc_isnan.h>
1211

13-
#define __FLOAT_ONLY
14-
#define __CLC_MIN_VECSIZE 1
15-
#define FUNCTION __clc_fmin
16-
#define __IMPL_FUNCTION __builtin_fminf
17-
#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
18-
#include <clc/math/gentype.inc>
19-
#undef __CLC_MIN_VECSIZE
20-
#undef FUNCTION
21-
#undef __IMPL_FUNCTION
12+
_CLC_DEF _CLC_OVERLOAD float __clc_fmin(float x, float y) {
13+
return __builtin_fminf(x, y);
14+
}
2215

2316
#ifdef cl_khr_fp64
24-
2517
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
26-
27-
#define __DOUBLE_ONLY
28-
#define __CLC_MIN_VECSIZE 1
29-
#define FUNCTION __clc_fmin
30-
#define __IMPL_FUNCTION __builtin_fmin
31-
#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
32-
#include <clc/math/gentype.inc>
33-
#undef __CLC_MIN_VECSIZE
34-
#undef FUNCTION
35-
#undef __IMPL_FUNCTION
36-
18+
_CLC_DEF _CLC_OVERLOAD double __clc_fmin(double x, double y) {
19+
return __builtin_fmin(x, y);
20+
}
3721
#endif
3822

3923
#ifdef cl_khr_fp16
40-
4124
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
42-
4325
_CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) {
44-
if (__clc_isnan(x))
45-
return y;
46-
if (__clc_isnan(y))
47-
return x;
48-
return (y < x) ? y : x;
26+
return __builtin_fminf16(x, y);
4927
}
28+
#endif
5029

51-
#define __HALF_ONLY
52-
#define __CLC_SUPPORTED_VECSIZE_OR_1 2
5330
#define FUNCTION __clc_fmin
5431
#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
5532
#include <clc/math/gentype.inc>
56-
57-
#endif

0 commit comments

Comments
 (0)