From a4a03bb261829d49d0cc19b06d435ce371addd5a Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Tue, 1 Aug 2023 13:38:11 +0300 Subject: [PATCH] xsimd: fix more failing tests Some tests fail on some platforms, and now every patch disables 1 test. --- pkgs/development/libraries/xsimd/default.nix | 15 ++++- .../xsimd/disable-darwin-failing-tests.patch | 58 ------------------- .../libraries/xsimd/disable-exp10-test.patch | 34 +++++++++++ .../libraries/xsimd/disable-polar-test.patch | 35 +++++++++++ .../xsimd/disable-test_error_gamma-test.patch | 36 ++++++++++++ .../libraries/xsimd/fix-atan-test.patch | 19 ++++++ 6 files changed, 136 insertions(+), 61 deletions(-) delete mode 100644 pkgs/development/libraries/xsimd/disable-darwin-failing-tests.patch create mode 100644 pkgs/development/libraries/xsimd/disable-exp10-test.patch create mode 100644 pkgs/development/libraries/xsimd/disable-polar-test.patch create mode 100644 pkgs/development/libraries/xsimd/disable-test_error_gamma-test.patch create mode 100644 pkgs/development/libraries/xsimd/fix-atan-test.patch diff --git a/pkgs/development/libraries/xsimd/default.nix b/pkgs/development/libraries/xsimd/default.nix index 6330739f3cd..a481a12932f 100644 --- a/pkgs/development/libraries/xsimd/default.nix +++ b/pkgs/development/libraries/xsimd/default.nix @@ -21,10 +21,19 @@ stdenv.mkDerivation rec { # interfer with the Linux implementations. ./fix-darwin-exp10-implementation.patch ] ++ lib.optionals stdenv.isDarwin [ - # Upstream reports: # https://github.com/xtensor-stack/xsimd/issues/807 - # https://github.com/xtensor-stack/xsimd/issues/917 - ./disable-darwin-failing-tests.patch + ./disable-test_error_gamma-test.patch + ] ++ lib.optionals (stdenv.isDarwin || stdenv.hostPlatform.isMusl) [ + # - Darwin report: https://github.com/xtensor-stack/xsimd/issues/917 + # - Musl report: https://github.com/xtensor-stack/xsimd/issues/798 + ./disable-exp10-test.patch + ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ + # https://github.com/xtensor-stack/xsimd/issues/798 + ./disable-polar-test.patch + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ + # Fix suggested here: https://github.com/xtensor-stack/xsimd/issues/798#issuecomment-1356884601 + # Upstream didn't merge that from some reason. + ./fix-atan-test.patch ]; nativeBuildInputs = [ diff --git a/pkgs/development/libraries/xsimd/disable-darwin-failing-tests.patch b/pkgs/development/libraries/xsimd/disable-darwin-failing-tests.patch deleted file mode 100644 index 246969e6d78..00000000000 --- a/pkgs/development/libraries/xsimd/disable-darwin-failing-tests.patch +++ /dev/null @@ -1,58 +0,0 @@ -diff --git i/test/test_error_gamma.cpp w/test/test_error_gamma.cpp -index 214cbb5..299e5b8 100644 ---- i/test/test_error_gamma.cpp -+++ w/test/test_error_gamma.cpp -@@ -131,25 +131,6 @@ struct error_gamma_test - INFO("lgamma"); - CHECK_EQ(diff, 0); - } --#if !(XSIMD_WITH_AVX && !XSIMD_WITH_AVX2) -- -- // tgamma (negative input) -- { -- std::transform(gamma_neg_input.cbegin(), gamma_neg_input.cend(), expected.begin(), -- [](const value_type& v) -- { return std::lgamma(v); }); -- batch_type in, out; -- for (size_t i = 0; i < nb_input; i += size) -- { -- detail::load_batch(in, gamma_neg_input, i); -- out = lgamma(in); -- detail::store_batch(out, res, i); -- } -- size_t diff = detail::get_nb_diff(res, expected); -- INFO("lgamma (negative input)"); -- CHECK_EQ(diff, 0); -- } --#endif - } - }; - -diff --git i/test/test_xsimd_api.cpp w/test/test_xsimd_api.cpp -index 84b4b0b..1b29742 100644 ---- i/test/test_xsimd_api.cpp -+++ w/test/test_xsimd_api.cpp -@@ -515,11 +515,6 @@ struct xsimd_api_float_types_functions - value_type val(2); - CHECK_EQ(extract(xsimd::exp(T(val))), std::exp(val)); - } -- void test_exp10() -- { -- value_type val(2); -- CHECK_EQ(extract(xsimd::exp10(T(val))), std::pow(value_type(10), val)); -- } - void test_exp2() - { - value_type val(2); -@@ -804,11 +799,6 @@ TEST_CASE_TEMPLATE("[xsimd api | float types functions]", B, FLOAT_TYPES) - Test.test_exp(); - } - -- SUBCASE("exp10") -- { -- Test.test_exp10(); -- } -- - SUBCASE("exp2") - { - Test.test_exp2(); diff --git a/pkgs/development/libraries/xsimd/disable-exp10-test.patch b/pkgs/development/libraries/xsimd/disable-exp10-test.patch new file mode 100644 index 00000000000..62e24e18c6b --- /dev/null +++ b/pkgs/development/libraries/xsimd/disable-exp10-test.patch @@ -0,0 +1,34 @@ +commit 87433035c70578507e08565723c99158290f2488 +Author: Doron Behar +Date: Tue Aug 1 13:26:04 2023 +0300 + + Darwin & Musl: Disable failing exp10 test + +diff --git a/test/test_xsimd_api.cpp b/test/test_xsimd_api.cpp +index 84b4b0b..1b29742 100644 +--- a/test/test_xsimd_api.cpp ++++ b/test/test_xsimd_api.cpp +@@ -515,11 +515,6 @@ struct xsimd_api_float_types_functions + value_type val(2); + CHECK_EQ(extract(xsimd::exp(T(val))), std::exp(val)); + } +- void test_exp10() +- { +- value_type val(2); +- CHECK_EQ(extract(xsimd::exp10(T(val))), std::pow(value_type(10), val)); +- } + void test_exp2() + { + value_type val(2); +@@ -804,11 +799,6 @@ TEST_CASE_TEMPLATE("[xsimd api | float types functions]", B, FLOAT_TYPES) + Test.test_exp(); + } + +- SUBCASE("exp10") +- { +- Test.test_exp10(); +- } +- + SUBCASE("exp2") + { + Test.test_exp2(); diff --git a/pkgs/development/libraries/xsimd/disable-polar-test.patch b/pkgs/development/libraries/xsimd/disable-polar-test.patch new file mode 100644 index 00000000000..cbb7c0313c6 --- /dev/null +++ b/pkgs/development/libraries/xsimd/disable-polar-test.patch @@ -0,0 +1,35 @@ +commit 9374b88b97911d9c6e19d5e764e25183cd45d534 +Author: Doron Behar +Date: Tue Aug 1 13:29:16 2023 +0300 + + aarch64-Darwin: Disable failing polar test + +diff --git a/test/test_xsimd_api.cpp b/test/test_xsimd_api.cpp +index 1b29742..03c6b4b 100644 +--- a/test/test_xsimd_api.cpp ++++ b/test/test_xsimd_api.cpp +@@ -652,12 +652,6 @@ struct xsimd_api_float_types_functions + value_type val1(4); + CHECK_EQ(extract(xsimd::nextafter(T(val0), T(val1))), std::nextafter(val0, val1)); + } +- void test_polar() +- { +- value_type val0(3); +- value_type val1(4); +- CHECK_EQ(extract(xsimd::polar(T(val0), T(val1))), std::polar(val0, val1)); +- } + void test_pow() + { + value_type val0(2); +@@ -912,11 +906,6 @@ TEST_CASE_TEMPLATE("[xsimd api | float types functions]", B, FLOAT_TYPES) + Test.test_nextafter(); + } + +- SUBCASE("polar") +- { +- Test.test_polar(); +- } +- + SUBCASE("pow") + { + Test.test_pow(); diff --git a/pkgs/development/libraries/xsimd/disable-test_error_gamma-test.patch b/pkgs/development/libraries/xsimd/disable-test_error_gamma-test.patch new file mode 100644 index 00000000000..a7344d231b8 --- /dev/null +++ b/pkgs/development/libraries/xsimd/disable-test_error_gamma-test.patch @@ -0,0 +1,36 @@ +commit 3f751cef6b27ec13418a92c5b5f36b22bb5ffd55 +Author: Doron Behar +Date: Tue Aug 1 13:24:34 2023 +0300 + + Darwin: Disable failing test from test_error_gamma.cpp + +diff --git a/test/test_error_gamma.cpp b/test/test_error_gamma.cpp +index 214cbb5..299e5b8 100644 +--- a/test/test_error_gamma.cpp ++++ b/test/test_error_gamma.cpp +@@ -131,25 +131,6 @@ struct error_gamma_test + INFO("lgamma"); + CHECK_EQ(diff, 0); + } +-#if !(XSIMD_WITH_AVX && !XSIMD_WITH_AVX2) +- +- // tgamma (negative input) +- { +- std::transform(gamma_neg_input.cbegin(), gamma_neg_input.cend(), expected.begin(), +- [](const value_type& v) +- { return std::lgamma(v); }); +- batch_type in, out; +- for (size_t i = 0; i < nb_input; i += size) +- { +- detail::load_batch(in, gamma_neg_input, i); +- out = lgamma(in); +- detail::store_batch(out, res, i); +- } +- size_t diff = detail::get_nb_diff(res, expected); +- INFO("lgamma (negative input)"); +- CHECK_EQ(diff, 0); +- } +-#endif + } + }; + diff --git a/pkgs/development/libraries/xsimd/fix-atan-test.patch b/pkgs/development/libraries/xsimd/fix-atan-test.patch new file mode 100644 index 00000000000..3d1517610aa --- /dev/null +++ b/pkgs/development/libraries/xsimd/fix-atan-test.patch @@ -0,0 +1,19 @@ +commit f60dad2c1d8ad47fbff761ce1cb027fc7c3a40e8 +Author: Doron Behar +Date: Tue Aug 1 13:47:37 2023 +0300 + + Musl: Fix atan test from test_complex_trigonometric.cpp + +diff --git a/test/test_complex_trigonometric.cpp b/test/test_complex_trigonometric.cpp +index a486110..691db77 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-12); + CHECK_EQ(diff, 0); + } +