xsimd icon indicating copy to clipboard operation
xsimd copied to clipboard

failing tests on alpine linux

Open a16bitsysop opened this issue 3 years ago • 18 comments

I am trying to package for alpine linux and 2 tests are failing:

xsimd-8.1.0/test/test_complex_trigonometric.cpp:160: Failure
[1330](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1330)Expected equality of these values:
[1331](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1331)  diff
[1332](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1332)    Which is: 1
[1333](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1333)  0
[1334](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1334)  while testing atan
[1335](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1335)[  FAILED  ] complex_trigonometric_test/fallback_complex<float>.atan, where TypeParam = xsimd::batch<std::complex<float>, xsimd::fma3<xsimd::avx2> > (4 ms)

xsimd-8.1.0/test/test_complex_trigonometric.cpp:160: Failure
[1352](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1352)Expected equality of these values:
[1353](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1353)  diff
[1354](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1354)    Which is: 1
[1355](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1355)  0
[1356](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1356)  while testing atan
[1357](https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/793063#L1357)[  FAILED  ] complex_trigonometric_test/fallback_complex<double>.atan, where TypeParam = xsimd::batch<std::complex<double>, xsimd::fma3<xsimd::avx2> > (3 ms)

The same test fails of x86_64, x86, and aarch64. Both the x86_64 and x86 use xsimd::fma3<xsimd::avx2> and aarch64 uses xsimd::neon64

a16bitsysop avatar Aug 06 '22 08:08 a16bitsysop

hey, sorry for the late answer. We've been doing quite a few updates to xsimd since you raised that issue. Any chance you would give it another try?

serge-sans-paille avatar Oct 01 '22 16:10 serge-sans-paille

I tried 10.0.0rc0 and the failure is the same, it’s the same on my pc and the builders: https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/860020

a16bitsysop avatar Oct 02 '22 11:10 a16bitsysop

how strange, I don't reproduce on my machine... can you share the content of the build.sh mentioned in the logfile?

serge-sans-paille avatar Oct 02 '22 18:10 serge-sans-paille

its here: https://gitlab.alpinelinux.org/alpine/infra/docker/alpine-gitlab-ci/-/blob/master/overlay/usr/local/bin/build.sh

a16bitsysop avatar Oct 02 '22 19:10 a16bitsysop

Thanks. I've been investigating a bit and I cannot find any compiler flag that would be responsible for the difference. Can you share an extract of the output of the make VERBOSE=1 command when you build (and reproduce!) locally? Just to double check the flags.

I'd also be interested in the output of ldd ./test/test_xsimd.

Thanks!

serge-sans-paille avatar Oct 03 '22 06:10 serge-sans-paille

The verbose output is here: https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/861033

The flags are the same locally, but I noticed the arch is native. But that shouldn't make a difference for compiling tests on same processor as run should it?

Output of ldd test_xsimd: ``` /lib/ld-musl-x86_64.so.1 (0x7f413efc6000) libgtest.so.1.12.1 => /usr/lib/libgtest.so.1.12.1 (0x7f413e530000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f413e2e2000) libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f413e2c4000) libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f413efc6000)

a16bitsysop avatar Oct 03 '22 18:10 a16bitsysop

@a16bitsysop is it possible to link with GNU libm instead of musl to provide math symbol? I just want to check if the difference may come from different reference math routines.

serge-sans-paille avatar Dec 13 '22 20:12 serge-sans-paille

I could try newlib libm as that is already packaged for alpine aarch64, as same test failed for arch64.

How can I get xsimd to find newlib? https://pkgs.alpinelinux.org/contents?branch=edge&name=newlib-aarch64-none-elf&arch=aarch64&repo=community

a16bitsysop avatar Dec 13 '22 20:12 a16bitsysop

Probably add

target_link_libraries(test_xsimd m)

to test/CMakeLists.txt

or add the path of your math library in the LD_PRELOAD environment variable?

serge-sans-paille avatar Dec 13 '22 21:12 serge-sans-paille

okay will have a go

a16bitsysop avatar Dec 13 '22 22:12 a16bitsysop

I had a go but couldn’t get it working, is there a way to make a simple test case with just this code? It could rely on an installed xsimd in alpine. Then I could post to the musl mailing list, if you think it is a musl problem.

a16bitsysop avatar Dec 18 '22 08:12 a16bitsysop

there is openlibm as well, it is packaged for alpine as well: https://openlibm.org/

a16bitsysop avatar Dec 18 '22 16:12 a16bitsysop

Can you giva a try to the following patch?

diff --git a/test/test_complex_trigonometric.cpp b/test/test_complex_trigonometric.cpp
index a486110..8878d00 100644
--- a/test/test_complex_trigonometric.cpp
+++ b/test/test_complex_trigonometric.cpp
@@ -155,7 +155,7 @@ struct complex_trigonometric_test
             out = atan(in);
             detail::store_batch(out, res, i);
         }
-        size_t diff = detail::get_nb_diff(res, expected);
+        size_t diff = detail::get_nb_diff_near(res, expected, 1e-10);
         CHECK_EQ(diff, 0);
     }
 

eventually changing 1e-10 ei 1e-8 (worst case) or 1e-12 better case?

serge-sans-paille avatar Dec 18 '22 21:12 serge-sans-paille

yes that works for x86 x86_64 and aarch64 https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/930009

does that prove what is the problem?

a16bitsysop avatar Dec 18 '22 23:12 a16bitsysop

On Sun, Dec 18, 2022 at 03:15:55PM -0800, Duncan Bellamy wrote:

yes that works for x86 x86_64 and aarch64 [1]https://gitlab.alpinelinux.org/ a16bitsysop/aports/-/jobs/930009

does that prove what is the problem?

It confirms a slight accuracy issue. I wonder how low you can get the third number (it's a trashold). If it's rather low, I can apply that patch globally.

serge-sans-paille avatar Dec 19 '22 08:12 serge-sans-paille

Okay, 1e-1 works and le-8 works as well.

Like this: https://gitlab.alpinelinux.org/alpine/aports/-/blob/12e022ad2c65af6b696a087bf806f670ca049812/community/xsimd/test.patch

Pipeline for le-1 https://gitlab.alpinelinux.org/a16bitsysop/aports/-/jobs/930473

a16bitsysop avatar Dec 19 '22 10:12 a16bitsysop

xsimd 11.0.0 has 2 more test failures, that look like they should pass:

xsimd/src/xsimd-11.0.0/test/test_xsimd_api.cpp:695:
TEST CASE:  [xsimd api | float types functions]<float>
  exp10

xsimd/src/xsimd-11.0.0/test/test_xsimd_api.cpp:466: ERROR: CHECK_EQ( extract(xsimd::exp10(T(val))), std::pow(value_type(10), val) ) is NOT correct!
  values: CHECK_EQ( 100, 100 )

===============================================================================
xsimd/src/xsimd-11.0.0/test/test_xsimd_api.cpp:695:
TEST CASE:  [xsimd api | float types functions]<double>
  exp10
xsimd-11.0.0/test/test_xsimd_api.cpp:466: ERROR: CHECK_EQ( extract(xsimd::exp10(T(val))), std::pow(value_type(10), val) ) is NOT correct!
  values: CHECK_EQ( 100, 100 )

On alpine the tests fail to compile with gcc for 11.0.0 as well with:

xsimd-11.0.0/include/xsimd/arch/xsimd_scalar.hpp:500:37: error: unable to find numeric literal operator 'operator""f'
  500 |         return std::exp(0x1.26bb1cp+1f * x);
      |                                     ^~

a16bitsysop avatar Apr 07 '23 11:04 a16bitsysop

Can confirm the same test failures on 11.1.0 on NixOS with musl libc.

yu-re-ka avatar Jul 31 '23 22:07 yu-re-ka