11#include <fmt/ranges.h>
12#include <gtest/gtest.h>
23std::tuple<std::vector<std::string>, std::vector<std::string>>
26std::vector<std::string>
28std::vector<std::string>
32 template <
class ParamType>
33 std::string
operator()(const ::testing::TestParamInfo<ParamType>& info)
const
35 return fmt::format(
"{}_{}", std::get<0>(info.param), std::get<1>(info.param));
39class VolkTest :
public ::testing::TestWithParam<std::tuple<std::string, size_t>>
58 ::testing::AssertionResult result = ::testing::AssertionFailure();
59 if (expected.size() != actual.size()) {
60 return result <<
"expected result size=" << expected.size()
61 <<
" differs from actual size=" << actual.size();
63 const unsigned long length = expected.size();
66 const char* separator =
" ";
67 for (
unsigned long index = 0; index < length; index++) {
68 auto expected_real = ::testing::internal::FloatingPoint(expected[index].real());
69 auto expected_imag = ::testing::internal::FloatingPoint(expected[index].imag());
70 auto actual_real = ::testing::internal::FloatingPoint(actual[index].real());
71 auto actual_imag = ::testing::internal::FloatingPoint(actual[index].imag());
72 if (not expected_real.AlmostEquals(actual_real) or
73 not expected_imag.AlmostEquals(actual_imag)) {
74 if (errorsFound == 0) {
75 result <<
"Differences found:";
77 if (errorsFound < 3) {
78 result << separator << expected[index] <<
" != " << actual[index] <<
" @ "
85 if (errorsFound > 0) {
86 result << separator << errorsFound <<
" differences in total";
89 return ::testing::AssertionSuccess();
94 const T& expected,
const T& actual,
const float absolute_error = 1.0e-7)
96 ::testing::AssertionResult result = ::testing::AssertionFailure();
97 if (expected.size() != actual.size()) {
98 return result <<
"expected result size=" << expected.size()
99 <<
" differs from actual size=" << actual.size();
101 const unsigned long length = expected.size();
104 const char* separator =
" ";
105 for (
unsigned long index = 0; index < length; index++) {
106 auto expected_real = ::testing::internal::FloatingPoint(expected[index].real());
107 auto expected_imag = ::testing::internal::FloatingPoint(expected[index].imag());
108 auto actual_real = ::testing::internal::FloatingPoint(actual[index].real());
109 auto actual_imag = ::testing::internal::FloatingPoint(actual[index].imag());
110 if (expected_real.is_nan() or actual_real.is_nan() or expected_imag.is_nan() or
111 actual_imag.is_nan() or
112 std::abs(expected[index].real() - actual[index].real()) > absolute_error or
113 std::abs(expected[index].imag() - actual[index].imag()) > absolute_error) {
114 if (errorsFound == 0) {
115 result <<
"Differences found:";
117 if (errorsFound < 3) {
118 result << separator << expected[index] <<
" != " << actual[index] <<
" @ "
125 if (errorsFound > 0) {
126 result << separator << errorsFound <<
" differences in total";
129 return ::testing::AssertionSuccess();
134 const T& expected,
const T& actual,
const float absolute_error = 1.0e-7)
136 ::testing::AssertionResult result = ::testing::AssertionFailure();
137 if (expected.size() != actual.size()) {
138 return result <<
"expected result size=" << expected.size()
139 <<
" differs from actual size=" << actual.size();
141 const unsigned long length = expected.size();
144 const char* separator =
" ";
145 for (
unsigned long index = 0; index < length; index++) {
146 auto expected_value = ::testing::internal::FloatingPoint(expected[index]);
147 auto actual_value = ::testing::internal::FloatingPoint(actual[index]);
148 if (expected_value.is_nan() or actual_value.is_nan() or
149 std::abs(expected[index] - actual[index]) > absolute_error) {
150 if (errorsFound == 0) {
151 result <<
"Differences found:";
153 if (errorsFound < 3) {
154 result << separator << expected[index] <<
" != " << actual[index] <<
" @ "
161 if (errorsFound > 0) {
162 result << separator << errorsFound <<
" differences in total";
165 return ::testing::AssertionSuccess();
Definition volk_test.h:40
void initialize_test(const std::tuple< std::string, size_t > ¶m)
Definition volk_test.h:42
std::string implementation_name
Definition volk_test.h:48
bool is_aligned_implementation
Definition volk_test.h:49
size_t vector_length
Definition volk_test.h:50
Definition volk_test.h:31
std::string operator()(const ::testing::TestParamInfo< ParamType > &info) const
Definition volk_test.h:33
__VOLK_DECL_BEGIN struct volk_func_desc volk_func_desc_t
::testing::AssertionResult AreFloatingPointArraysEqualWithAbsoluteError(const T &expected, const T &actual, const float absolute_error=1.0e-7)
Definition volk_test.h:133
std::vector< std::string > get_aligned_kernel_implementation_names(const volk_func_desc_t desc)
Definition volk_test.cc:89
bool is_aligned_implementation_name(const std::string &name)
Definition volk_test.cc:68
::testing::AssertionResult AreComplexFloatingPointArraysAlmostEqual(const T &expected, const T &actual)
Definition volk_test.h:55
::testing::AssertionResult AreComplexFloatingPointArraysEqualWithAbsoluteError(const T &expected, const T &actual, const float absolute_error=1.0e-7)
Definition volk_test.h:93
std::tuple< std::vector< std::string >, std::vector< std::string > > separate_implementations_by_alignment(const std::vector< std::string > &names)
Definition volk_test.cc:74
static constexpr std::array< size_t, 5 > default_vector_sizes
Definition volk_test.h:17
std::vector< std::string > get_unaligned_kernel_implementation_names(const volk_func_desc_t desc)
Definition volk_test.cc:97
std::vector< std::string > get_kernel_implementation_name_list(const volk_func_desc_t desc)
Definition volk_test.cc:58