Skip to content

Commit cc369f8

Browse files
committed
Test refactoring: specific batch tests
1 parent ca51808 commit cc369f8

File tree

7 files changed

+898
-106
lines changed

7 files changed

+898
-106
lines changed

include/xsimd/types/xsimd_fallback.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,12 @@ namespace xsimd
523523

524524
static batch_type bitwise_not(const batch_type& rhs)
525525
{
526-
XSIMD_FALLBACK_UNARY_OP(batch_bool, ~, rhs)
526+
XSIMD_FALLBACK_UNARY_OP(batch_bool, !, rhs)
527527
}
528528

529529
static batch_type bitwise_andnot(const batch_type& lhs, const batch_type& rhs)
530530
{
531-
XSIMD_FALLBACK_MAPPING_LOOP(batch_bool, (~(lhs[i] & rhs[i])))
531+
XSIMD_FALLBACK_MAPPING_LOOP(batch_bool, (!(lhs[i] & rhs[i])))
532532
}
533533

534534
static batch_type equal(const batch_type& lhs, const batch_type& rhs)

test/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ include_directories(${GTEST_INCLUDE_DIRS})
143143
set(XSIMD_TESTS
144144
main.cpp
145145
test_batch.cpp
146+
test_batch_bool.cpp
147+
test_batch_float.cpp
148+
test_batch_int.cpp
146149
test_utils.hpp
147150
#[[ xsimd_api_test.hpp
148151
xsimd_api_test.cpp

test/test_batch.cpp

Lines changed: 16 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,9 @@ class batch_test : public testing::Test
364364
{
365365
array_type expected;
366366
std::transform(lhs.cbegin(), lhs.cend(), rhs.begin(), expected.begin(),
367-
[](const value_type& l, const value_type& r) { return std::fma(l, r, r); });
368-
batch_type res = fma(batch_lhs(), batch_rhs(), batch_rhs());
367+
[](const value_type& l, const value_type& r) { return l * r + r; });
368+
// Warning: ADL seems to not work correctly on Windows, thus the full qualified call
369+
batch_type res = xsimd::fma(batch_lhs(), batch_rhs(), batch_rhs());
369370
EXPECT_BATCH_EQ(res, expected) << print_function_name("fma");
370371
}
371372
// fms
@@ -412,14 +413,6 @@ class batch_test : public testing::Test
412413
batch_type res = fabs(batch_lhs());
413414
EXPECT_BATCH_EQ(res, expected) << print_function_name("fabs");
414415
}
415-
// sqrt
416-
/*{
417-
array_type expected;
418-
std::transform(lhs.cbegin(), lhs.cend(), expected.begin(),
419-
[](const value_type& l) { return std::sqrt(l); });
420-
batch_type res = sqrt(batch_lhs());
421-
EXPECT_BATCH_EQ(res, expected) << print_function_name("sqrt");
422-
}*/
423416
}
424417

425418
void test_horizontal_operations() const
@@ -430,33 +423,6 @@ class batch_test : public testing::Test
430423
value_type res = hadd(batch_lhs());
431424
EXPECT_SCALAR_EQ(res, expected) << print_function_name("hadd");
432425
}
433-
// haddp
434-
/*{
435-
batch_type haddp_input[size];
436-
for(size_t i = 0; i < size; i += 2)
437-
{
438-
haddp_input[i] = batch_lhs();
439-
if(i + 1 < size)
440-
{
441-
haddp_input[i+1] = batch_rhs();
442-
}
443-
}
444-
array_type expected;
445-
std::fill(expected.cbegin(), expected.cend(), value_type(0));
446-
for(size_t i = 0; i < size; i += 2)
447-
{
448-
for(size_t j = 0; j < size; j += 2)
449-
{
450-
expected[j] += lhs[i];
451-
if(j + 1 < size)
452-
{
453-
expected[j + 1] += rhs[i];
454-
}
455-
}
456-
}
457-
auto res = haddp(haddp_input);
458-
EXPECT_EQ(res, expected) << print_function_name("haddp");
459-
}*/
460426
}
461427

462428
void test_boolean_conversions() const
@@ -571,88 +537,65 @@ class batch_test : public testing::Test
571537
}
572538
};
573539

574-
TYPED_TEST_SUITE_P(batch_test);
540+
TYPED_TEST_SUITE(batch_test, batch_types, simd_test_names);
575541

576-
TYPED_TEST_P(batch_test, load_store)
542+
TYPED_TEST(batch_test, load_store)
577543
{
578544
this->test_load_store();
579545
}
580546

581-
TYPED_TEST_P(batch_test, constructors)
547+
TYPED_TEST(batch_test, constructors)
582548
{
583549
this->test_constructors();
584550
}
585551

586-
TYPED_TEST_P(batch_test, access_operator)
552+
TYPED_TEST(batch_test, access_operator)
587553
{
588554
this->test_access_operator();
589555
}
590556

591-
TYPED_TEST_P(batch_test, arithmetic)
557+
TYPED_TEST(batch_test, arithmetic)
592558
{
593559
this->test_arithmetic();
594560
}
595561

596-
TYPED_TEST_P(batch_test, computed_assignment)
562+
TYPED_TEST(batch_test, computed_assignment)
597563
{
598564
this->test_computed_assignment();
599565
}
600566

601-
TYPED_TEST_P(batch_test, comparison)
567+
TYPED_TEST(batch_test, comparison)
602568
{
603569
this->test_comparison();
604570
}
605571

606-
TYPED_TEST_P(batch_test, min_max)
572+
TYPED_TEST(batch_test, min_max)
607573
{
608574
this->test_min_max();
609575
}
610576

611-
TYPED_TEST_P(batch_test, fused_operations)
577+
TYPED_TEST(batch_test, fused_operations)
612578
{
613579
this->test_fused_operations();
614580
}
615581

616-
TYPED_TEST_P(batch_test, abs)
582+
TYPED_TEST(batch_test, abs)
617583
{
618584
this->test_abs();
619585
}
620586

621-
TYPED_TEST_P(batch_test, horizontal_operations)
587+
TYPED_TEST(batch_test, horizontal_operations)
622588
{
623589
this->test_horizontal_operations();
624590
}
625591

626-
TYPED_TEST_P(batch_test, boolean_conversions)
592+
TYPED_TEST(batch_test, boolean_conversions)
627593
{
628594
this->test_boolean_conversions();
629595
}
630596

631-
TYPED_TEST_P(batch_test, iterator)
597+
TYPED_TEST(batch_test, iterator)
632598
{
633599
this-> test_iterator();
634600
}
635601

636-
REGISTER_TYPED_TEST_SUITE_P(
637-
batch_test,
638-
load_store,
639-
constructors,
640-
access_operator,
641-
arithmetic,
642-
computed_assignment,
643-
comparison,
644-
min_max,
645-
fused_operations,
646-
abs,
647-
horizontal_operations,
648-
boolean_conversions,
649-
iterator
650-
);
651-
652-
653-
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
654-
INSTANTIATE_TYPED_TEST_SUITE_P(sse,
655-
batch_test,
656-
sse_types,
657-
simd_test_names);
658-
#endif

0 commit comments

Comments
 (0)