Nektar++
Loading...
Searching...
No Matches
Typedefs | Functions
Nektar::SimdLibTests Namespace Reference

Typedefs

using vec_t = simd< double >
 
using default_long_vec_t = longsimd< double >
 
using long_vec_t = longsimd< double, 3 *vec_t::width >
 

Functions

 BOOST_AUTO_TEST_CASE (SimdLibDouble_width_alignment)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_type_traits)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_mem_size)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_ctors)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_load)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_load_implicit)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_load_aligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_load_unaligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibInt64_load)
 
 BOOST_AUTO_TEST_CASE (SimdLibInt64_load_aligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibInt64_load_unaligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibInt32_load)
 
 BOOST_AUTO_TEST_CASE (SimdLibInt32_load_aligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibInt32_load_unaligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_store)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_store_aligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_store_unaligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_store_non_temporal)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_broadcast)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_subscript_assign_read)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_gather64)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_gather32)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_scatter64)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_add_unary)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_sub_unary)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_mul_unary)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_div_unary)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_add_binary)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_sub_binary)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_mul_binary)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_div_binary)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_add_mul)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_fused_add_mul)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_sqrt)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_abs)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_log)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_greater)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_logic_and)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_load_interleave_unload)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_longsimd_width)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_longsimd_mixed_arithmetic)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_longsimd_interleave_helpers)
 
 BOOST_AUTO_TEST_CASE (SimdLibDouble_io)
 
 BOOST_AUTO_TEST_CASE (SimdLibSingle_width_alignment)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_type_traits)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_mem_size)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_ctors)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_load)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_load_implicit)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_load_aligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_load_unaligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_store)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_store_aligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_store_unaligned)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_store_non_temporal)
 
 BOOST_AUTO_TEST_CASE (SimdLibSingle_broadcast)
 
 BOOST_AUTO_TEST_CASE (SimdLibSingle_subscript_assign_read)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_gather32)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_scatter32)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_add_unary)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_sub_unary)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_mul_unary)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_div_unary)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_add_binary)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_sub_binary)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_mul_binary)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_div_binary)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_add_mul)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_fused_add_mul)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_sqrt)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_abs)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_log)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_greater)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_logic_and)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_load_interleave_unload)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_longsimd_mixed_arithmetic)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_longsimd_interleave_helpers)
 
 BOOST_AUTO_TEST_CASE (SimdLibFloat_io)
 

Typedef Documentation

◆ default_long_vec_t

Definition at line 86 of file TestSimdLibDouble.cpp.

◆ long_vec_t

typedef longsimd< float, 3 *vec_t::width > Nektar::SimdLibTests::long_vec_t

Definition at line 87 of file TestSimdLibDouble.cpp.

◆ vec_t

Definition at line 85 of file TestSimdLibDouble.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_abs  )

Definition at line 682 of file TestSimdLibDouble.cpp.

683{
684 double val = -4.0;
685 vec_t avec(val);
686 vec_t aabs = abs(avec);
687 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
688 {}}; // double brace to deal with gcc 4.8.5 ...
689 aabs.store(ascalararr.data());
690
691 for (size_t i = 0; i < vec_t::width; ++i)
692 {
693 BOOST_CHECK_EQUAL(ascalararr[i], std::abs(val));
694 }
695}
scalarT< T > abs(scalarT< T > in)
Definition scalar.hpp:295

References tinysimd::abs().

◆ BOOST_AUTO_TEST_CASE() [2/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_add_binary  )

Definition at line 561 of file TestSimdLibDouble.cpp.

562{
563 double val1 = -4.0;
564 double val2 = 2.5;
565 vec_t avec1(val1);
566 vec_t avec2(val2);
567 vec_t res = avec1 + avec2;
568 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
569 {}}; // double brace to deal with gcc 4.8.5 ...
570 res.store(ascalararr.data());
571
572 for (size_t i = 0; i < vec_t::width; ++i)
573 {
574 BOOST_CHECK_EQUAL(ascalararr[i], val1 + val2);
575 }
576}

◆ BOOST_AUTO_TEST_CASE() [3/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_add_mul  )

Definition at line 629 of file TestSimdLibDouble.cpp.

630{
631 double val1 = -4.0;
632 double val2 = 1.5;
633 double val3 = 5.0;
634 vec_t avec1(val1);
635 vec_t avec2(val2);
636 vec_t avec3(val3);
637 vec_t res = avec1 + avec2 * avec3;
638 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
639 {}}; // double brace to deal with gcc 4.8.5 ...
640 res.store(ascalararr.data());
641
642 for (size_t i = 0; i < vec_t::width; ++i)
643 {
644 BOOST_CHECK_EQUAL(ascalararr[i], val1 + val2 * val3);
645 }
646}

◆ BOOST_AUTO_TEST_CASE() [4/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_add_unary  )

Definition at line 493 of file TestSimdLibDouble.cpp.

494{
495 double val1 = -4.0;
496 double val2 = 2.0;
497 vec_t res(val1);
498 vec_t avec(val2);
499 res += avec;
500 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
501 {}}; // double brace to deal with gcc 4.8.5 ...
502 res.store(ascalararr.data());
503
504 for (size_t i = 0; i < vec_t::width; ++i)
505 {
506 BOOST_CHECK_EQUAL(ascalararr[i], val1 + val2);
507 }
508}

◆ BOOST_AUTO_TEST_CASE() [5/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_broadcast  )

Definition at line 314 of file TestSimdLibDouble.cpp.

315{
316 vec_t::scalarType ascalar{3.333};
317 vec_t avec;
318 avec.broadcast(ascalar);
319}
tinysimd::simd< NekDouble > vec_t

◆ BOOST_AUTO_TEST_CASE() [6/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_ctors  )

Definition at line 158 of file TestSimdLibDouble.cpp.

159{
160 [[maybe_unused]] vec_t avec1;
161
162 vec_t::scalarType ascalar = 0;
163 vec_t avec2(ascalar);
164 [[maybe_unused]] vec_t avec3{ascalar};
165 vec_t avec4 = ascalar;
166
167 [[maybe_unused]] vec_t avec5(avec2);
168 [[maybe_unused]] vec_t avec6{avec4};
169
170 [[maybe_unused]] vec_t avec7(avec2._data);
171 [[maybe_unused]] vec_t avec8{avec2._data};
172
173 vec_t::vectorType anative;
174 [[maybe_unused]] vec_t avec9(anative);
175 [[maybe_unused]] vec_t avec10{anative};
176}
tinysimd::scalarT< double > vec_t

◆ BOOST_AUTO_TEST_CASE() [7/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_div_binary  )

Definition at line 612 of file TestSimdLibDouble.cpp.

613{
614 double val1 = -4.0;
615 double val2 = 2.5;
616 vec_t avec1(val1);
617 vec_t avec2(val2);
618 vec_t res = avec1 / avec2;
619 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
620 {}}; // double brace to deal with gcc 4.8.5 ...
621 res.store(ascalararr.data());
622
623 for (size_t i = 0; i < vec_t::width; ++i)
624 {
625 BOOST_CHECK_EQUAL(ascalararr[i], val1 / val2);
626 }
627}

◆ BOOST_AUTO_TEST_CASE() [8/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_div_unary  )

Definition at line 544 of file TestSimdLibDouble.cpp.

545{
546 double val1 = -4.0;
547 double val2 = 2.0;
548 vec_t res(val1);
549 vec_t avec(val2);
550 res /= avec;
551 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
552 {}}; // double brace to deal with gcc 4.8.5 ...
553 res.store(ascalararr.data());
554
555 for (size_t i = 0; i < vec_t::width; ++i)
556 {
557 BOOST_CHECK_EQUAL(ascalararr[i], val1 / val2);
558 }
559}

◆ BOOST_AUTO_TEST_CASE() [9/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_fused_add_mul  )

Definition at line 648 of file TestSimdLibDouble.cpp.

649{
650 double val1 = -4.0;
651 double val2 = 1.5;
652 double val3 = 5.0;
653 vec_t avec1(val1);
654 vec_t avec2(val2);
655 vec_t avec3(val3);
656 avec1.fma(avec2, avec3);
657 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
658 {}}; // double brace to deal with gcc 4.8.5 ...
659 avec1.store(ascalararr.data());
660
661 for (size_t i = 0; i < vec_t::width; ++i)
662 {
663 BOOST_CHECK_EQUAL(ascalararr[i], val1 + val2 * val3);
664 }
665}

◆ BOOST_AUTO_TEST_CASE() [10/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_gather32  )

Definition at line 386 of file TestSimdLibDouble.cpp.

387{
388 vec_t avec;
389 using index_t = simd<std::uint32_t, vec_t::width>;
390 index_t aindexvec;
391
392 // create and fill index
393 std::array<std::uint32_t, vec_t::width> aindex;
394 aindex[0] = 0;
395 if (vec_t::width > 2)
396 {
397 aindex[1] = 3;
398 aindex[2] = 5;
399 aindex[3] = 6;
400 }
401 if (vec_t::width > 4)
402 {
403 aindex[4] = 8;
404 aindex[5] = 15;
405 aindex[6] = 16;
406 aindex[7] = 20;
407 }
408
409 // load index
410 aindexvec.load(aindex.data(), is_not_aligned);
411
412 // create and fill scalar array
413 constexpr size_t scalarArraySize = 32;
414 std::array<double, scalarArraySize> ascalararr;
415 for (size_t i = 0; i < scalarArraySize; ++i)
416 {
417 ascalararr[i] = i;
418 }
419
420 avec.gather(ascalararr.data(), aindexvec);
421
422 // check
423 for (size_t i = 0; i < vec_t::width; ++i)
424 {
425 BOOST_CHECK_EQUAL(ascalararr[aindex[i]], avec[i]);
426 }
427}
typename abi< ScalarType, width >::type simd
Definition tinysimd.hpp:132

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [11/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_gather64  )

Definition at line 343 of file TestSimdLibDouble.cpp.

344{
345 vec_t avec;
346 using index_t = simd<size_t>;
347 index_t aindexvec;
348
349 // create and fill index
350 std::array<size_t, vec_t::width> aindex;
351 aindex[0] = 0;
352 if (vec_t::width > 2)
353 {
354 aindex[1] = 3;
355 aindex[2] = 5;
356 aindex[3] = 6;
357 }
358 if (vec_t::width > 4)
359 {
360 aindex[4] = 8;
361 aindex[5] = 15;
362 aindex[6] = 16;
363 aindex[7] = 20;
364 }
365
366 // load index
367 aindexvec.load(aindex.data(), is_not_aligned);
368
369 // create and fill scalar array
370 constexpr size_t scalarArraySize = 32;
371 std::array<double, scalarArraySize> ascalararr;
372 for (size_t i = 0; i < scalarArraySize; ++i)
373 {
374 ascalararr[i] = i;
375 }
376
377 avec.gather(ascalararr.data(), aindexvec);
378
379 // check
380 for (size_t i = 0; i < vec_t::width; ++i)
381 {
382 BOOST_CHECK_EQUAL(ascalararr[aindex[i]], avec[i]);
383 }
384}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [12/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_greater  )

Definition at line 712 of file TestSimdLibDouble.cpp.

713{
714 double aval = 4.0;
715 vec_t avec(aval);
716 using mask_t = simd<bool, vec_t::width>;
717 mask_t amask;
718
719 amask = avec > avec;
720 // check
721 alignas(vec_t::alignment) std::array<std::uint64_t, vec_t::width>
722 ascalararr{{}}; // double brace to deal with gcc 4.8.5 ...
723 amask.store(ascalararr.data());
724 for (size_t i = 0; i < vec_t::width; ++i)
725 {
726 // type conversion make lvalue in rvalue, needed pre-c++17
727 BOOST_CHECK_EQUAL(ascalararr[i], (std::uint64_t)mask_t::false_v);
728 }
729
730 double bval = 3.0;
731 vec_t bvec(bval);
732
733 amask = avec > bvec;
734 // check
735 amask.store(ascalararr.data());
736 for (size_t i = 0; i < vec_t::width; ++i)
737 {
738 // type conversion make lvalue in rvalue, needed pre-c++17
739 BOOST_CHECK_EQUAL(ascalararr[i], (std::uint64_t)mask_t::true_v);
740 }
741
742 double cval = 5.0;
743 vec_t cvec(cval);
744
745 amask = avec > cvec;
746 // check
747 amask.store(ascalararr.data());
748 for (size_t i = 0; i < vec_t::width; ++i)
749 {
750 // type conversion make lvalue in rvalue, needed pre-c++17
751 BOOST_CHECK_EQUAL(ascalararr[i], (std::uint64_t)mask_t::false_v);
752 }
753
754 if (vec_t::width == 4)
755 {
756 alignas(vec_t::alignment) std::array<double, 4> ascalararr2{
757 {1.0, 2.0, 3.0, 4.0}}; // double brace to deal with gcc 4.8.5 ...
758 double dval = 2.0;
759 vec_t dvec(dval);
760 vec_t evec;
761 evec.load(ascalararr2.data());
762
763 amask = dvec > evec;
764 // check
765 for (size_t i = 0; i < vec_t::width; ++i)
766 {
767 BOOST_CHECK_EQUAL(static_cast<bool>(amask[i]),
768 dval > ascalararr2[i]);
769 }
770 }
771
772 if (vec_t::width == 8)
773 {
774 alignas(vec_t::alignment) std::array<double, 8> ascalararr2{
775 {1.0, 2.0, 3.0, 4.0, 3.0, 2.0,
776 1.0}}; // double brace to deal with gcc 4.8.5 ...
777 double dval = 2.0;
778 vec_t dvec(dval);
779 vec_t evec;
780 evec.load(ascalararr2.data());
781
782 amask = dvec > evec;
783 // check
784 for (size_t i = 0; i < vec_t::width; ++i)
785 {
786 BOOST_CHECK_EQUAL(static_cast<bool>(amask[i]),
787 dval > ascalararr2[i]);
788 }
789 }
790}

◆ BOOST_AUTO_TEST_CASE() [13/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_io  )

Definition at line 1061 of file TestSimdLibDouble.cpp.

1062{
1063 vec_t avec(3.14);
1064 std::cout << avec << std::endl;
1065}

◆ BOOST_AUTO_TEST_CASE() [14/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_load  )

Definition at line 178 of file TestSimdLibDouble.cpp.

179{
180 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
181 {}}; // double brace to deal with gcc 4.8.5 ...
182 vec_t avec;
183 avec.load(ascalararr.data());
184}

◆ BOOST_AUTO_TEST_CASE() [15/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_load_aligned  )

Definition at line 194 of file TestSimdLibDouble.cpp.

195{
196 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
197 {}}; // double brace to deal with gcc 4.8.5 ...
198 vec_t avec;
199 avec.load(ascalararr.data(), is_aligned);
200}

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [16/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_load_implicit  )

Definition at line 186 of file TestSimdLibDouble.cpp.

187{
188 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
189 {}}; // double brace to deal with gcc 4.8.5 ...
190 vec_t avec;
191 avec = *(reinterpret_cast<vec_t *>(ascalararr.data()));
192}

◆ BOOST_AUTO_TEST_CASE() [17/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_load_interleave_unload  )

Definition at line 830 of file TestSimdLibDouble.cpp.

831{
832 constexpr size_t nDof{5};
833 // no padding in load_interleave deinterleave_store
834 constexpr size_t nEle{vec_t::width * 5};
835 constexpr size_t nDofBlock = nDof * vec_t::width;
836
837 constexpr size_t size{nDof * nEle};
838 std::array<double, size> dofScalarArr{{}};
839 for (size_t i = 0; i < size; ++i)
840 {
841 dofScalarArr[i] = i;
842 }
843
844 // number of blocks
845 size_t nBlock = nEle / vec_t::width;
846
847 // aligned vector
848 std::vector<vec_t, allocator<vec_t>> dofVectorArr(nDof);
849
850 double *dataPtr = dofScalarArr.data();
851 // loop over blocks vec_t::width elements at the time
852 for (size_t b = 0; b < nBlock; ++b)
853 {
854 // load
855 load_interleave(dataPtr, nDof, dofVectorArr);
856
857 // manipulate each block
858 for (size_t j = 0; j < nDof; ++j)
859 {
860 dofVectorArr[j] = dofVectorArr[j] + j;
861 }
862
863 // store
864 deinterleave_store(dofVectorArr, nDof, dataPtr);
865 dataPtr += nDofBlock;
866 }
867
868 // check
869 for (size_t b = 0, i = 0; b < nBlock; ++b)
870 {
871 for (size_t j = 0; j < nDof; ++j, ++i)
872 {
873 BOOST_CHECK_EQUAL(dofScalarArr[i], i + j);
874 }
875 }
876}
void load_interleave(const T *in, const size_t dataLen, std::vector< scalarT< T >, allocator< scalarT< T > > > &out)
Definition scalar.hpp:338
void deinterleave_store(const std::vector< scalarT< T >, allocator< scalarT< T > > > &in, const size_t dataLen, T *out)
Definition scalar.hpp:370

References tinysimd::deinterleave_store(), and tinysimd::load_interleave().

◆ BOOST_AUTO_TEST_CASE() [18/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_load_unaligned  )

Definition at line 202 of file TestSimdLibDouble.cpp.

203{
204 std::array<double, vec_t::width> ascalararr{
205 {}}; // double brace to deal with gcc 4.8.5 ...
206 vec_t avec;
207 avec.load(ascalararr.data(), is_not_aligned);
208}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [19/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_log  )

Definition at line 697 of file TestSimdLibDouble.cpp.

698{
699 double val = 4.0;
700 vec_t avec(val);
701 vec_t alog = log(avec);
702 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
703 {}}; // double brace to deal with gcc 4.8.5 ...
704 alog.store(ascalararr.data());
705
706 for (size_t i = 0; i < vec_t::width; ++i)
707 {
708 BOOST_CHECK_EQUAL(ascalararr[i], std::log(val));
709 }
710}
scalarT< T > log(scalarT< T > in)
Definition scalar.hpp:310

References tinysimd::log().

◆ BOOST_AUTO_TEST_CASE() [20/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_logic_and  )

Definition at line 792 of file TestSimdLibDouble.cpp.

793{
794 double aval = 4.0;
795 vec_t avec(aval);
796 using mask_t = simd<bool, vec_t::width>;
797 mask_t amask;
798
799 alignas(vec_t::alignment) std::array<std::uint64_t, vec_t::width>
800 ascalararr{{}}; // double brace to deal with gcc 4.8.5 ...
801 for (size_t i = 0; i < vec_t::width; ++i)
802 {
803 ascalararr[i] = mask_t::true_v;
804 }
805 amask.load(ascalararr.data());
806
807 // check
808 BOOST_CHECK_EQUAL(amask && false, false);
809 BOOST_CHECK_EQUAL(amask && true, true);
810
811 for (size_t i = 0; i < vec_t::width; ++i)
812 {
813 ascalararr[i] = mask_t::false_v;
814 }
815 amask.load(ascalararr.data());
816
817 // check
818 BOOST_CHECK_EQUAL(amask && false, false);
819 BOOST_CHECK_EQUAL(amask && true, false);
820
821 if (vec_t::width > 1)
822 {
823 ascalararr[0] = mask_t::true_v;
824 // check
825 BOOST_CHECK_EQUAL(amask && false, false);
826 BOOST_CHECK_EQUAL(amask && true, false);
827 }
828}

◆ BOOST_AUTO_TEST_CASE() [21/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_longsimd_interleave_helpers  )

Definition at line 961 of file TestSimdLibDouble.cpp.

962{
963 {
964 constexpr size_t nDof = 5;
965 constexpr size_t nBlocks = 3;
966 constexpr size_t nEle = long_vec_t::width * nBlocks;
967 constexpr size_t blockSize = nDof * long_vec_t::width;
968 constexpr size_t size = nDof * nEle;
969
970 std::array<double, size> data{{}};
971 for (size_t i = 0; i < size; ++i)
972 {
973 data[i] = static_cast<double>(i);
974 }
975
976 std::vector<long_vec_t, allocator<long_vec_t>> work(nDof);
977
978 for (size_t block = 0; block < nBlocks; ++block)
979 {
980 double *dataPtr = data.data() + block * blockSize;
981 load_interleave(dataPtr, nDof, work);
982 for (size_t j = 0; j < nDof; ++j)
983 {
984 work[j] += static_cast<double>(j + 1);
985 }
986 deinterleave_store(work, nDof, dataPtr);
987 }
988
989 for (size_t block = 0; block < nBlocks; ++block)
990 {
991 for (size_t lane = 0; lane < long_vec_t::width; ++lane)
992 {
993 for (size_t dof = 0; dof < nDof; ++dof)
994 {
995 const auto idx = block * blockSize + lane * nDof + dof;
996 BOOST_CHECK_EQUAL(data[idx],
997 static_cast<double>(idx + dof + 1));
998 }
999 }
1000 }
1001 }
1002
1003 {
1004 constexpr size_t nDof = 4;
1005 constexpr size_t skipPads = long_vec_t::width > 1 ? 1 : 0;
1006 constexpr size_t activeWidth = long_vec_t::width - skipPads;
1007 constexpr size_t unalignedSize = nDof * long_vec_t::width;
1008 constexpr size_t paddedSize = nDof * activeWidth;
1009
1010 std::array<double, unalignedSize> data{{}};
1011 for (size_t i = 0; i < data.size(); ++i)
1012 {
1013 data[i] = static_cast<double>(100 + i);
1014 }
1015
1016 std::vector<long_vec_t, allocator<long_vec_t>> work(nDof);
1017 load_unalign_interleave(data.data(), nDof, work);
1018 for (size_t j = 0; j < nDof; ++j)
1019 {
1020 work[j] += static_cast<double>(2 * j + 1);
1021 }
1022 std::array<double, unalignedSize> out{{}};
1023 deinterleave_unalign_store(work, nDof, out.data());
1024
1025 for (size_t lane = 0; lane < long_vec_t::width; ++lane)
1026 {
1027 for (size_t dof = 0; dof < nDof; ++dof)
1028 {
1029 const auto idx = lane * nDof + dof;
1030 BOOST_CHECK_EQUAL(out[idx],
1031 data[idx] + static_cast<double>(2 * dof + 1));
1032 }
1033 }
1034
1035 std::array<double, paddedSize> padded{{}};
1036 for (size_t i = 0; i < padded.size(); ++i)
1037 {
1038 padded[i] = static_cast<double>(200 + i);
1039 }
1040
1041 load_unalign_interleave_skipPads(padded.data(), nDof, skipPads, work);
1042 for (auto &value : work)
1043 {
1044 value += 3.0;
1045 }
1046 std::array<double, paddedSize> paddedOut{{}};
1047 deinterleave_unalign_store_skipPads(work, nDof, skipPads,
1048 paddedOut.data());
1049
1050 for (size_t lane = 0; lane < activeWidth; ++lane)
1051 {
1052 for (size_t dof = 0; dof < nDof; ++dof)
1053 {
1054 const auto idx = lane * nDof + dof;
1055 BOOST_CHECK_EQUAL(paddedOut[idx], padded[idx] + 3.0);
1056 }
1057 }
1058 }
1059}
void deinterleave_unalign_store(const std::vector< scalarT< T >, allocator< scalarT< T > > > &in, const size_t dataLen, T *out)
Definition scalar.hpp:348
void load_unalign_interleave(const T *in, const size_t dataLen, std::vector< scalarT< T >, allocator< scalarT< T > > > &out)
Definition scalar.hpp:316
void deinterleave_unalign_store_skipPads(const std::vector< scalarT< T >, allocator< scalarT< T > > > &in, const size_t dataLen, const size_t skipPads, T *out)
Definition scalar.hpp:359
void load_unalign_interleave_skipPads(const T *in, const size_t dataLen, const size_t skipPads, std::vector< scalarT< T >, allocator< scalarT< T > > > &out)
Definition scalar.hpp:327

References tinysimd::deinterleave_store(), tinysimd::deinterleave_unalign_store(), tinysimd::deinterleave_unalign_store_skipPads(), tinysimd::load_interleave(), tinysimd::load_unalign_interleave(), and tinysimd::load_unalign_interleave_skipPads().

◆ BOOST_AUTO_TEST_CASE() [22/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_longsimd_mixed_arithmetic  )

Definition at line 889 of file TestSimdLibDouble.cpp.

890{
891 alignas(long_vec_t::alignment) std::array<double, long_vec_t::width>
892 lhsData{{}};
893 alignas(vec_t::alignment) std::array<double, vec_t::width> rhsData{{}};
894
895 for (size_t i = 0; i < lhsData.size(); ++i)
896 {
897 lhsData[i] = static_cast<double>(i + 1);
898 }
899 for (size_t i = 0; i < rhsData.size(); ++i)
900 {
901 rhsData[i] = static_cast<double>(10 * (i + 1));
902 }
903
904 long_vec_t lhs;
905 lhs.load(lhsData.data(), is_aligned);
906
907 vec_t rhs;
908 rhs.load(rhsData.data(), is_aligned);
909
910 auto sum = lhs + rhs;
911 auto reverseSum = rhs + lhs;
912 auto scalarRight = lhs + 2.5;
913 auto scalarLeft = 100.0 - lhs;
914 auto scaled = lhs * 2.0;
915
916 long_vec_t acc(1.0);
917 acc.fma(lhs, rhs);
918
919 alignas(long_vec_t::alignment) std::array<double, long_vec_t::width> tmp{
920 {}};
921 sum.store(tmp.data(), is_aligned);
922 for (size_t i = 0; i < tmp.size(); ++i)
923 {
924 const auto chunkLane = i % vec_t::width;
925 BOOST_CHECK_EQUAL(tmp[i], lhsData[i] + rhsData[chunkLane]);
926 }
927
928 reverseSum.store(tmp.data(), is_aligned);
929 for (size_t i = 0; i < tmp.size(); ++i)
930 {
931 const auto chunkLane = i % vec_t::width;
932 BOOST_CHECK_EQUAL(tmp[i], lhsData[i] + rhsData[chunkLane]);
933 }
934
935 scalarRight.store(tmp.data(), is_aligned);
936 for (size_t i = 0; i < tmp.size(); ++i)
937 {
938 BOOST_CHECK_EQUAL(tmp[i], lhsData[i] + 2.5);
939 }
940
941 scalarLeft.store(tmp.data(), is_aligned);
942 for (size_t i = 0; i < tmp.size(); ++i)
943 {
944 BOOST_CHECK_EQUAL(tmp[i], 100.0 - lhsData[i]);
945 }
946
947 scaled.store(tmp.data(), is_aligned);
948 for (size_t i = 0; i < tmp.size(); ++i)
949 {
950 BOOST_CHECK_EQUAL(tmp[i], lhsData[i] * 2.0);
951 }
952
953 acc.store(tmp.data(), is_aligned);
954 for (size_t i = 0; i < tmp.size(); ++i)
955 {
956 const auto chunkLane = i % vec_t::width;
957 BOOST_CHECK_EQUAL(tmp[i], 1.0 + lhsData[i] * rhsData[chunkLane]);
958 }
959}
longsimd< double, 3 *vec_t::width > long_vec_t

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [23/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_longsimd_width  )

Definition at line 878 of file TestSimdLibDouble.cpp.

879{
880 BOOST_CHECK_EQUAL(default_long_vec_t::width,
881 vec_t::width * tinysimd::PACKMULTIPLIER);
882
883 BOOST_CHECK_EQUAL(long_vec_t::width, 3 * vec_t::width);
884 BOOST_CHECK_EQUAL(long_vec_t::alignment, vec_t::alignment);
885 BOOST_CHECK_EQUAL(sizeof(long_vec_t), sizeof(double) * long_vec_t::width);
886 BOOST_CHECK_EQUAL(is_vector_floating_point_v<long_vec_t>, true);
887}
static constexpr unsigned int PACKMULTIPLIER
Definition tinysimd.hpp:99

References tinysimd::PACKMULTIPLIER.

◆ BOOST_AUTO_TEST_CASE() [24/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_mem_size  )

Definition at line 153 of file TestSimdLibDouble.cpp.

154{
155 BOOST_CHECK_EQUAL(sizeof(vec_t), sizeof(double) * vec_t::width);
156}

◆ BOOST_AUTO_TEST_CASE() [25/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_mul_binary  )

Definition at line 595 of file TestSimdLibDouble.cpp.

596{
597 double val1 = -4.0;
598 double val2 = 2.5;
599 vec_t avec1(val1);
600 vec_t avec2(val2);
601 vec_t res = avec1 * avec2;
602 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
603 {}}; // double brace to deal with gcc 4.8.5 ...
604 res.store(ascalararr.data());
605
606 for (size_t i = 0; i < vec_t::width; ++i)
607 {
608 BOOST_CHECK_EQUAL(ascalararr[i], val1 * val2);
609 }
610}

◆ BOOST_AUTO_TEST_CASE() [26/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_mul_unary  )

Definition at line 527 of file TestSimdLibDouble.cpp.

528{
529 double val1 = -4.0;
530 double val2 = 2.0;
531 vec_t res(val1);
532 vec_t avec(val2);
533 res *= avec;
534 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
535 {}}; // double brace to deal with gcc 4.8.5 ...
536 res.store(ascalararr.data());
537
538 for (size_t i = 0; i < vec_t::width; ++i)
539 {
540 BOOST_CHECK_EQUAL(ascalararr[i], val1 * val2);
541 }
542}

◆ BOOST_AUTO_TEST_CASE() [27/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_scatter64  )

Definition at line 429 of file TestSimdLibDouble.cpp.

430{
431 vec_t avec;
432 using index_t = simd<size_t>;
433 index_t aindexvec;
434
435 // create and fill index
436 std::array<size_t, vec_t::width> aindex;
437 aindex[0] = 1;
438 if (vec_t::width > 1)
439 {
440 aindex[1] = 3;
441 }
442 if (vec_t::width > 2)
443 {
444 aindex[2] = 5;
445 aindex[3] = 6;
446 }
447 if (vec_t::width > 4)
448 {
449 aindex[4] = 8;
450 aindex[5] = 15;
451 aindex[6] = 20;
452 aindex[7] = 30;
453 }
454
455 // load index
456 aindexvec.load(aindex.data(), is_not_aligned);
457
458 // create scalar array
459 constexpr size_t scalarArraySize = 32;
460 std::array<double, scalarArraySize> ascalararr;
461
462 // fill vector
463 alignas(vec_t::alignment) std::array<double, vec_t::width> avecarr{{}};
464 avecarr[0] = 10;
465 if (vec_t::width > 1)
466 {
467 avecarr[1] = 9;
468 }
469
470 if (vec_t::width > 2)
471 {
472 avecarr[2] = 8;
473 avecarr[3] = 7;
474 }
475 if (vec_t::width > 4)
476 {
477 avecarr[4] = 4;
478 avecarr[5] = 3;
479 avecarr[6] = 2;
480 avecarr[7] = 1;
481 }
482 avec.load(avecarr.data());
483
484 avec.scatter(ascalararr.data(), aindexvec);
485
486 // check
487 for (size_t i = 0; i < vec_t::width; ++i)
488 {
489 BOOST_CHECK_EQUAL(avec[i], ascalararr[aindex[i]]);
490 }
491}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [28/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_sqrt  )

Definition at line 667 of file TestSimdLibDouble.cpp.

668{
669 double val = 4.0;
670 vec_t avec(val);
671 vec_t asqrt = sqrt(avec);
672 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
673 {}}; // double brace to deal with gcc 4.8.5 ...
674 asqrt.store(ascalararr.data());
675
676 for (size_t i = 0; i < vec_t::width; ++i)
677 {
678 BOOST_CHECK_EQUAL(ascalararr[i], std::sqrt(val));
679 }
680}
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:290

References tinysimd::sqrt().

◆ BOOST_AUTO_TEST_CASE() [29/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_store  )

Definition at line 258 of file TestSimdLibDouble.cpp.

259{
260 double val = 4.0;
261 vec_t avec(val);
262 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
263 {}}; // double brace to deal with gcc 4.8.5 ...
264 avec.store(ascalararr.data());
265
266 for (size_t i = 0; i < vec_t::width; ++i)
267 {
268 BOOST_CHECK_EQUAL(ascalararr[i], val);
269 }
270}

◆ BOOST_AUTO_TEST_CASE() [30/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_store_aligned  )

Definition at line 272 of file TestSimdLibDouble.cpp.

273{
274 double val = 4.0;
275 vec_t avec(val);
276 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
277 {}}; // double brace to deal with gcc 4.8.5 ...
278 avec.store(ascalararr.data(), is_aligned);
279
280 for (size_t i = 0; i < vec_t::width; ++i)
281 {
282 BOOST_CHECK_EQUAL(ascalararr[i], val);
283 }
284}

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [31/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_store_non_temporal  )

Definition at line 300 of file TestSimdLibDouble.cpp.

301{
302 double val = 4.0;
303 vec_t avec(val);
304 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
305 {}}; // double brace to deal with gcc 4.8.5 ...
306 avec.store(ascalararr.data(), is_not_reused);
307
308 for (size_t i = 0; i < vec_t::width; ++i)
309 {
310 BOOST_CHECK_EQUAL(ascalararr[i], val);
311 }
312}

References tinysimd::is_not_reused.

◆ BOOST_AUTO_TEST_CASE() [32/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_store_unaligned  )

Definition at line 286 of file TestSimdLibDouble.cpp.

287{
288 double val = 4.0;
289 vec_t avec(val);
290 std::array<double, vec_t::width> ascalararr{
291 {}}; // double brace to deal with gcc 4.8.5 ...
292 avec.store(ascalararr.data(), is_not_aligned);
293
294 for (size_t i = 0; i < vec_t::width; ++i)
295 {
296 BOOST_CHECK_EQUAL(ascalararr[i], val);
297 }
298}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [33/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_sub_binary  )

Definition at line 578 of file TestSimdLibDouble.cpp.

579{
580 double val1 = -4.0;
581 double val2 = 2.5;
582 vec_t avec1(val1);
583 vec_t avec2(val2);
584 vec_t res = avec1 - avec2;
585 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
586 {}}; // double brace to deal with gcc 4.8.5 ...
587 res.store(ascalararr.data());
588
589 for (size_t i = 0; i < vec_t::width; ++i)
590 {
591 BOOST_CHECK_EQUAL(ascalararr[i], val1 - val2);
592 }
593}

◆ BOOST_AUTO_TEST_CASE() [34/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_sub_unary  )

Definition at line 510 of file TestSimdLibDouble.cpp.

511{
512 double val1 = -4.0;
513 double val2 = 2.0;
514 vec_t res(val1);
515 vec_t avec(val2);
516 res -= avec;
517 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
518 {}}; // double brace to deal with gcc 4.8.5 ...
519 res.store(ascalararr.data());
520
521 for (size_t i = 0; i < vec_t::width; ++i)
522 {
523 BOOST_CHECK_EQUAL(ascalararr[i], val1 - val2);
524 }
525}

◆ BOOST_AUTO_TEST_CASE() [35/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_subscript_assign_read  )

Definition at line 321 of file TestSimdLibDouble.cpp.

322{
323 vec_t avec;
324 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
325 {}}; // double brace to deal with gcc 4.8.5 ...
326
327 for (size_t i = 0; i < vec_t::width; ++i)
328 {
329 ascalararr[i] = i;
330 }
331
332 for (size_t i = 0; i < vec_t::width; ++i)
333 {
334 avec[i] = ascalararr[i];
335 }
336
337 for (size_t i = 0; i < vec_t::width; ++i)
338 {
339 BOOST_CHECK_EQUAL(ascalararr[i], avec[i]);
340 }
341}

◆ BOOST_AUTO_TEST_CASE() [36/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_type_traits  )

Definition at line 130 of file TestSimdLibDouble.cpp.

131{
132 {
133 using namespace details;
134
135 BOOST_CHECK_EQUAL(has_width<double>::value, false);
136 BOOST_CHECK_EQUAL(has_width<vec_t>::value, true);
137
138 BOOST_CHECK_EQUAL(has_alignment<double>::value, false);
139 BOOST_CHECK_EQUAL(has_alignment<vec_t>::value, true);
140
141 BOOST_CHECK_EQUAL(has_scalarType<double>::value, false);
142 BOOST_CHECK_EQUAL(has_scalarType<vec_t>::value, true);
143 }
144
145 BOOST_CHECK_EQUAL(is_vector_v<double>, false);
146 BOOST_CHECK_EQUAL(is_vector_v<vec_t>, true);
147
148 BOOST_CHECK_EQUAL(is_vector_floating_point_v<double>, false);
149 BOOST_CHECK_EQUAL(is_vector_floating_point_v<simd<int>>, false);
150 BOOST_CHECK_EQUAL(is_vector_floating_point_v<vec_t>, true);
151}

References tinysimd::is_vector_floating_point_v.

◆ BOOST_AUTO_TEST_CASE() [37/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_width_alignment  )

Definition at line 89 of file TestSimdLibDouble.cpp.

90{
91 std::size_t width, alignment;
92
93#if defined(USING_SCALAR)
94 std::cout << "scalar double" << std::endl;
95#endif
96#if defined(USING_SSE2)
97 std::cout << "sse2 double" << std::endl;
98#endif
99#if defined(USING_AVX2)
100 std::cout << "avx2 double" << std::endl;
101#endif
102#if defined(USING_AVX512)
103 std::cout << "avx512 double" << std::endl;
104#endif
105#if defined(USING_SVE)
106 std::cout << "sve double" << std::endl;
107#endif
108
109 // double
110 width = simd<double>::width;
111 alignment = simd<double>::alignment;
112 BOOST_CHECK_EQUAL(width, NUM_LANES_64BITS);
113 BOOST_CHECK_EQUAL(alignment, ALIGNMENT);
114 // std::int32_t index forcing # of lanes
117 BOOST_CHECK_EQUAL(width, NUM_LANES_64BITS);
118 // std::int64_t index forcing # of lanes
121 BOOST_CHECK_EQUAL(width, NUM_LANES_64BITS);
122 BOOST_CHECK_EQUAL(alignment, ALIGNMENT);
123 // std::int64_t default index
126 BOOST_CHECK_EQUAL(width, NUM_LANES_64BITS);
127 BOOST_CHECK_EQUAL(alignment, ALIGNMENT);
128}
#define ALIGNMENT
#define NUM_LANES_64BITS
The above copyright notice and this permission notice shall be included.

References ALIGNMENT, and NUM_LANES_64BITS.

◆ BOOST_AUTO_TEST_CASE() [38/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_abs  )

Definition at line 604 of file TestSimdLibSingle.cpp.

605{
606 float val = -4.0;
607 vec_t avec(val);
608 vec_t aabs = abs(avec);
609 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
610 {}}; // float brace to deal with gcc 4.8.5 ...
611 aabs.store(ascalararr.data());
612
613 for (size_t i = 0; i < vec_t::width; ++i)
614 {
615 BOOST_CHECK_EQUAL(ascalararr[i], std::abs(val));
616 }
617}

References tinysimd::abs().

◆ BOOST_AUTO_TEST_CASE() [39/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_add_binary  )

Definition at line 483 of file TestSimdLibSingle.cpp.

484{
485 float val1 = -4.0;
486 float val2 = 2.5;
487 vec_t avec1(val1);
488 vec_t avec2(val2);
489 vec_t res = avec1 + avec2;
490 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
491 {}}; // double brace to deal with gcc 4.8.5 ...
492 res.store(ascalararr.data());
493
494 for (size_t i = 0; i < vec_t::width; ++i)
495 {
496 BOOST_CHECK_EQUAL(ascalararr[i], val1 + val2);
497 }
498}

◆ BOOST_AUTO_TEST_CASE() [40/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_add_mul  )

Definition at line 551 of file TestSimdLibSingle.cpp.

552{
553 float val1 = -4.0;
554 float val2 = 2.0;
555 float val3 = 2.0;
556 vec_t avec1(val1);
557 vec_t avec2(val2);
558 vec_t avec3(val3);
559 vec_t res = avec1 + avec2 * avec3;
560 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
561 {}}; // float brace to deal with gcc 4.8.5 ...
562 res.store(ascalararr.data());
563
564 for (size_t i = 0; i < vec_t::width; ++i)
565 {
566 BOOST_CHECK_EQUAL(ascalararr[i], val1 + val2 + val3);
567 }
568}

◆ BOOST_AUTO_TEST_CASE() [41/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_add_unary  )

Definition at line 415 of file TestSimdLibSingle.cpp.

416{
417 float val1 = -4.0;
418 float val2 = 2.0;
419 vec_t res(val1);
420 vec_t avec(val2);
421 res += avec;
422 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
423 {}}; // float brace to deal with gcc 4.8.5 ...
424 res.store(ascalararr.data());
425
426 for (size_t i = 0; i < vec_t::width; ++i)
427 {
428 BOOST_CHECK_EQUAL(ascalararr[i], val1 + val2);
429 }
430}

◆ BOOST_AUTO_TEST_CASE() [42/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_ctors  )

Definition at line 147 of file TestSimdLibSingle.cpp.

148{
149 [[maybe_unused]] vec_t avec1;
150
151 vec_t::scalarType ascalar = 0;
152 vec_t avec2(ascalar);
153 [[maybe_unused]] vec_t avec3{ascalar};
154 vec_t avec4 = ascalar;
155
156 [[maybe_unused]] vec_t avec5(avec2);
157 [[maybe_unused]] vec_t avec6{avec4};
158
159 [[maybe_unused]] vec_t avec7(avec2._data);
160 [[maybe_unused]] vec_t avec8{avec2._data};
161
162 vec_t::vectorType anative;
163 [[maybe_unused]] vec_t avec9(anative);
164 [[maybe_unused]] vec_t avec10{anative};
165}

◆ BOOST_AUTO_TEST_CASE() [43/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_div_binary  )

Definition at line 534 of file TestSimdLibSingle.cpp.

535{
536 float val1 = -4.0;
537 float val2 = 2.5;
538 vec_t avec1(val1);
539 vec_t avec2(val2);
540 vec_t res = avec1 / avec2;
541 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
542 {}}; // double brace to deal with gcc 4.8.5 ...
543 res.store(ascalararr.data());
544
545 for (size_t i = 0; i < vec_t::width; ++i)
546 {
547 BOOST_CHECK_EQUAL(ascalararr[i], val1 / val2);
548 }
549}

◆ BOOST_AUTO_TEST_CASE() [44/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_div_unary  )

Definition at line 466 of file TestSimdLibSingle.cpp.

467{
468 float val1 = -4.0;
469 float val2 = 2.0;
470 vec_t res(val1);
471 vec_t avec(val2);
472 res /= avec;
473 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
474 {}}; // float brace to deal with gcc 4.8.5 ...
475 res.store(ascalararr.data());
476
477 for (size_t i = 0; i < vec_t::width; ++i)
478 {
479 BOOST_CHECK_EQUAL(ascalararr[i], val1 / val2);
480 }
481}

◆ BOOST_AUTO_TEST_CASE() [45/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_fused_add_mul  )

Definition at line 570 of file TestSimdLibSingle.cpp.

571{
572 float val1 = -4.0;
573 float val2 = 1.5;
574 float val3 = 5.0;
575 vec_t avec1(val1);
576 vec_t avec2(val2);
577 vec_t avec3(val3);
578 avec1.fma(avec2, avec3);
579 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
580 {}}; // double brace to deal with gcc 4.8.5 ...
581 avec1.store(ascalararr.data());
582
583 for (size_t i = 0; i < vec_t::width; ++i)
584 {
585 BOOST_CHECK_EQUAL(ascalararr[i], val1 + val2 * val3);
586 }
587}

◆ BOOST_AUTO_TEST_CASE() [46/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_gather32  )

Definition at line 286 of file TestSimdLibSingle.cpp.

287{
288 vec_t avec;
289 using index_t = simd<std::uint32_t>;
290 index_t aindexvec;
291
292 // create and fill index
293 std::array<std::uint32_t, vec_t::width> aindex;
294 aindex[0] = 0;
295 if (vec_t::width > 2)
296 {
297 aindex[1] = 3;
298 aindex[2] = 5;
299 aindex[3] = 6;
300 }
301 if (vec_t::width > 4)
302 {
303 aindex[4] = 8;
304 aindex[5] = 15;
305 aindex[6] = 20;
306 aindex[7] = 23;
307 }
308 if (vec_t::width > 8)
309 {
310 aindex[8] = 24;
311 aindex[9] = 28;
312 aindex[10] = 33;
313 aindex[11] = 40;
314 aindex[12] = 41;
315 aindex[13] = 45;
316 aindex[14] = 60;
317 aindex[15] = 61;
318 }
319
320 // load index
321 aindexvec.load(aindex.data(), is_not_aligned);
322
323 // create and fill scalar array
324 constexpr size_t scalarArraySize = 64;
325 std::array<float, scalarArraySize> ascalararr;
326 for (size_t i = 0; i < scalarArraySize; ++i)
327 {
328 ascalararr[i] = i;
329 }
330
331 avec.gather(ascalararr.data(), aindexvec);
332
333 // check
334 for (size_t i = 0; i < vec_t::width; ++i)
335 {
336 BOOST_CHECK_EQUAL(ascalararr[aindex[i]], avec[i]);
337 }
338}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [47/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_greater  )

Definition at line 634 of file TestSimdLibSingle.cpp.

635{
636 float aval = 4.0;
637 vec_t avec(aval);
638 using mask_t = simd<bool, vec_t::width>;
639 mask_t amask;
640
641 amask = avec > avec;
642 // check
643 alignas(vec_t::alignment) std::array<std::uint32_t, vec_t::width>
644 ascalararr{{}}; // float brace to deal with gcc 4.8.5 ...
645 amask.store(ascalararr.data());
646 for (size_t i = 0; i < vec_t::width; ++i)
647 {
648 // type conversion make lvalue in rvalue, needed pre-c++17
649 BOOST_CHECK_EQUAL(ascalararr[i], (std::uint32_t)mask_t::false_v);
650 }
651
652 float bval = 3.0;
653 vec_t bvec(bval);
654
655 amask = avec > bvec;
656 // check
657 amask.store(ascalararr.data());
658 for (size_t i = 0; i < vec_t::width; ++i)
659 {
660 // type conversion make lvalue in rvalue, needed pre-c++17
661 BOOST_CHECK_EQUAL(ascalararr[i], (std::uint32_t)mask_t::true_v);
662 }
663
664 float cval = 5.0;
665 vec_t cvec(cval);
666
667 amask = avec > cvec;
668 // check
669 amask.store(ascalararr.data());
670 for (size_t i = 0; i < vec_t::width; ++i)
671 {
672 // type conversion make lvalue in rvalue, needed pre-c++17
673 BOOST_CHECK_EQUAL(ascalararr[i], (std::uint32_t)mask_t::false_v);
674 }
675
676 if (vec_t::width == 4)
677 {
678 alignas(vec_t::alignment) std::array<float, 4> ascalararr2{
679 {1.0, 2.0, 3.0, 4.0}}; // float brace to deal with gcc 4.8.5 ...
680 float dval = 2.0;
681 vec_t dvec(dval);
682 vec_t evec;
683 evec.load(ascalararr2.data());
684
685 amask = dvec > evec;
686 // check
687 for (size_t i = 0; i < vec_t::width; ++i)
688 {
689 BOOST_CHECK_EQUAL(static_cast<bool>(amask[i]), dvec[i] > evec[i]);
690 }
691 }
692
693 if (vec_t::width == 8)
694 {
695 alignas(vec_t::alignment) std::array<float, 8> ascalararr2{
696 {1.0, 2.0, 3.0, 4.0, 3.0, 2.0,
697 1.0}}; // double brace to deal with gcc 4.8.5 ...
698 float dval = 2.0;
699 vec_t dvec(dval);
700 vec_t evec;
701 evec.load(ascalararr2.data());
702
703 amask = dvec > evec;
704 // check
705 for (size_t i = 0; i < vec_t::width; ++i)
706 {
707 BOOST_CHECK_EQUAL(static_cast<bool>(amask[i]),
708 dval > ascalararr2[i]);
709 }
710 }
711}

◆ BOOST_AUTO_TEST_CASE() [48/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_io  )

Definition at line 874 of file TestSimdLibSingle.cpp.

875{
876 vec_t avec(3.14);
877 std::cout << avec << std::endl;
878}

◆ BOOST_AUTO_TEST_CASE() [49/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_load  )

Definition at line 167 of file TestSimdLibSingle.cpp.

168{
169 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
170 {}}; // double brace to deal with gcc 4.8.5 ...
171 vec_t avec;
172 avec.load(ascalararr.data());
173}

◆ BOOST_AUTO_TEST_CASE() [50/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_load_aligned  )

Definition at line 183 of file TestSimdLibSingle.cpp.

184{
185 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
186 {}}; // double brace to deal with gcc 4.8.5 ...
187 vec_t avec;
188 avec.load(ascalararr.data(), is_aligned);
189}

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [51/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_load_implicit  )

Definition at line 175 of file TestSimdLibSingle.cpp.

176{
177 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
178 {}}; // double brace to deal with gcc 4.8.5 ...
179 vec_t avec;
180 avec = *(reinterpret_cast<vec_t *>(ascalararr.data()));
181}

◆ BOOST_AUTO_TEST_CASE() [52/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_load_interleave_unload  )

Definition at line 751 of file TestSimdLibSingle.cpp.

752{
753 constexpr size_t nDof{5};
754 // no padding in load_interleave deinterleave_store
755 constexpr size_t nEle{vec_t::width * 5};
756 constexpr size_t nDofBlock = nDof * vec_t::width;
757
758 constexpr size_t size{nDof * nEle};
759 std::array<float, size> dofScalarArr{{}};
760 for (size_t i = 0; i < size; ++i)
761 {
762 dofScalarArr[i] = i;
763 }
764
765 // number of blocks
766 size_t nBlock = nEle / vec_t::width;
767
768 // aligned vector
769 std::vector<vec_t, allocator<vec_t>> dofVectorArr(nDof);
770
771 float *dataPtr = dofScalarArr.data();
772 // loop over blocks vec_t::width elements at the time
773 for (size_t b = 0; b < nBlock; ++b)
774 {
775 // load
776 load_interleave(dataPtr, nDof, dofVectorArr);
777
778 // manipulate each block
779 for (size_t j = 0; j < nDof; ++j)
780 {
781 dofVectorArr[j] = dofVectorArr[j] + j;
782 }
783
784 // store
785 deinterleave_store(dofVectorArr, nDof, dataPtr);
786 dataPtr += nDofBlock;
787 }
788
789 // check
790 for (size_t b = 0, i = 0; b < nBlock; ++b)
791 {
792 for (size_t j = 0; j < nDof; ++j, ++i)
793 {
794 BOOST_CHECK_EQUAL(dofScalarArr[i], i + j);
795 }
796 }
797}

References tinysimd::deinterleave_store(), and tinysimd::load_interleave().

◆ BOOST_AUTO_TEST_CASE() [53/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_load_unaligned  )

Definition at line 191 of file TestSimdLibSingle.cpp.

192{
193 std::array<float, vec_t::width> ascalararr{
194 {}}; // double brace to deal with gcc 4.8.5 ...
195 vec_t avec;
196 avec.load(ascalararr.data(), is_not_aligned);
197}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [54/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_log  )

Definition at line 619 of file TestSimdLibSingle.cpp.

620{
621 float val = 4.0;
622 vec_t avec(val);
623 vec_t alog = log(avec);
624 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
625 {}}; // float brace to deal with gcc 4.8.5 ...
626 alog.store(ascalararr.data());
627
628 for (size_t i = 0; i < vec_t::width; ++i)
629 {
630 BOOST_CHECK_EQUAL(ascalararr[i], std::log(val));
631 }
632}

References tinysimd::log().

◆ BOOST_AUTO_TEST_CASE() [55/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_logic_and  )

Definition at line 713 of file TestSimdLibSingle.cpp.

714{
715 float aval = 4.0;
716 vec_t avec(aval);
717 using mask_t = simd<bool, vec_t::width>;
718 mask_t amask;
719
720 alignas(vec_t::alignment) std::array<std::uint32_t, vec_t::width>
721 ascalararr{{}}; // float brace to deal with gcc 4.8.5 ...
722 for (size_t i = 0; i < vec_t::width; ++i)
723 {
724 ascalararr[i] = mask_t::true_v;
725 }
726 amask.load(ascalararr.data());
727
728 // check
729 BOOST_CHECK_EQUAL(amask && false, false);
730 BOOST_CHECK_EQUAL(amask && true, true);
731
732 for (size_t i = 0; i < vec_t::width; ++i)
733 {
734 ascalararr[i] = mask_t::false_v;
735 }
736 amask.load(ascalararr.data());
737
738 // check
739 BOOST_CHECK_EQUAL(amask && false, false);
740 BOOST_CHECK_EQUAL(amask && true, false);
741
742 if (vec_t::width > 1)
743 {
744 ascalararr[0] = mask_t::true_v;
745 // check
746 BOOST_CHECK_EQUAL(amask && false, false);
747 BOOST_CHECK_EQUAL(amask && true, false);
748 }
749}

◆ BOOST_AUTO_TEST_CASE() [56/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_longsimd_interleave_helpers  )

Definition at line 834 of file TestSimdLibSingle.cpp.

835{
836 constexpr size_t nDof = 3;
837 constexpr size_t nBlocks = 2;
838 constexpr size_t nEle = long_vec_t::width * nBlocks;
839 constexpr size_t blockSize = nDof * long_vec_t::width;
840 constexpr size_t size = nDof * nEle;
841
842 std::array<float, size> data{{}};
843 for (size_t i = 0; i < size; ++i)
844 {
845 data[i] = static_cast<float>(i);
846 }
847
848 std::vector<long_vec_t, allocator<long_vec_t>> work(nDof);
849
850 for (size_t block = 0; block < nBlocks; ++block)
851 {
852 float *dataPtr = data.data() + block * blockSize;
853 load_interleave(dataPtr, nDof, work);
854 for (size_t j = 0; j < nDof; ++j)
855 {
856 work[j] += static_cast<float>(j + 1);
857 }
858 deinterleave_store(work, nDof, dataPtr);
859 }
860
861 for (size_t block = 0; block < nBlocks; ++block)
862 {
863 for (size_t lane = 0; lane < long_vec_t::width; ++lane)
864 {
865 for (size_t dof = 0; dof < nDof; ++dof)
866 {
867 const auto idx = block * blockSize + lane * nDof + dof;
868 BOOST_CHECK_EQUAL(data[idx], static_cast<float>(idx + dof + 1));
869 }
870 }
871 }
872}

References tinysimd::deinterleave_store(), and tinysimd::load_interleave().

◆ BOOST_AUTO_TEST_CASE() [57/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_longsimd_mixed_arithmetic  )

Definition at line 799 of file TestSimdLibSingle.cpp.

800{
801 alignas(long_vec_t::alignment) std::array<float, long_vec_t::width> lhsData{
802 {}};
803 alignas(vec_t::alignment) std::array<float, vec_t::width> rhsData{{}};
804
805 for (size_t i = 0; i < lhsData.size(); ++i)
806 {
807 lhsData[i] = static_cast<float>(i + 1);
808 }
809 for (size_t i = 0; i < rhsData.size(); ++i)
810 {
811 rhsData[i] = static_cast<float>(i + 1);
812 }
813
814 long_vec_t lhs;
815 lhs.load(lhsData.data(), is_aligned);
816
817 vec_t rhs;
818 rhs.load(rhsData.data(), is_aligned);
819
820 auto mixed = lhs + rhs;
821 mixed += rhs;
822 mixed += 2.0f;
823
824 alignas(long_vec_t::alignment) std::array<float, long_vec_t::width> tmp{{}};
825 mixed.store(tmp.data(), is_aligned);
826 for (size_t i = 0; i < tmp.size(); ++i)
827 {
828 const auto chunkLane = i % vec_t::width;
829 BOOST_CHECK_EQUAL(tmp[i],
830 lhsData[i] + 2.0f * rhsData[chunkLane] + 2.0f);
831 }
832}

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [58/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_mem_size  )

Definition at line 142 of file TestSimdLibSingle.cpp.

143{
144 BOOST_CHECK_EQUAL(sizeof(vec_t), sizeof(float) * vec_t::width);
145}

◆ BOOST_AUTO_TEST_CASE() [59/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_mul_binary  )

Definition at line 517 of file TestSimdLibSingle.cpp.

518{
519 float val1 = -4.0;
520 float val2 = 2.5;
521 vec_t avec1(val1);
522 vec_t avec2(val2);
523 vec_t res = avec1 * avec2;
524 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
525 {}}; // double brace to deal with gcc 4.8.5 ...
526 res.store(ascalararr.data());
527
528 for (size_t i = 0; i < vec_t::width; ++i)
529 {
530 BOOST_CHECK_EQUAL(ascalararr[i], val1 * val2);
531 }
532}

◆ BOOST_AUTO_TEST_CASE() [60/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_mul_unary  )

Definition at line 449 of file TestSimdLibSingle.cpp.

450{
451 float val1 = -4.0;
452 float val2 = 2.0;
453 vec_t res(val1);
454 vec_t avec(val2);
455 res *= avec;
456 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
457 {}}; // float brace to deal with gcc 4.8.5 ...
458 res.store(ascalararr.data());
459
460 for (size_t i = 0; i < vec_t::width; ++i)
461 {
462 BOOST_CHECK_EQUAL(ascalararr[i], val1 * val2);
463 }
464}

◆ BOOST_AUTO_TEST_CASE() [61/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_scatter32  )

Definition at line 340 of file TestSimdLibSingle.cpp.

341{
342 vec_t avec;
343 using index_t = simd<std::uint32_t>;
344 index_t aindexvec;
345
346 // create and fill index
347 std::array<std::uint32_t, vec_t::width> aindex;
348 aindex[0] = 1;
349 if (vec_t::width > 1)
350 {
351 aindex[1] = 3;
352 }
353 if (vec_t::width > 2)
354 {
355 aindex[2] = 5;
356 aindex[3] = 6;
357 }
358 if (vec_t::width > 4)
359 {
360 aindex[4] = 8;
361 aindex[5] = 15;
362 aindex[6] = 20;
363 aindex[7] = 30;
364 }
365 if (vec_t::width > 8)
366 {
367 aindex[8] = 31;
368 aindex[9] = 32;
369 aindex[10] = 35;
370 aindex[11] = 40;
371 aindex[12] = 41;
372 aindex[13] = 45;
373 aindex[14] = 60;
374 aindex[15] = 61;
375 }
376
377 // load index
378 aindexvec.load(aindex.data(), is_not_aligned);
379
380 // create scalar array
381 constexpr size_t scalarArraySize = 64;
382 std::array<float, scalarArraySize> ascalararr;
383
384 // fill vector
385 alignas(vec_t::alignment) std::array<float, vec_t::width> avecarr{{}};
386 avecarr[0] = 10;
387 if (vec_t::width > 1)
388 {
389 avecarr[1] = 9;
390 }
391
392 if (vec_t::width > 2)
393 {
394 avec[2] = 8;
395 avec[3] = 7;
396 }
397 if (vec_t::width > 4)
398 {
399 avec[4] = 4;
400 avec[5] = 3;
401 avec[6] = 2;
402 avec[7] = 1;
403 }
404 avec.load(avecarr.data());
405
406 avec.scatter(ascalararr.data(), aindexvec);
407
408 // check
409 for (size_t i = 0; i < vec_t::width; ++i)
410 {
411 BOOST_CHECK_EQUAL(avec[i], ascalararr[aindex[i]]);
412 }
413}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [62/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_sqrt  )

Definition at line 589 of file TestSimdLibSingle.cpp.

590{
591 float val = 4.0;
592 vec_t avec(val);
593 vec_t asqrt = sqrt(avec);
594 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
595 {}}; // float brace to deal with gcc 4.8.5 ...
596 asqrt.store(ascalararr.data());
597
598 for (size_t i = 0; i < vec_t::width; ++i)
599 {
600 BOOST_CHECK_EQUAL(ascalararr[i], std::sqrt(val));
601 }
602}

References tinysimd::sqrt().

◆ BOOST_AUTO_TEST_CASE() [63/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_store  )

Definition at line 199 of file TestSimdLibSingle.cpp.

200{
201 float val = 4.0;
202 vec_t avec(val);
203 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
204 {}}; // float brace to deal with gcc 4.8.5 ...
205 avec.store(ascalararr.data());
206
207 for (size_t i = 0; i < vec_t::width; ++i)
208 {
209 BOOST_CHECK_EQUAL(ascalararr[i], val);
210 }
211}

◆ BOOST_AUTO_TEST_CASE() [64/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_store_aligned  )

Definition at line 213 of file TestSimdLibSingle.cpp.

214{
215 float val = 4.0;
216 vec_t avec(val);
217 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
218 {}}; // float brace to deal with gcc 4.8.5 ...
219 avec.store(ascalararr.data(), is_aligned);
220
221 for (size_t i = 0; i < vec_t::width; ++i)
222 {
223 BOOST_CHECK_EQUAL(ascalararr[i], val);
224 }
225}

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [65/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_store_non_temporal  )

Definition at line 241 of file TestSimdLibSingle.cpp.

242{
243 float val = 4.0;
244 vec_t avec(val);
245 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
246 {}}; // float brace to deal with gcc 4.8.5 ...
247 avec.store(ascalararr.data(), is_not_reused);
248
249 for (size_t i = 0; i < vec_t::width; ++i)
250 {
251 BOOST_CHECK_EQUAL(ascalararr[i], val);
252 }
253}

References tinysimd::is_not_reused.

◆ BOOST_AUTO_TEST_CASE() [66/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_store_unaligned  )

Definition at line 227 of file TestSimdLibSingle.cpp.

228{
229 float val = 4.0;
230 vec_t avec(val);
231 std::array<float, vec_t::width> ascalararr{
232 {}}; // float brace to deal with gcc 4.8.5 ...
233 avec.store(ascalararr.data(), is_not_aligned);
234
235 for (size_t i = 0; i < vec_t::width; ++i)
236 {
237 BOOST_CHECK_EQUAL(ascalararr[i], val);
238 }
239}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [67/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_sub_binary  )

Definition at line 500 of file TestSimdLibSingle.cpp.

501{
502 float val1 = -4.0;
503 float val2 = 2.5;
504 vec_t avec1(val1);
505 vec_t avec2(val2);
506 vec_t res = avec1 - avec2;
507 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
508 {}}; // double brace to deal with gcc 4.8.5 ...
509 res.store(ascalararr.data());
510
511 for (size_t i = 0; i < vec_t::width; ++i)
512 {
513 BOOST_CHECK_EQUAL(ascalararr[i], val1 - val2);
514 }
515}

◆ BOOST_AUTO_TEST_CASE() [68/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_sub_unary  )

Definition at line 432 of file TestSimdLibSingle.cpp.

433{
434 float val1 = -4.0;
435 float val2 = 2.0;
436 vec_t res(val1);
437 vec_t avec(val2);
438 res -= avec;
439 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
440 {}}; // float brace to deal with gcc 4.8.5 ...
441 res.store(ascalararr.data());
442
443 for (size_t i = 0; i < vec_t::width; ++i)
444 {
445 BOOST_CHECK_EQUAL(ascalararr[i], val1 - val2);
446 }
447}

◆ BOOST_AUTO_TEST_CASE() [69/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_type_traits  )

Definition at line 121 of file TestSimdLibSingle.cpp.

122{
123 using namespace details;
124
125 BOOST_CHECK_EQUAL(has_width<float>::value, false);
126 BOOST_CHECK_EQUAL(has_width<vec_t>::value, true);
127
128 BOOST_CHECK_EQUAL(has_alignment<float>::value, false);
129 BOOST_CHECK_EQUAL(has_alignment<vec_t>::value, true);
130
131 BOOST_CHECK_EQUAL(has_scalarType<float>::value, false);
132 BOOST_CHECK_EQUAL(has_scalarType<vec_t>::value, true);
133
134 BOOST_CHECK_EQUAL(is_vector_v<float>, false);
135 BOOST_CHECK_EQUAL(is_vector_v<vec_t>, true);
136
137 BOOST_CHECK_EQUAL(is_vector_floating_point_v<float>, false);
138 BOOST_CHECK_EQUAL(is_vector_floating_point_v<simd<int>>, false);
139 BOOST_CHECK_EQUAL(is_vector_floating_point_v<vec_t>, true);
140}

References tinysimd::is_vector_floating_point_v.

◆ BOOST_AUTO_TEST_CASE() [70/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt32_load  )

Definition at line 234 of file TestSimdLibDouble.cpp.

235{
236 alignas(vec_t::alignment) std::array<std::uint32_t, vec_t::width>
237 ascalararr{{}}; // double brace to deal with gcc 4.8.5 ...
238 simd<std::uint32_t, vec_t::width> aindex;
239 aindex.load(ascalararr.data());
240}

◆ BOOST_AUTO_TEST_CASE() [71/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt32_load_aligned  )

Definition at line 242 of file TestSimdLibDouble.cpp.

243{
244 alignas(vec_t::alignment) std::array<std::uint32_t, vec_t::width>
245 ascalararr{{}}; // double brace to deal with gcc 4.8.5 ...
246 simd<std::uint32_t, vec_t::width> aindex;
247 aindex.load(ascalararr.data(), is_aligned);
248}

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [72/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt32_load_unaligned  )

Definition at line 250 of file TestSimdLibDouble.cpp.

251{
252 std::array<std::uint32_t, vec_t::width> ascalararr{
253 {}}; // double brace to deal with gcc 4.8.5 ...
254 simd<std::uint32_t, vec_t::width> aindex;
255 aindex.load(ascalararr.data(), is_not_aligned);
256}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [73/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt64_load  )

Definition at line 210 of file TestSimdLibDouble.cpp.

211{
212 alignas(vec_t::alignment) std::array<std::uint64_t, vec_t::width>
213 ascalararr{{}}; // double brace to deal with gcc 4.8.5 ...
214 simd<std::uint64_t, vec_t::width> aindex;
215 aindex.load(ascalararr.data());
216}

◆ BOOST_AUTO_TEST_CASE() [74/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt64_load_aligned  )

Definition at line 218 of file TestSimdLibDouble.cpp.

219{
220 alignas(vec_t::alignment) std::array<std::uint64_t, vec_t::width>
221 ascalararr{{}}; // double brace to deal with gcc 4.8.5 ...
222 simd<std::uint64_t, vec_t::width> aindex;
223 aindex.load(ascalararr.data(), is_aligned);
224}

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [75/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt64_load_unaligned  )

Definition at line 226 of file TestSimdLibDouble.cpp.

227{
228 std::array<std::uint64_t, vec_t::width> ascalararr{
229 {}}; // double brace to deal with gcc 4.8.5 ...
230 simd<std::uint64_t, vec_t::width> aindex;
231 aindex.load(ascalararr.data(), is_not_aligned);
232}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [76/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibSingle_broadcast  )

Definition at line 255 of file TestSimdLibSingle.cpp.

256{
257 // explictly float literal for
258 // Visual Studio 14 2015 Win64 compiler bug
259 vec_t::scalarType ascalar{3.333f};
260 vec_t avec;
261 avec.broadcast(ascalar);
262}

◆ BOOST_AUTO_TEST_CASE() [77/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibSingle_subscript_assign_read  )

Definition at line 264 of file TestSimdLibSingle.cpp.

265{
266 vec_t avec;
267 alignas(vec_t::alignment) std::array<float, vec_t::width> ascalararr{
268 {}}; // double brace to deal with gcc 4.8.5 ...
269
270 for (size_t i = 0; i < vec_t::width; ++i)
271 {
272 ascalararr[i] = i;
273 }
274
275 for (size_t i = 0; i < vec_t::width; ++i)
276 {
277 avec[i] = ascalararr[i];
278 }
279
280 for (size_t i = 0; i < vec_t::width; ++i)
281 {
282 BOOST_CHECK_EQUAL(ascalararr[i], avec[i]);
283 }
284}

◆ BOOST_AUTO_TEST_CASE() [78/78]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibSingle_width_alignment  )

Definition at line 87 of file TestSimdLibSingle.cpp.

88{
89 std::size_t width, alignment;
90
91#if defined(USING_SCALAR)
92 std::cout << "scalar float" << std::endl;
93#endif
94#if defined(USING_AVX2)
95 std::cout << "avx2 float" << std::endl;
96#endif
97#if defined(USING_AVX512)
98 std::cout << "avx512 float" << std::endl;
99#endif
100#if defined(USING_SVE)
101 std::cout << "sve float" << std::endl;
102#endif
103
104 // float
105 width = simd<float>::width;
106 alignment = simd<float>::alignment;
107 BOOST_CHECK_EQUAL(width, NUM_LANES_32BITS);
108 BOOST_CHECK_EQUAL(alignment, ALIGNMENT);
109 // std::int32_t index forcing # of lanes
112 BOOST_CHECK_EQUAL(width, NUM_LANES_32BITS);
113 BOOST_CHECK_EQUAL(alignment, ALIGNMENT);
114 // std::int32_t default index
117 BOOST_CHECK_EQUAL(width, NUM_LANES_32BITS);
118 BOOST_CHECK_EQUAL(alignment, ALIGNMENT);
119}
#define NUM_LANES_32BITS
The above copyright notice and this permission notice shall be included.
#define ALIGNMENT

References ALIGNMENT, and NUM_LANES_32BITS.