Skip to content

Commit f85999b

Browse files
authored
[SYCL][NativeCPU] Fix __clc_exp10. (#17403)
In the libspirv builtins, no definitions of fma and ldexp are provided, and there must be no references to them. Call __spirv_ocl_fma and __spirv_ocl_ldexp instead.
1 parent 2045895 commit f85999b

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

libclc/libspirv/lib/generic/math/clc_exp10.cl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,27 @@ _CLC_DEF _CLC_OVERLOAD double __clc_exp10(double x) {
123123
int m = n >> 6;
124124

125125
double r =
126-
R_LN10 * fma(-R_LOG10_2_BY_64_TL, dn, fma(-R_LOG10_2_BY_64_LD, dn, x));
126+
R_LN10 * __spirv_ocl_fma(-R_LOG10_2_BY_64_TL, dn,
127+
__spirv_ocl_fma(-R_LOG10_2_BY_64_LD, dn, x));
127128

128129
// 6 term tail of Taylor expansion of e^r
129130
double z2 =
130-
r *
131-
fma(r,
132-
fma(r,
133-
fma(r,
134-
fma(r, fma(r, 0x1.6c16c16c16c17p-10, 0x1.1111111111111p-7),
135-
0x1.5555555555555p-5),
136-
0x1.5555555555555p-3),
137-
0x1.0000000000000p-1),
138-
1.0);
131+
r * __spirv_ocl_fma(
132+
r,
133+
__spirv_ocl_fma(
134+
r,
135+
__spirv_ocl_fma(
136+
r,
137+
__spirv_ocl_fma(r,
138+
__spirv_ocl_fma(r, 0x1.6c16c16c16c17p-10,
139+
0x1.1111111111111p-7),
140+
0x1.5555555555555p-5),
141+
0x1.5555555555555p-3),
142+
0x1.0000000000000p-1),
143+
1.0);
139144

140145
double2 tv = USE_TABLE(two_to_jby64_ep_tbl, j);
141-
z2 = fma(tv.s0 + tv.s1, z2, tv.s1) + tv.s0;
146+
z2 = __spirv_ocl_fma(tv.s0 + tv.s1, z2, tv.s1) + tv.s0;
142147

143148
int small_value = (m < -1022) || ((m == -1022) && (z2 < 1.0));
144149

@@ -147,7 +152,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_exp10(double x) {
147152
double z3 = z2 * as_double(((long)n1 + 1023) << 52);
148153
z3 *= as_double(((long)n2 + 1023) << 52);
149154

150-
z2 = ldexp(z2, m);
155+
z2 = __spirv_ocl_ldexp(z2, m);
151156
z2 = small_value ? z3 : z2;
152157

153158
z2 = __clc_isnan(x) ? x : z2;

0 commit comments

Comments
 (0)