Nektar++
Typedefs | Functions
Nektar::SimdLibTests Namespace Reference

Typedefs

using vec_t = simd< double >
 

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_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_io)
 

Typedef Documentation

◆ vec_t

Definition at line 85 of file TestSimdLibDouble.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_abs  )

Definition at line 677 of file TestSimdLibDouble.cpp.

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

References tinysimd::abs().

◆ BOOST_AUTO_TEST_CASE() [2/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_add_binary  )

Definition at line 556 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [3/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_add_mul  )

Definition at line 624 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [4/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_add_unary  )

Definition at line 488 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [5/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_broadcast  )

Definition at line 309 of file TestSimdLibDouble.cpp.

310{
311 vec_t::scalarType ascalar{3.333};
312 vec_t avec;
313 avec.broadcast(ascalar);
314}
tinysimd::simd< NekDouble > vec_t

◆ BOOST_AUTO_TEST_CASE() [6/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_ctors  )

Definition at line 153 of file TestSimdLibDouble.cpp.

154{
155 [[maybe_unused]] vec_t avec1;
156
157 vec_t::scalarType ascalar = 0;
158 vec_t avec2(ascalar);
159 [[maybe_unused]] vec_t avec3{ascalar};
160 vec_t avec4 = ascalar;
161
162 [[maybe_unused]] vec_t avec5(avec2);
163 [[maybe_unused]] vec_t avec6{avec4};
164
165 [[maybe_unused]] vec_t avec7(avec2._data);
166 [[maybe_unused]] vec_t avec8{avec2._data};
167
168 vec_t::vectorType anative;
169 [[maybe_unused]] vec_t avec9(anative);
170 [[maybe_unused]] vec_t avec10{anative};
171}

◆ BOOST_AUTO_TEST_CASE() [7/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_div_binary  )

Definition at line 607 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [8/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_div_unary  )

Definition at line 539 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [9/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_fused_add_mul  )

Definition at line 643 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [10/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_gather32  )

Definition at line 381 of file TestSimdLibDouble.cpp.

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

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [11/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_gather64  )

Definition at line 338 of file TestSimdLibDouble.cpp.

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

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [12/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_greater  )

Definition at line 707 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [13/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_io  )

Definition at line 873 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [14/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_load  )

Definition at line 173 of file TestSimdLibDouble.cpp.

174{
175 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
176 {}}; // double brace to deal with gcc 4.8.5 ...
177 vec_t avec;
178 avec.load(ascalararr.data());
179}

◆ BOOST_AUTO_TEST_CASE() [15/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_load_aligned  )

Definition at line 189 of file TestSimdLibDouble.cpp.

190{
191 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
192 {}}; // double brace to deal with gcc 4.8.5 ...
193 vec_t avec;
194 avec.load(ascalararr.data(), is_aligned);
195}
static constexpr struct tinysimd::is_aligned_t is_aligned

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [16/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_load_implicit  )

Definition at line 181 of file TestSimdLibDouble.cpp.

182{
183 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
184 {}}; // double brace to deal with gcc 4.8.5 ...
185 vec_t avec;
186 avec = *(reinterpret_cast<vec_t *>(ascalararr.data()));
187}

◆ BOOST_AUTO_TEST_CASE() [17/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_load_interleave_unload  )

Definition at line 825 of file TestSimdLibDouble.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [18/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_load_unaligned  )

Definition at line 197 of file TestSimdLibDouble.cpp.

198{
199 std::array<double, vec_t::width> ascalararr{
200 {}}; // double brace to deal with gcc 4.8.5 ...
201 vec_t avec;
202 avec.load(ascalararr.data(), is_not_aligned);
203}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [19/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_log  )

Definition at line 692 of file TestSimdLibDouble.cpp.

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

References tinysimd::log().

◆ BOOST_AUTO_TEST_CASE() [20/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_logic_and  )

Definition at line 787 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [21/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_mem_size  )

Definition at line 148 of file TestSimdLibDouble.cpp.

149{
150 BOOST_CHECK_EQUAL(sizeof(vec_t), sizeof(double) * vec_t::width);
151}

◆ BOOST_AUTO_TEST_CASE() [22/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_mul_binary  )

Definition at line 590 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [23/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_mul_unary  )

Definition at line 522 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [24/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_scatter64  )

Definition at line 424 of file TestSimdLibDouble.cpp.

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

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [25/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_sqrt  )

Definition at line 662 of file TestSimdLibDouble.cpp.

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

References tinysimd::sqrt().

◆ BOOST_AUTO_TEST_CASE() [26/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_store  )

Definition at line 253 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [27/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_store_aligned  )

Definition at line 267 of file TestSimdLibDouble.cpp.

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

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [28/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_store_non_temporal  )

Definition at line 295 of file TestSimdLibDouble.cpp.

296{
297 double val = 4.0;
298 vec_t avec(val);
299 alignas(vec_t::alignment) std::array<double, vec_t::width> ascalararr{
300 {}}; // double brace to deal with gcc 4.8.5 ...
301 avec.store(ascalararr.data(), is_not_reused);
302
303 for (size_t i = 0; i < vec_t::width; ++i)
304 {
305 BOOST_CHECK_EQUAL(ascalararr[i], val);
306 }
307}
static constexpr struct tinysimd::is_not_reused_t is_not_reused

References tinysimd::is_not_reused.

◆ BOOST_AUTO_TEST_CASE() [29/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_store_unaligned  )

Definition at line 281 of file TestSimdLibDouble.cpp.

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

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [30/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_sub_binary  )

Definition at line 573 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [31/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_sub_unary  )

Definition at line 505 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [32/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_subscript_assign_read  )

Definition at line 316 of file TestSimdLibDouble.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [33/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_type_traits  )

Definition at line 125 of file TestSimdLibDouble.cpp.

126{
127 {
128 using namespace details;
129
130 BOOST_CHECK_EQUAL(has_width<double>::value, false);
131 BOOST_CHECK_EQUAL(has_width<vec_t>::value, true);
132
133 BOOST_CHECK_EQUAL(has_alignment<double>::value, false);
134 BOOST_CHECK_EQUAL(has_alignment<vec_t>::value, true);
135
136 BOOST_CHECK_EQUAL(has_scalarType<double>::value, false);
137 BOOST_CHECK_EQUAL(has_scalarType<vec_t>::value, true);
138 }
139
140 BOOST_CHECK_EQUAL(is_vector<double>::value, false);
141 BOOST_CHECK_EQUAL(is_vector<vec_t>::value, true);
142
143 BOOST_CHECK_EQUAL(is_vector_floating_point<double>::value, false);
144 BOOST_CHECK_EQUAL(is_vector_floating_point<simd<int>>::value, false);
145 BOOST_CHECK_EQUAL(is_vector_floating_point<vec_t>::value, true);
146}

◆ BOOST_AUTO_TEST_CASE() [34/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibDouble_width_alignment  )

Definition at line 87 of file TestSimdLibDouble.cpp.

88{
89 std::size_t width, alignment;
90
91#if defined(USING_SCALAR)
92 std::cout << "scalar double" << std::endl;
93#endif
94#if defined(USING_AVX2)
95 std::cout << "avx2 double" << std::endl;
96#endif
97#if defined(USING_AVX512)
98 std::cout << "avx512 double" << std::endl;
99#endif
100#if defined(USING_SVE)
101 std::cout << "sve double" << std::endl;
102#endif
103
104 // double
105 width = simd<double>::width;
106 alignment = simd<double>::alignment;
107 BOOST_CHECK_EQUAL(width, NUM_LANES_64BITS);
108 BOOST_CHECK_EQUAL(alignment, ALIGNMENT);
109 // std::int32_t index forcing # of lanes
112 BOOST_CHECK_EQUAL(width, NUM_LANES_64BITS);
113 // std::int64_t index forcing # of lanes
116 BOOST_CHECK_EQUAL(width, NUM_LANES_64BITS);
117 BOOST_CHECK_EQUAL(alignment, ALIGNMENT);
118 // std::int64_t default index
121 BOOST_CHECK_EQUAL(width, NUM_LANES_64BITS);
122 BOOST_CHECK_EQUAL(alignment, ALIGNMENT);
123}
#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() [35/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_abs  )

Definition at line 603 of file TestSimdLibSingle.cpp.

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

References tinysimd::abs().

◆ BOOST_AUTO_TEST_CASE() [36/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_add_binary  )

Definition at line 482 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [37/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_add_mul  )

Definition at line 550 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [38/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_add_unary  )

Definition at line 414 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [39/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_ctors  )

Definition at line 146 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [40/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_div_binary  )

Definition at line 533 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [41/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_div_unary  )

Definition at line 465 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [42/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_fused_add_mul  )

Definition at line 569 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [43/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_gather32  )

Definition at line 285 of file TestSimdLibSingle.cpp.

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

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [44/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_greater  )

Definition at line 633 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [45/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_io  )

Definition at line 798 of file TestSimdLibSingle.cpp.

799{
800 vec_t avec(3.14);
801 std::cout << avec << std::endl;
802}

◆ BOOST_AUTO_TEST_CASE() [46/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_load  )

Definition at line 166 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [47/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_load_aligned  )

Definition at line 182 of file TestSimdLibSingle.cpp.

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

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [48/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_load_implicit  )

Definition at line 174 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [49/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_load_interleave_unload  )

Definition at line 750 of file TestSimdLibSingle.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [50/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_load_unaligned  )

Definition at line 190 of file TestSimdLibSingle.cpp.

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

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [51/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_log  )

Definition at line 618 of file TestSimdLibSingle.cpp.

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

References tinysimd::log().

◆ BOOST_AUTO_TEST_CASE() [52/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_logic_and  )

Definition at line 712 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [53/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_mem_size  )

Definition at line 141 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [54/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_mul_binary  )

Definition at line 516 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [55/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_mul_unary  )

Definition at line 448 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [56/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_scatter32  )

Definition at line 339 of file TestSimdLibSingle.cpp.

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

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [57/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_sqrt  )

Definition at line 588 of file TestSimdLibSingle.cpp.

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

References tinysimd::sqrt().

◆ BOOST_AUTO_TEST_CASE() [58/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_store  )

Definition at line 198 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [59/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_store_aligned  )

Definition at line 212 of file TestSimdLibSingle.cpp.

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

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [60/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_store_non_temporal  )

Definition at line 240 of file TestSimdLibSingle.cpp.

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

References tinysimd::is_not_reused.

◆ BOOST_AUTO_TEST_CASE() [61/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_store_unaligned  )

Definition at line 226 of file TestSimdLibSingle.cpp.

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

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [62/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_sub_binary  )

Definition at line 499 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [63/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_sub_unary  )

Definition at line 431 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [64/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibFloat_type_traits  )

Definition at line 120 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [65/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt32_load  )

Definition at line 229 of file TestSimdLibDouble.cpp.

230{
231 alignas(vec_t::alignment) std::array<std::uint32_t, vec_t::width>
232 ascalararr{{}}; // double brace to deal with gcc 4.8.5 ...
233 simd<std::uint32_t, vec_t::width> aindex;
234 aindex.load(ascalararr.data());
235}

◆ BOOST_AUTO_TEST_CASE() [66/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt32_load_aligned  )

Definition at line 237 of file TestSimdLibDouble.cpp.

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

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [67/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt32_load_unaligned  )

Definition at line 245 of file TestSimdLibDouble.cpp.

246{
247 std::array<std::uint32_t, vec_t::width> ascalararr{
248 {}}; // double brace to deal with gcc 4.8.5 ...
249 simd<std::uint32_t, vec_t::width> aindex;
250 aindex.load(ascalararr.data(), is_not_aligned);
251}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [68/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt64_load  )

Definition at line 205 of file TestSimdLibDouble.cpp.

206{
207 alignas(vec_t::alignment) std::array<std::uint64_t, vec_t::width>
208 ascalararr{{}}; // double brace to deal with gcc 4.8.5 ...
209 simd<std::uint64_t, vec_t::width> aindex;
210 aindex.load(ascalararr.data());
211}

◆ BOOST_AUTO_TEST_CASE() [69/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt64_load_aligned  )

Definition at line 213 of file TestSimdLibDouble.cpp.

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

References tinysimd::is_aligned.

◆ BOOST_AUTO_TEST_CASE() [70/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibInt64_load_unaligned  )

Definition at line 221 of file TestSimdLibDouble.cpp.

222{
223 std::array<std::uint64_t, vec_t::width> ascalararr{
224 {}}; // double brace to deal with gcc 4.8.5 ...
225 simd<std::uint64_t, vec_t::width> aindex;
226 aindex.load(ascalararr.data(), is_not_aligned);
227}

References tinysimd::is_not_aligned.

◆ BOOST_AUTO_TEST_CASE() [71/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibSingle_broadcast  )

Definition at line 254 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [72/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibSingle_subscript_assign_read  )

Definition at line 263 of file TestSimdLibSingle.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [73/73]

Nektar::SimdLibTests::BOOST_AUTO_TEST_CASE ( SimdLibSingle_width_alignment  )

Definition at line 86 of file TestSimdLibSingle.cpp.

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

References ALIGNMENT, and NUM_LANES_32BITS.