Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions test/test_arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,12 @@ TEST_CASE("[multi arch support]")
{
// make sure load_aligned / load_unaligned work for the default arch and
// return the appropriate type.
using type_list = xsimd::mpl::type_list<short, int, long, float, std::complex<float>
try_loads<short, int, long, float, std::complex<float>
#if XSIMD_WITH_NEON64 || !XSIMD_WITH_NEON
,
double, std::complex<double>
,
double, std::complex<double>
#endif
>;
try_loads<type_list>();
>();
}
}

Expand Down
40 changes: 20 additions & 20 deletions test/test_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,35 +920,35 @@ struct batch_test
return batch_type::load_unaligned(rhs.data());
}

template <class T = value_type>
xsimd::enable_integral_t<T, void> init_operands()
void init_operands()
{
for (size_t i = 0; i < size; ++i)
XSIMD_IF_CONSTEXPR(std::is_integral<value_type>::value)
{
bool negative_lhs = std::is_signed<T>::value && (i % 2 == 1);
lhs[i] = value_type(i) * (negative_lhs ? -3 : 3);
if (lhs[i] == value_type(0))
for (size_t i = 0; i < size; ++i)
{
lhs[i] += value_type(1);
bool negative_lhs = std::is_signed<value_type>::value && (i % 2 == 1);
lhs[i] = value_type(i) * (negative_lhs ? -3 : 3);
if (lhs[i] == value_type(0))
{
lhs[i] += value_type(1);
}
rhs[i] = value_type(i) + value_type(2);
}
rhs[i] = value_type(i) + value_type(2);
scalar = value_type(3);
}
scalar = value_type(3);
}

template <class T = value_type>
xsimd::enable_floating_point_t<T, void> init_operands()
{
for (size_t i = 0; i < size; ++i)
else
{
lhs[i] = value_type(i) / 4 + value_type(1.2) * std::sqrt(value_type(i + 0.25));
if (lhs[i] == value_type(0))
for (size_t i = 0; i < size; ++i)
{
lhs[i] += value_type(0.1);
lhs[i] = value_type(i) / 4 + value_type(1.2) * std::sqrt(value_type(i + 0.25));
if (lhs[i] == value_type(0))
{
lhs[i] += value_type(0.1);
}
rhs[i] = value_type(10.2) / (i + 2) + value_type(0.25);
}
rhs[i] = value_type(10.2) / (i + 2) + value_type(0.25);
scalar = value_type(1.2);
}
scalar = value_type(1.2);
}
};

Expand Down
58 changes: 24 additions & 34 deletions test/test_complex_exponential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct complex_exponential_test
vector_type huge_exp_input;
vector_type log_input;
vector_type expected;
vector_type res;

complex_exponential_test()
{
Expand All @@ -46,23 +45,21 @@ struct complex_exponential_test
real_value_type(0.002 + i * 110 / nb_input));
}
expected.resize(nb_input);
res.resize(nb_input);
}

void test_exp()
{
std::transform(exp_input.cbegin(), exp_input.cend(), expected.begin(),
[](const value_type& v)
{ using std::exp; return exp(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, exp_input, i);
out = exp(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_expm1()
Expand All @@ -71,111 +68,104 @@ struct complex_exponential_test
[](const value_type& v)
{ using xsimd::expm1; return expm1(v); });

batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, exp_input, i);
out = expm1(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_huge_exp()
{
std::transform(huge_exp_input.cbegin(), huge_exp_input.cend(), expected.begin(),
[](const value_type& v)
{ using std::exp; return exp(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, huge_exp_input, i);
out = exp(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_log()
{
std::transform(log_input.cbegin(), log_input.cend(), expected.begin(),
[](const value_type& v)
{ using std::log; return log(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, log_input, i);
out = log(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_log2()
{
std::transform(log_input.cbegin(), log_input.cend(), expected.begin(),
[](const value_type& v)
{ using xsimd::log2; return log2(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, log_input, i);
out = log2(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_log10()
{
std::transform(log_input.cbegin(), log_input.cend(), expected.begin(),
[](const value_type& v)
{ using std::log10; return log10(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, log_input, i);
out = log10(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_log1p()
{
std::transform(log_input.cbegin(), log_input.cend(), expected.begin(),
[](const value_type& v)
{ using xsimd::log1p; return log1p(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, log_input, i);
out = log1p(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_sign()
{
std::transform(log_input.cbegin(), log_input.cend(), expected.begin(),
[](const value_type& v)
{ using xsimd::sign; return sign(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, log_input, i);
out = sign(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}
};

Expand Down
44 changes: 18 additions & 26 deletions test/test_complex_hyperbolic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct complex_hyperbolic_test
vector_type acosh_input;
vector_type atanh_input;
vector_type expected;
vector_type res;

complex_hyperbolic_test()
{
Expand All @@ -47,103 +46,96 @@ struct complex_hyperbolic_test
real_value_type(-0.94) + i * real_value_type(1.8) / nb_input);
}
expected.resize(nb_input);
res.resize(nb_input);
}

void test_sinh()
{
std::transform(input.cbegin(), input.cend(), expected.begin(),
[](const value_type& v)
{ using std::sinh; return sinh(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, input, i);
out = sinh(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_cosh()
{
std::transform(input.cbegin(), input.cend(), expected.begin(),
[](const value_type& v)
{ using std::cosh; return cosh(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, input, i);
out = cosh(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_tanh()
{
std::transform(input.cbegin(), input.cend(), expected.begin(),
[](const value_type& v)
{ using std::tanh; return tanh(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, input, i);
out = tanh(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_asinh()
{
std::transform(input.cbegin(), input.cend(), expected.begin(),
[](const value_type& v)
{ using std::asinh; return asinh(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, input, i);
out = asinh(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_acosh()
{
std::transform(acosh_input.cbegin(), acosh_input.cend(), expected.begin(),
[](const value_type& v)
{ using std::acosh; return acosh(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, acosh_input, i);
out = acosh(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}

void test_atanh()
{
std::transform(atanh_input.cbegin(), atanh_input.cend(), expected.begin(),
[](const value_type& v)
{ using std::atanh; return atanh(v); });
batch_type in, out;
for (size_t i = 0; i < nb_input; i += size)
{
batch_type in, out, ref;
detail::load_batch(in, atanh_input, i);
out = atanh(in);
detail::store_batch(out, res, i);
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}
size_t diff = detail::get_nb_diff(res, expected);
CHECK_EQ(diff, 0);
}
};

Expand Down
Loading