[libcxx-commits] [libcxx] [libc++] <experimental/simd> Fix conversion constructor (PR #74693)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Dec 12 22:48:39 PST 2023
https://github.com/joy2myself updated https://github.com/llvm/llvm-project/pull/74693
>From b554ec700226f7b64f22fc83d7e423f4244a3965 Mon Sep 17 00:00:00 2001
From: Yin Zhang <zhangyin2018 at iscas.ac.cn>
Date: Thu, 7 Dec 2023 11:06:50 +0800
Subject: [PATCH] [libc++] <experimental/simd> Fix equal assertion for long
double
---
libcxx/test/std/experimental/simd/test_utils.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libcxx/test/std/experimental/simd/test_utils.h b/libcxx/test/std/experimental/simd/test_utils.h
index 30a48521aa589c..f8c043c847fa03 100644
--- a/libcxx/test/std/experimental/simd/test_utils.h
+++ b/libcxx/test/std/experimental/simd/test_utils.h
@@ -12,6 +12,7 @@
#include <algorithm>
#include <array>
#include <cassert>
+#include <cmath>
#include <type_traits>
#include <utility>
#include <experimental/simd>
@@ -72,6 +73,13 @@ void assert_simd_values_equal(const ex::simd<T, SimdAbi>& origin_simd, const std
assert(origin_simd[i] == static_cast<T>(expected_value[i]));
}
+template <std::size_t ArraySize, class SimdAbi, class U>
+void assert_simd_values_equal(const ex::simd<long double, SimdAbi>& origin_simd, const std::array<U, ArraySize>& expected_value) {
+ const long double tolerance = 1e-10;
+ for (std::size_t i = 0; i < origin_simd.size(); ++i)
+ assert(std::fabsl(origin_simd[i] - static_cast<long double>(expected_value[i])) < tolerance);
+}
+
template <std::size_t ArraySize, class T, class SimdAbi>
void assert_simd_mask_values_equal(const ex::simd_mask<T, SimdAbi>& origin_mask,
const std::array<bool, ArraySize>& expected_value) {
More information about the libcxx-commits
mailing list