Skip to content

Commit 200e650

Browse files
committed
[libclc] Move __clc_fmod to the CLC library
1 parent e480113 commit 200e650

File tree

7 files changed

+31
-10
lines changed

7 files changed

+31
-10
lines changed

libclc/generic/include/math/clc_fmod.h renamed to libclc/clc/include/clc/math/clc_fmod.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_MATH_CLC_FMOD_H__
10+
#define __CLC_MATH_CLC_FMOD_H__
11+
912
#define __CLC_FUNCTION __clc_fmod
10-
#define __CLC_BODY <clc/math/binary_decl_tt.inc>
13+
#define __CLC_BODY <clc/shared/binary_decl.inc>
14+
1115
#include <clc/math/gentype.inc>
16+
17+
#undef __CLC_BODY
1218
#undef __CLC_FUNCTION
19+
20+
#endif // __CLC_MATH_CLC_FMOD_H__

libclc/clc/lib/generic/SOURCES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ math/clc_copysign.cl
3333
math/clc_ep_log.cl
3434
math/clc_fabs.cl
3535
math/clc_fma.cl
36+
math/clc_fmod.cl
3637
math/clc_floor.cl
3738
math/clc_frexp.cl
3839
math/clc_hypot.cl

libclc/generic/lib/math/clc_fmod.cl renamed to libclc/clc/lib/generic/math/clc_fmod.cl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include <clc/clc.h>
109
#include <clc/clc_convert.h>
1110
#include <clc/clcmacro.h>
1211
#include <clc/integer/clc_clz.h>
12+
#include <clc/internal/clc.h>
1313
#include <clc/math/clc_floor.h>
1414
#include <clc/math/clc_fma.h>
15-
#include <clc/math/clc_subnormal_config.h>
15+
#include <clc/math/clc_ldexp.h>
1616
#include <clc/math/clc_trunc.h>
1717
#include <clc/math/math.h>
1818
#include <clc/shared/clc_max.h>
@@ -66,6 +66,9 @@ _CLC_DEF _CLC_OVERLOAD float __clc_fmod(float x, float y) {
6666
_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_fmod, float, float);
6767

6868
#ifdef cl_khr_fp64
69+
70+
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
71+
6972
_CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y) {
7073
ulong ux = __clc_as_ulong(x);
7174
ulong ax = ux & ~SIGNBIT_DP64;
@@ -91,7 +94,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y) {
9194
// but it doesn't matter - it just means that we'll go round
9295
// the loop below one extra time.
9396
int ntimes = __clc_max(0, (xexp1 - yexp1) / 53);
94-
double w = ldexp(dy, ntimes * 53);
97+
double w = __clc_ldexp(dy, ntimes * 53);
9598
w = ntimes == 0 ? dy : w;
9699
double scale = ntimes == 0 ? 1.0 : 0x1.0p-53;
97100

@@ -170,3 +173,15 @@ _CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y) {
170173
_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_fmod, double,
171174
double);
172175
#endif
176+
177+
#ifdef cl_khr_fp16
178+
179+
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
180+
181+
// Forward the half version of this builtin onto the float one
182+
#define __HALF_ONLY
183+
#define __CLC_FUNCTION __clc_fmod
184+
#define __CLC_BODY <clc/math/binary_def_via_fp32.inc>
185+
#include <clc/math/gentype.inc>
186+
187+
#endif

libclc/clspv/lib/SOURCES

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ subnormal_config.cl
1717
../../generic/lib/math/atanpi.cl
1818
../../generic/lib/math/cbrt.cl
1919
../../generic/lib/math/clc_exp10.cl
20-
../../generic/lib/math/clc_fmod.cl
2120
../../generic/lib/math/clc_pow.cl
2221
../../generic/lib/math/clc_pown.cl
2322
../../generic/lib/math/clc_powr.cl

libclc/generic/lib/SOURCES

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ math/floor.cl
108108
math/fma.cl
109109
math/fmax.cl
110110
math/fmin.cl
111-
math/clc_fmod.cl
112111
math/fmod.cl
113112
math/fract.cl
114113
math/frexp.cl

libclc/generic/lib/math/fmod.cl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include <clc/clc.h>
10-
#include <math/clc_fmod.h>
10+
#include <clc/math/clc_fmod.h>
1111

12-
#define __CLC_FUNC fmod
13-
#define __CLC_BODY <clc_sw_binary.inc>
12+
#define FUNCTION fmod
13+
#define __CLC_BODY <clc/shared/binary_def.inc>
1414
#include <clc/math/gentype.inc>

libclc/spirv/lib/SOURCES

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ subnormal_config.cl
4141
../../generic/lib/math/clc_exp10.cl
4242
../../generic/lib/math/exp10.cl
4343
math/fma.cl
44-
../../generic/lib/math/clc_fmod.cl
4544
../../generic/lib/math/fmod.cl
4645
../../generic/lib/math/fract.cl
4746
../../generic/lib/math/frexp.cl

0 commit comments

Comments
 (0)