Merge pull request #313306 from doronbehar/pkg/xsimd

This commit is contained in:
Doron Behar 2024-05-22 16:18:19 +03:00 committed by GitHub
commit 9d056f9c77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 27 additions and 210 deletions

View File

@ -1,39 +1,28 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, cmake
, doctest
}:
stdenv.mkDerivation (finalAttrs: {
pname = "xsimd";
version = "12.1.1";
version = "13.0.0";
src = fetchFromGitHub {
owner = "xtensor-stack";
repo = "xsimd";
rev = finalAttrs.version;
hash = "sha256-ofUFieeRtpnzNv3Ad5oYwKWb2XcqQHoj601TIhydJyI=";
hash = "sha256-qElJYW5QDj3s59L3NgZj5zkhnUMzIP2mBa1sPks3/CE=";
};
patches = [
# Ideally, Accelerate/Accelerate.h should be used for this implementation,
# but it doesn't work... Needs a Darwin user to debug this. We apply this
# patch unconditionally, because the #if macros make sure it doesn't
# interfer with the Linux implementations.
./fix-darwin-exp10-implementation.patch
] ++ lib.optionals stdenv.isDarwin [
# https://github.com/xtensor-stack/xsimd/issues/807
./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
# Fix of https://github.com/xtensor-stack/xsimd/pull/1024 for
# https://github.com/xtensor-stack/xsimd/issues/456 and
# https://github.com/xtensor-stack/xsimd/issues/807,
(fetchpatch {
url = "https://github.com/xtensor-stack/xsimd/commit/c8a87ed6e04b6782f48f94713adfb0cad6c11ddf.patch";
hash = "sha256-2/FvBGdqTPcayD7rdHPSzL+F8IYKAfMW0WBJ0cW9EZ0=";
})
];
nativeBuildInputs = [
@ -41,7 +30,9 @@ stdenv.mkDerivation (finalAttrs: {
];
cmakeFlags = [
"-DBUILD_TESTS=${if (finalAttrs.finalPackage.doCheck && stdenv.hostPlatform == stdenv.buildPlatform) then "ON" else "OFF"}"
# Always build the tests, even if not running them, because testing whether
# they can be built is a test in itself.
"-DBUILD_TESTS=ON"
];
doCheck = true;

View File

@ -1,36 +0,0 @@
commit 87433035c70578507e08565723c99158290f2488
Author: Doron Behar <doron.behar@gmail.com>
Date: Tue Aug 1 13:26:04 2023 +0300
Darwin & Musl: Disable failing exp10 test
--- a/test/test_xsimd_api.cpp
+++ b/test/test_xsimd_api.cpp
@@ -515,15 +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);
-#ifdef EMSCRIPTEN
- CHECK_EQ(extract(xsimd::exp10(T(val))), doctest::Approx(std::pow(value_type(10), val)));
-#else
- CHECK_EQ(extract(xsimd::exp10(T(val))), std::pow(value_type(10), val));
-#endif
- }
void test_exp2()
{
value_type val(2);
@@ -813,11 +804,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();

View File

@ -1,38 +0,0 @@
commit 9374b88b97911d9c6e19d5e764e25183cd45d534
Author: Doron Behar <doron.behar@gmail.com>
Date: Tue Aug 1 13:29:16 2023 +0300
aarch64-Darwin: Disable failing polar test
--- a/test/test_xsimd_api.cpp
+++ b/test/test_xsimd_api.cpp
@@ -661,17 +661,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);
-#ifndef EMSCRIPTEN
- CHECK_EQ(extract(xsimd::polar(T(val0), T(val1))), std::polar(val0, val1));
-#else
- CHECK_EQ(std::real(extract(xsimd::polar(T(val0), T(val1)))), doctest::Approx(std::real(std::polar(val0, val1))));
- CHECK_EQ(std::imag(extract(xsimd::polar(T(val0), T(val1)))), doctest::Approx(std::imag(std::polar(val0, val1))));
-#endif
- }
void test_pow()
{
value_type val0(2);
@@ -931,11 +920,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();

View File

@ -1,36 +0,0 @@
commit 3f751cef6b27ec13418a92c5b5f36b22bb5ffd55
Author: Doron Behar <doron.behar@gmail.com>
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
}
};

View File

@ -1,19 +0,0 @@
commit f60dad2c1d8ad47fbff761ce1cb027fc7c3a40e8
Author: Doron Behar <doron.behar@gmail.com>
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);
}

View File

@ -1,22 +0,0 @@
diff --git i/include/xsimd/arch/xsimd_scalar.hpp w/include/xsimd/arch/xsimd_scalar.hpp
index 9066da6..7aa3b6b 100644
--- i/include/xsimd/arch/xsimd_scalar.hpp
+++ w/include/xsimd/arch/xsimd_scalar.hpp
@@ -502,16 +502,7 @@ namespace xsimd
return !(x0 == x1);
}
-#if defined(__APPLE__)
- inline float exp10(const float& x) noexcept
- {
- return __exp10f(x);
- }
- inline double exp10(const double& x) noexcept
- {
- return __exp10(x);
- }
-#elif defined(__GLIBC__)
+#if defined(__GLIBC__)
inline float exp10(const float& x) noexcept
{
return ::exp10f(x);

View File

@ -13,24 +13,14 @@
stdenv.mkDerivation (finalAttrs: {
pname = "xtensor";
version = "0.24.7";
version = "0.25.0";
src = fetchFromGitHub {
owner = "xtensor-stack";
repo = "xtensor";
rev = finalAttrs.version;
hash = "sha256-dVbpcBW+jK9nIl5efk5LdKdBm8CkaJWEZ0ZY7ZuApwk=";
hash = "sha256-hVfdtYcJ6mzqj0AUu6QF9aVKQGYKd45RngY6UN3yOH4=";
};
patches = [
# Support for xsimd 11
(fetchpatch {
url = "https://github.com/xtensor-stack/xtensor/commit/77a650a8018e0be6fcc76bf66685ff352ae23ef1.patch";
hash = "sha256-vOdUzzsSK+lYcA7fZXWOTVV202GZC0DhkMMjzggnmWE=";
})
# A single test fails on Darwin, see:
# https://github.com/xtensor-stack/xtensor/issues/2718
./remove-failing-test_xinfo.patch
];
nativeBuildInputs = [
cmake
@ -38,18 +28,15 @@ stdenv.mkDerivation (finalAttrs: {
propagatedBuildInputs = [
nlohmann_json
xtl
] ++ lib.optionals (!(stdenv.isAarch64 && stdenv.isLinux)) [
# xsimd support is broken on aarch64-linux, see:
# https://github.com/xtensor-stack/xsimd/issues/945
xsimd
];
cmakeFlags = let
cmakeBool = x: if x then "ON" else "OFF";
in [
"-DBUILD_TESTS=${cmakeBool finalAttrs.finalPackage.doCheck}"
"-DXTENSOR_ENABLE_ASSERT=${cmakeBool enableAssertions}"
"-DXTENSOR_CHECK_DIMENSION=${cmakeBool enableBoundChecks}"
cmakeFlags = [
# Always build the tests, even if not running them, because testing whether
# they can be built is a test in itself.
(lib.cmakeBool "BUILD_TESTS" true)
(lib.cmakeBool "XTENSOR_ENABLE_ASSERT" enableAssertions)
(lib.cmakeBool "XTENSOR_CHECK_DIMENSION" enableBoundChecks)
];
doCheck = true;
@ -59,7 +46,7 @@ stdenv.mkDerivation (finalAttrs: {
checkTarget = "xtest";
meta = with lib; {
description = "Multi-dimensional arrays with broadcasting and lazy computing.";
description = "Multi-dimensional arrays with broadcasting and lazy computing";
homepage = "https://github.com/xtensor-stack/xtensor";
license = licenses.bsd3;
maintainers = with maintainers; [ cpcloud ];

View File

@ -1,12 +0,0 @@
diff --git i/test/CMakeLists.txt w/test/CMakeLists.txt
index 46127597..727b66bd 100644
--- i/test/CMakeLists.txt
+++ w/test/CMakeLists.txt
@@ -189,7 +189,6 @@ set(XTENSOR_TESTS
test_xhistogram.cpp
test_xpad.cpp
test_xindex_view.cpp
- test_xinfo.cpp
test_xio.cpp
test_xlayout.cpp
test_xmanipulation.cpp

View File

@ -11,13 +11,13 @@
toPythonModule (stdenv.mkDerivation(finalAttrs: {
pname = "xtensor-python";
version = "0.26.1";
version = "0.27.0";
src = fetchFromGitHub {
owner = "xtensor-stack";
repo = "xtensor-python";
rev = finalAttrs.version;
sha256 = "sha256-kLFt5Ah5/ZO6wfTZQviVXeIAVok+/F/XCwpgPSagOMo=";
sha256 = "sha256-Cy/aXuiriE/qxSd4Apipzak30DjgE7jX8ai1ThJ/VnE=";
};
nativeBuildInputs = [
@ -31,7 +31,9 @@ toPythonModule (stdenv.mkDerivation(finalAttrs: {
];
doCheck = true;
cmakeFlags = [
"-DBUILD_TESTS=${if finalAttrs.finalPackage.doCheck then "ON" else "OFF"}"
# Always build the tests, even if not running them, because testing whether
# they can be built is a test in itself.
"-DBUILD_TESTS=ON"
];
propagatedBuildInputs = [