Implement C23 log2p1
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon Apr 15 13:52:43 GMT 2024
On 15/04/24 10:41, Carlos O'Donell wrote:
> On 4/8/24 17:19, Joseph Myers wrote:
>> C23 adds various <math.h> function families originally defined in TS
>> 18661-4. Add the log2p1 functions (log2(1+x): like log1p, but for
>> base-2 logarithms).
>>
>> This illustrates the intended structure of implementations of all
>> these function families: define them initially with a type-generic
>> template implementation. If someone wishes to add type-specific
>> implementations, it is likely such implementations can be both faster
>> and more accurate than the type-generic one and can then override it
>> for types for which they are implemented (adding benchmarks would be
>> desirable in such cases to demonstrate that a new implementation is
>> indeed faster).
>>
>> The test inputs are copied from those for log1p. Note that these
>> changes make gen-auto-libm-tests depend on MPFR 4.2 (or later).
>>
>> The bulk of the changes are fairly generic for any such new function.
>> (sysdeps/powerpc/nofpu/Makefile only needs changing for those
>> type-generic templates that use fabs.)
>>
>> Tested for x86_64 and x86, and with build-many-glibcs.py.
>
> This fails CI for glibc:
> https://patchwork.sourceware.org/project/glibc/patch/41a4a6c9-4942-a9be-9459-1aaeb44ffee8@redhat.com/
>
> Please review the results and work with Linaro to ensure this passes.
>
These are the required ULPs update for arm and powerpc:
diff --git a/sysdeps/aarch64/libm-test-ulps b/sysdeps/aarch64/libm-test-ulps
index 116a5404f5..43aa07ba10 100644
--- a/sysdeps/aarch64/libm-test-ulps
+++ b/sysdeps/aarch64/libm-test-ulps
@@ -1355,6 +1355,26 @@ double: 3
float: 3
ldouble: 1
+Function: "log2p1":
+double: 1
+float: 1
+ldouble: 3
+
+Function: "log2p1_downward":
+double: 2
+float: 2
+ldouble: 3
+
+Function: "log2p1_towardzero":
+double: 2
+float: 2
+ldouble: 2
+
+Function: "log2p1_upward":
+double: 1
+float: 2
+ldouble: 2
+
Function: "log_advsimd":
double: 1
float: 3
diff --git a/sysdeps/arm/libm-test-ulps b/sysdeps/arm/libm-test-ulps
index 5720e73288..fc7ba1439a 100644
--- a/sysdeps/arm/libm-test-ulps
+++ b/sysdeps/arm/libm-test-ulps
@@ -965,6 +965,22 @@ Function: "log2_upward":
double: 3
float: 3
+Function: "log2p1":
+double: 1
+float: 1
+
+Function: "log2p1_downward":
+double: 2
+float: 2
+
+Function: "log2p1_towardzero":
+double: 2
+float: 2
+
+Function: "log2p1_upward":
+double: 1
+float: 2
+
Function: "log_downward":
float: 2
diff --git a/sysdeps/powerpc/fpu/libm-test-ulps b/sysdeps/powerpc/fpu/libm-test-ulps
index dbf71d8194..78e9a9ad6e 100644
--- a/sysdeps/powerpc/fpu/libm-test-ulps
+++ b/sysdeps/powerpc/fpu/libm-test-ulps
@@ -1506,6 +1506,30 @@ float: 3
float128: 1
ldouble: 4
+Function: "log2p1":
+double: 1
+float: 1
+float128: 2
+ldouble: 2
+
+Function: "log2p1_downward":
+double: 2
+float: 2
+float128: 3
+ldouble: 4
+
+Function: "log2p1_towardzero":
+double: 2
+float: 2
+float128: 2
+ldouble: 4
+
+Function: "log2p1_upward":
+double: 1
+float: 2
+float128: 2
+ldouble: 4
+
Function: "log_downward":
float: 2
float128: 1
More information about the Libc-alpha
mailing list