From bd4a61d518ee518286a73a301a7f6df7714a25b8 Mon Sep 17 00:00:00 2001 From: Yves Delley Date: Sun, 15 Sep 2024 17:36:14 +0200 Subject: [PATCH 1/3] added test for upstream clang on macos-14, as an example for an arm64 platform --- .github/workflows/ci-test-package-cmake.yml | 25 ++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-test-package-cmake.yml b/.github/workflows/ci-test-package-cmake.yml index df1cae9f2..979ed1be9 100644 --- a/.github/workflows/ci-test-package-cmake.yml +++ b/.github/workflows/ci-test-package-cmake.yml @@ -136,6 +136,20 @@ jobs: cxx_modules: "False", std_format_support: "True" } + - { + name: "Clang-18 on Apple M1 (arm64)", + os: macos-14, + compiler: + { + type: CLANG, + version: 18, + cc: "/opt/homebrew/opt/llvm@18/bin/clang-18", + cxx: "/opt/homebrew/opt/llvm@18/bin/clang++", + }, + lib: "libc++", + cxx_modules: "False", + std_format_support: "True" + } - { name: "Apple Clang 15", os: macos-14, @@ -188,8 +202,8 @@ jobs: shell: bash run: | sudo apt install -y g++-${{ matrix.config.compiler.version }} - - name: Install Clang - if: matrix.config.compiler.type == 'CLANG' + - name: Install Clang with apt + if: matrix.config.compiler.type == 'CLANG' && matrix.config.os != 'macos-14' shell: bash working-directory: ${{ env.HOME }} run: | @@ -197,8 +211,13 @@ jobs: chmod +x llvm.sh sudo ./llvm.sh ${{ matrix.config.compiler.version }} sudo apt install -y clang-tools-${{ matrix.config.compiler.version }} + - name: Install Clang using homebrew + if: matrix.config.compiler.type == 'CLANG' && matrix.config.os == 'macos-14' + shell: bash + run: | + brew install llvm@18 - name: Install Libc++ - if: matrix.config.compiler.type == 'CLANG' && matrix.config.lib == 'libc++' + if: matrix.config.compiler.type == 'CLANG' && matrix.config.lib == 'libc++' && matrix.config.os != 'macos-14' shell: bash run: | sudo apt install -y libc++-${{ matrix.config.compiler.version }}-dev libc++abi-${{ matrix.config.compiler.version }}-dev libunwind-${{ matrix.config.compiler.version }}-dev From 25534c6998a0b79b6f356b7a32c4576d1094db05 Mon Sep 17 00:00:00 2001 From: Yves Delley Date: Sun, 15 Sep 2024 18:34:28 +0200 Subject: [PATCH 2/3] also run conan tests on macOS 14 (again, an example for arm64) --- .github/workflows/ci-conan.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-conan.yml b/.github/workflows/ci-conan.yml index 58df08808..380bbae52 100644 --- a/.github/workflows/ci-conan.yml +++ b/.github/workflows/ci-conan.yml @@ -143,6 +143,20 @@ jobs: std_format_support: "True", conan-config: "", } + - { + name: "Clang-18 on Apple M1 (arm64)", + os: macos-14, + compiler: + { + type: CLANG, + version: 18, + cc: "/opt/homebrew/opt/llvm@18/bin/clang-18", + cxx: "/opt/homebrew/opt/llvm@18/bin/clang++", + }, + lib: "libc++", + cxx_modules: "False", + std_format_support: "True" + } - { name: "Apple Clang 15", os: macos-13, @@ -196,8 +210,8 @@ jobs: shell: bash run: | sudo apt install -y g++-${{ matrix.config.compiler.version }} - - name: Install Clang - if: matrix.config.compiler.type == 'CLANG' + - name: Install Clang with apt + if: matrix.config.compiler.type == 'CLANG' && matrix.config.os != 'macos-14' shell: bash working-directory: ${{ env.HOME }} run: | @@ -205,8 +219,13 @@ jobs: chmod +x llvm.sh sudo ./llvm.sh ${{ matrix.config.compiler.version }} sudo apt install -y clang-tools-${{ matrix.config.compiler.version }} + - name: Install Clang using homebrew + if: matrix.config.compiler.type == 'CLANG' && matrix.config.os == 'macos-14' + shell: bash + run: | + brew install llvm@18 - name: Install Libc++ - if: matrix.config.compiler.type == 'CLANG' && matrix.config.lib == 'libc++' + if: matrix.config.compiler.type == 'CLANG' && matrix.config.lib == 'libc++' && matrix.config.os != 'macos-14' shell: bash run: | sudo apt install -y libc++-${{ matrix.config.compiler.version }}-dev libc++abi-${{ matrix.config.compiler.version }}-dev libunwind-${{ matrix.config.compiler.version }}-dev From 3e502fb795a93c2f56bf78034c7ff92cc116aeb6 Mon Sep 17 00:00:00 2001 From: Yves Delley Date: Mon, 16 Sep 2024 20:34:12 +0200 Subject: [PATCH 3/3] increase tolerance for certain math tests to two epsilon --- test/runtime/almost_equals.h | 9 +++++---- test/runtime/math_test.cpp | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/runtime/almost_equals.h b/test/runtime/almost_equals.h index 0cc03e8eb..4c2153a0b 100644 --- a/test/runtime/almost_equals.h +++ b/test/runtime/almost_equals.h @@ -35,7 +35,7 @@ namespace mp_units { template struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase { - explicit AlmostEqualsMatcher(const T& target) : target_{target} {} + explicit AlmostEqualsMatcher(const T& target, int n_eps) : target_{target}, n_eps_{n_eps} {} template U> requires std::same_as @@ -48,7 +48,7 @@ struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase { const auto y = common(other).numerical_value_in(common::unit); if constexpr (treat_as_floating_point) { const auto maxXYOne = std::max({rep{1}, abs(x), abs(y)}); - return abs(x - y) <= std::numeric_limits::epsilon() * maxXYOne; + return abs(x - y) <= (n_eps_ * std::numeric_limits::epsilon()) * maxXYOne; } else { if (x >= 0) { return x - 1 <= y && y - 1 <= x; @@ -71,12 +71,13 @@ struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase { private: const T& target_; + int n_eps_; }; template -AlmostEqualsMatcher AlmostEquals(const T& target) +AlmostEqualsMatcher AlmostEquals(const T& target, int n_eps = 1) { - return AlmostEqualsMatcher{target}; + return AlmostEqualsMatcher{target, n_eps}; } diff --git a/test/runtime/math_test.cpp b/test/runtime/math_test.cpp index 2a59135b8..79018bff8 100644 --- a/test/runtime/math_test.cpp +++ b/test/runtime/math_test.cpp @@ -448,7 +448,7 @@ TEST_CASE("Angle trigonometric functions", "[trig][angle]") REQUIRE_THAT(sin(0 * angle[grad]), AlmostEquals(0. * one)); REQUIRE_THAT(sin(100 * angle[grad]), AlmostEquals(1. * one)); - REQUIRE_THAT(sin(200 * angle[grad]), AlmostEquals(0. * one)); + REQUIRE_THAT(sin(200 * angle[grad]), AlmostEquals(0. * one, 2)); REQUIRE_THAT(sin(300 * angle[grad]), AlmostEquals(-1. * one)); } @@ -475,7 +475,7 @@ TEST_CASE("Angle trigonometric functions", "[trig][angle]") REQUIRE_THAT(tan(0 * angle[grad]), AlmostEquals(0. * one)); REQUIRE_THAT(tan(50 * angle[grad]), AlmostEquals(1. * one)); REQUIRE_THAT(tan(150 * angle[grad]), AlmostEquals(-1. * one)); - REQUIRE_THAT(tan(200 * angle[grad]), AlmostEquals(0. * one)); + REQUIRE_THAT(tan(200 * angle[grad]), AlmostEquals(0. * one, 2)); } }