Skip to content

[SYCL][NativeCPU] Fix __clc_exp10. #17403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions libclc/libspirv/lib/generic/math/clc_exp10.cl
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,27 @@ _CLC_DEF _CLC_OVERLOAD double __clc_exp10(double x) {
int m = n >> 6;

double r =
R_LN10 * fma(-R_LOG10_2_BY_64_TL, dn, fma(-R_LOG10_2_BY_64_LD, dn, x));
R_LN10 * __spirv_ocl_fma(-R_LOG10_2_BY_64_TL, dn,
__spirv_ocl_fma(-R_LOG10_2_BY_64_LD, dn, x));

// 6 term tail of Taylor expansion of e^r
double z2 =
r *
fma(r,
fma(r,
fma(r,
fma(r, fma(r, 0x1.6c16c16c16c17p-10, 0x1.1111111111111p-7),
0x1.5555555555555p-5),
0x1.5555555555555p-3),
0x1.0000000000000p-1),
1.0);
r * __spirv_ocl_fma(
r,
__spirv_ocl_fma(
r,
__spirv_ocl_fma(
r,
__spirv_ocl_fma(r,
__spirv_ocl_fma(r, 0x1.6c16c16c16c17p-10,
0x1.1111111111111p-7),
0x1.5555555555555p-5),
0x1.5555555555555p-3),
0x1.0000000000000p-1),
1.0);

double2 tv = USE_TABLE(two_to_jby64_ep_tbl, j);
z2 = fma(tv.s0 + tv.s1, z2, tv.s1) + tv.s0;
z2 = __spirv_ocl_fma(tv.s0 + tv.s1, z2, tv.s1) + tv.s0;

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

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

z2 = ldexp(z2, m);
z2 = __spirv_ocl_ldexp(z2, m);
z2 = small_value ? z3 : z2;

z2 = __clc_isnan(x) ? x : z2;
Expand Down
Loading