8 #ifndef Intrepid2_Data_h 9 #define Intrepid2_Data_h 12 #include "Intrepid2_ScalarView.hpp" 48 int blockPlusDiagonalLastNonDiagonal = -1;
52 KOKKOS_INLINE_FUNCTION
55 const int myNominalExtent = myData.logicalExtent;
56 #ifdef HAVE_INTREPID2_DEBUG 62 const int & myVariationModulus = myData.variationModulus;
63 const int & otherVariationModulus = otherData.variationModulus;
65 int myDataExtent = myData.dataExtent;
66 int otherDataExtent = otherData.dataExtent;
74 switch (otherVariation)
84 switch (otherVariation)
90 if (myVariationModulus == otherVariationModulus)
120 switch (otherVariation)
139 combinedDimensionInfo.blockPlusDiagonalLastNonDiagonal = min(myData.blockPlusDiagonalLastNonDiagonal, otherData.blockPlusDiagonalLastNonDiagonal);
143 switch (otherVariation)
163 template<
class DataScalar,
typename DeviceType>
166 static ScalarView<DataScalar,DeviceType> zeroView()
168 static ScalarView<DataScalar,DeviceType> zeroView = ScalarView<DataScalar,DeviceType>(
"zero",1);
169 static bool havePushedFinalizeHook =
false;
170 if (!havePushedFinalizeHook)
172 Kokkos::push_finalize_hook( [=] {
173 zeroView = ScalarView<DataScalar,DeviceType>();
175 havePushedFinalizeHook =
true;
198 template<
class DataScalar,
typename DeviceType>
201 using value_type = DataScalar;
202 using execution_space =
typename DeviceType::execution_space;
204 ordinal_type dataRank_;
205 Kokkos::View<DataScalar*, DeviceType> data1_;
206 Kokkos::View<DataScalar**, DeviceType> data2_;
207 Kokkos::View<DataScalar***, DeviceType> data3_;
208 Kokkos::View<DataScalar****, DeviceType> data4_;
209 Kokkos::View<DataScalar*****, DeviceType> data5_;
210 Kokkos::View<DataScalar******, DeviceType> data6_;
211 Kokkos::View<DataScalar*******, DeviceType> data7_;
212 Kokkos::Array<int,7> extents_;
213 Kokkos::Array<DataVariationType,7> variationType_;
214 Kokkos::Array<int,7> variationModulus_;
215 int blockPlusDiagonalLastNonDiagonal_ = -1;
217 bool hasNontrivialModulusUNUSED_;
218 bool underlyingMatchesLogical_;
219 Kokkos::Array<ordinal_type,7> activeDims_;
224 using reference_type =
typename ScalarView<DataScalar,DeviceType>::reference_type;
225 using const_reference_type =
typename ScalarView<const DataScalar,DeviceType>::reference_type;
227 using return_type = const_reference_type;
229 ScalarView<DataScalar,DeviceType> zeroView_;
232 KOKKOS_INLINE_FUNCTION
235 return (lastNondiagonal + 1) * (lastNondiagonal + 1);
239 KOKKOS_INLINE_FUNCTION
242 return i * (lastNondiagonal + 1) + j;
246 KOKKOS_INLINE_FUNCTION
249 return i - (lastNondiagonal + 1) + numNondiagonalEntries;
253 KOKKOS_INLINE_FUNCTION
258 case 1:
return data1_.extent_int(dim);
259 case 2:
return data2_.extent_int(dim);
260 case 3:
return data3_.extent_int(dim);
261 case 4:
return data4_.extent_int(dim);
262 case 5:
return data5_.extent_int(dim);
263 case 6:
return data6_.extent_int(dim);
264 case 7:
return data7_.extent_int(dim);
274 for (
int d=rank_; d<7; d++)
276 INTREPID2_TEST_FOR_EXCEPTION(extents_[d] > 1, std::invalid_argument,
"Nominal extents may not be > 1 in dimensions beyond the rank of the container");
280 int blockPlusDiagonalCount = 0;
281 underlyingMatchesLogical_ =
true;
282 for (ordinal_type i=0; i<7; i++)
284 if (variationType_[i] ==
GENERAL)
286 if (extents_[i] != 0)
288 variationModulus_[i] = extents_[i];
292 variationModulus_[i] = 1;
294 activeDims_[numActiveDims_] = i;
297 else if (variationType_[i] ==
MODULAR)
299 underlyingMatchesLogical_ =
false;
303 const int logicalExtent = extents_[i];
304 const int modulus = dataExtent;
306 INTREPID2_TEST_FOR_EXCEPTION( dataExtent * (logicalExtent / dataExtent) != logicalExtent, std::invalid_argument,
"data extent must evenly divide logical extent");
308 variationModulus_[i] = modulus;
312 variationModulus_[i] = extents_[i];
314 activeDims_[numActiveDims_] = i;
319 underlyingMatchesLogical_ =
false;
320 blockPlusDiagonalCount++;
321 if (blockPlusDiagonalCount == 1)
324 #ifdef HAVE_INTREPID2_DEBUG 327 const int logicalExtent = extents_[i];
328 const int numDiagonalEntries = logicalExtent - (blockPlusDiagonalLastNonDiagonal_ + 1);
329 const int expectedDataExtent = numNondiagonalEntries + numDiagonalEntries;
330 INTREPID2_TEST_FOR_EXCEPTION(dataExtent != expectedDataExtent, std::invalid_argument, (
"BLOCK_PLUS_DIAGONAL data extent of " + std::to_string(dataExtent) +
" does not match expected based on blockPlusDiagonalLastNonDiagonal setting of " + std::to_string(blockPlusDiagonalLastNonDiagonal_)).c_str());
333 activeDims_[numActiveDims_] = i;
337 INTREPID2_TEST_FOR_EXCEPTION(variationType_[i+1] !=
BLOCK_PLUS_DIAGONAL, std::invalid_argument,
"BLOCK_PLUS_DIAGONAL ranks must be contiguous");
339 variationModulus_[i] = 1;
340 INTREPID2_TEST_FOR_EXCEPTION(blockPlusDiagonalCount > 1, std::invalid_argument,
"BLOCK_PLUS_DIAGONAL can only apply to two ranks");
346 underlyingMatchesLogical_ =
false;
348 variationModulus_[i] = 1;
352 if (rank_ != dataRank_)
354 underlyingMatchesLogical_ =
false;
357 for (
int d=numActiveDims_; d<7; d++)
363 for (
int d=0; d<7; d++)
365 INTREPID2_TEST_FOR_EXCEPTION(variationModulus_[d] == 0, std::logic_error,
"variationModulus should not ever be 0");
371 template<
bool passThroughBlockDiagonalArgs>
374 template<
class ViewType,
class ...IntArgs>
375 static KOKKOS_INLINE_FUNCTION reference_type
get(
const ViewType &view,
const IntArgs&... intArgs)
377 return view.getWritableEntryWithPassThroughOption(passThroughBlockDiagonalArgs, intArgs...);
382 template<
bool passThroughBlockDiagonalArgs>
385 template<
class ViewType,
class ...IntArgs>
386 static KOKKOS_INLINE_FUNCTION const_reference_type
get(
const ViewType &view,
const IntArgs&... intArgs)
388 return view.getEntryWithPassThroughOption(passThroughBlockDiagonalArgs, intArgs...);
392 template<
class BinaryOperator,
class ThisUnderlyingViewType,
class AUnderlyingViewType,
class BUnderlyingViewType,
393 class ArgExtractorThis,
class ArgExtractorA,
class ArgExtractorB,
bool includeInnerLoop=
false>
397 ThisUnderlyingViewType this_underlying_;
398 AUnderlyingViewType A_underlying_;
399 BUnderlyingViewType B_underlying_;
400 BinaryOperator binaryOperator_;
403 InPlaceCombinationFunctor(ThisUnderlyingViewType this_underlying, AUnderlyingViewType A_underlying, BUnderlyingViewType B_underlying,
404 BinaryOperator binaryOperator)
406 this_underlying_(this_underlying),
407 A_underlying_(A_underlying),
408 B_underlying_(B_underlying),
409 binaryOperator_(binaryOperator)
411 INTREPID2_TEST_FOR_EXCEPTION(includeInnerLoop,std::invalid_argument,
"If includeInnerLoop is true, must specify the size of the inner loop");
414 InPlaceCombinationFunctor(ThisUnderlyingViewType this_underlying, AUnderlyingViewType A_underlying, BUnderlyingViewType B_underlying,
415 BinaryOperator binaryOperator,
int innerLoopSize)
417 this_underlying_(this_underlying),
418 A_underlying_(A_underlying),
419 B_underlying_(B_underlying),
420 binaryOperator_(binaryOperator),
421 innerLoopSize_(innerLoopSize)
423 INTREPID2_TEST_FOR_EXCEPTION(includeInnerLoop,std::invalid_argument,
"If includeInnerLoop is true, must specify the size of the inner loop");
426 template<
class ...IntArgs,
bool M=includeInnerLoop>
427 KOKKOS_INLINE_FUNCTION
428 enable_if_t<!M, void>
429 operator()(
const IntArgs&... args)
const 431 auto & result = ArgExtractorThis::get( this_underlying_, args... );
432 const auto & A_val = ArgExtractorA::get( A_underlying_, args... );
433 const auto & B_val = ArgExtractorB::get( B_underlying_, args... );
435 result = binaryOperator_(A_val,B_val);
438 template<
class ...IntArgs,
bool M=includeInnerLoop>
439 KOKKOS_INLINE_FUNCTION
441 operator()(
const IntArgs&... args)
const 443 using int_type = std::tuple_element_t<0, std::tuple<IntArgs...>>;
444 for (int_type iFinal=0; iFinal<static_cast<int_type>(innerLoopSize_); iFinal++)
446 auto & result = ArgExtractorThis::get( this_underlying_, args..., iFinal );
447 const auto & A_val = ArgExtractorA::get( A_underlying_, args..., iFinal );
448 const auto & B_val = ArgExtractorB::get( B_underlying_, args..., iFinal );
450 result = binaryOperator_(A_val,B_val);
456 template<
class BinaryOperator,
class PolicyType,
class ThisUnderlyingViewType,
class AUnderlyingViewType,
class BUnderlyingViewType,
457 class ArgExtractorThis,
class ArgExtractorA,
class ArgExtractorB>
459 AUnderlyingViewType &A_underlying, BUnderlyingViewType &B_underlying,
460 BinaryOperator &binaryOperator, ArgExtractorThis argThis, ArgExtractorA argA, ArgExtractorB argB)
462 using Functor = InPlaceCombinationFunctor<BinaryOperator, ThisUnderlyingViewType, AUnderlyingViewType, BUnderlyingViewType, ArgExtractorThis, ArgExtractorA, ArgExtractorB>;
463 Functor functor(this_underlying, A_underlying, B_underlying, binaryOperator);
464 Kokkos::parallel_for(
"compute in-place", policy, functor);
468 template<
class BinaryOperator,
int rank>
469 enable_if_t<rank != 7, void>
472 auto policy = dataExtentRangePolicy<rank>();
490 const FullArgExtractorData<true> fullArgsData;
491 const FullArgExtractorWritableData<true> fullArgsWritable;
504 const auto & variationTypes = data.getVariationTypes();
505 for (
int d=0; d<
rank; d++)
507 if (variationTypes[d] ==
GENERAL)
517 auto thisAE = constArg;
520 auto & this_underlying = this->getUnderlyingView<1>();
523 storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, AAE, BAE);
525 else if (this_full && A_full && B_full)
527 auto thisAE = fullArgs;
531 auto & this_underlying = this->getUnderlyingView<rank>();
535 storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, AAE, BAE);
543 auto thisAE = fullArgs;
544 auto & this_underlying = this->getUnderlyingView<rank>();
550 storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, AAE, BAE);
554 auto BAE = fullArgsData;
561 if (B_1D && (get1DArgIndex(B) != -1) )
564 const int argIndex = get1DArgIndex(B);
566 auto & this_underlying = this->getUnderlyingView<1>();
569 case 0:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg0, AAE, arg0);
break;
570 case 1:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg1, AAE, arg1);
break;
571 case 2:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg2, AAE, arg2);
break;
572 case 3:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg3, AAE, arg3);
break;
573 case 4:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg4, AAE, arg4);
break;
574 case 5:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg5, AAE, arg5);
break;
575 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid/unexpected arg index");
581 auto thisAE = fullArgsWritable;
582 auto BAE = fullArgsData;
593 auto thisAE = fullArgs;
594 auto & this_underlying = this->getUnderlyingView<rank>();
600 storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, AAE, BAE);
605 auto AAE = fullArgsData;
612 if (A_1D && (get1DArgIndex(A) != -1) )
615 const int argIndex = get1DArgIndex(A);
617 auto & this_underlying = this->getUnderlyingView<1>();
620 case 0:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg0, arg0, BAE);
break;
621 case 1:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg1, arg1, BAE);
break;
622 case 2:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg2, arg2, BAE);
break;
623 case 3:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg3, arg3, BAE);
break;
624 case 4:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg4, arg4, BAE);
break;
625 case 5:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg5, arg5, BAE);
break;
626 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid/unexpected arg index");
632 auto thisAE = fullArgsWritable;
633 auto AAE = fullArgsData;
640 if (this_1D && (get1DArgIndex(thisData) != -1))
647 const int argThis = get1DArgIndex(thisData);
648 const int argA = get1DArgIndex(A);
649 const int argB = get1DArgIndex(B);
653 auto & this_underlying = this->getUnderlyingView<1>();
654 if ((argA != -1) && (argB != -1))
656 #ifdef INTREPID2_HAVE_DEBUG 657 INTREPID2_TEST_FOR_EXCEPTION(argA != argThis, std::logic_error,
"Unexpected 1D arg combination.");
658 INTREPID2_TEST_FOR_EXCEPTION(argB != argThis, std::logic_error,
"Unexpected 1D arg combination.");
662 case 0:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg0, arg0, arg0);
break;
663 case 1:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg1, arg1, arg1);
break;
664 case 2:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg2, arg2, arg2);
break;
665 case 3:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg3, arg3, arg3);
break;
666 case 4:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg4, arg4, arg4);
break;
667 case 5:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, arg5, arg5, arg5);
break;
668 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid/unexpected arg index");
676 case 0:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, arg0, arg0, fullArgsData);
break;
677 case 1:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, arg1, arg1, fullArgsData);
break;
678 case 2:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, arg2, arg2, fullArgsData);
break;
679 case 3:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, arg3, arg3, fullArgsData);
break;
680 case 4:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, arg4, arg4, fullArgsData);
break;
681 case 5:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, arg5, arg5, fullArgsData);
break;
682 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid/unexpected arg index");
690 case 0:
storeInPlaceCombination(policy, this_underlying, A, B_underlying, binaryOperator, arg0, fullArgsData, arg0);
break;
691 case 1:
storeInPlaceCombination(policy, this_underlying, A, B_underlying, binaryOperator, arg1, fullArgsData, arg1);
break;
692 case 2:
storeInPlaceCombination(policy, this_underlying, A, B_underlying, binaryOperator, arg2, fullArgsData, arg2);
break;
693 case 3:
storeInPlaceCombination(policy, this_underlying, A, B_underlying, binaryOperator, arg3, fullArgsData, arg3);
break;
694 case 4:
storeInPlaceCombination(policy, this_underlying, A, B_underlying, binaryOperator, arg4, fullArgsData, arg4);
break;
695 case 5:
storeInPlaceCombination(policy, this_underlying, A, B_underlying, binaryOperator, arg5, fullArgsData, arg5);
break;
696 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid/unexpected arg index");
703 auto & this_underlying = this->getUnderlyingView<rank>();
704 auto thisAE = fullArgs;
711 if (B_1D && (get1DArgIndex(B) != -1))
713 const int argIndex = get1DArgIndex(B);
717 case 0:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, AAE, arg0);
break;
718 case 1:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, AAE, arg1);
break;
719 case 2:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, AAE, arg2);
break;
720 case 3:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, AAE, arg3);
break;
721 case 4:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, AAE, arg4);
break;
722 case 5:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, AAE, arg5);
break;
723 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid/unexpected arg index");
730 auto BAE = fullArgsData;
736 if (A_1D && (get1DArgIndex(A) != -1))
738 const int argIndex = get1DArgIndex(A);
746 case 0:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, arg0, BAE);
break;
747 case 1:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, arg1, BAE);
break;
748 case 2:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, arg2, BAE);
break;
749 case 3:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, arg3, BAE);
break;
750 case 4:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, arg4, BAE);
break;
751 case 5:
storeInPlaceCombination(policy, this_underlying, A_underlying, B_underlying, binaryOperator, thisAE, arg5, BAE);
break;
752 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid/unexpected arg index");
757 auto BAE = fullArgsData;
760 case 0:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, thisAE, arg0, BAE);
break;
761 case 1:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, thisAE, arg1, BAE);
break;
762 case 2:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, thisAE, arg2, BAE);
break;
763 case 3:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, thisAE, arg3, BAE);
break;
764 case 4:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, thisAE, arg4, BAE);
break;
765 case 5:
storeInPlaceCombination(policy, this_underlying, A_underlying, B, binaryOperator, thisAE, arg5, BAE);
break;
766 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid/unexpected arg index");
773 auto AAE = fullArgsData;
774 auto BAE = fullArgsData;
782 auto thisAE = fullArgsWritable;
783 auto AAE = fullArgsData;
784 auto BAE = fullArgsData;
791 template<
class BinaryOperator,
int rank>
792 enable_if_t<rank == 7, void>
795 auto policy = dataExtentRangePolicy<rank>();
798 using ThisAE = FullArgExtractorWritableData<true>;
803 const bool includeInnerLoop =
true;
804 using Functor = InPlaceCombinationFunctor<BinaryOperator, DataType, DataType, DataType, ThisAE, AAE, BAE, includeInnerLoop>;
805 Functor functor(*
this, A, B, binaryOperator, dim6);
806 Kokkos::parallel_for(
"compute in-place", policy, functor);
810 template<
class UnaryOperator>
813 using ExecutionSpace =
typename DeviceType::execution_space;
819 const int dataRank = 1;
820 auto view = getUnderlyingView<dataRank>();
823 Kokkos::RangePolicy<ExecutionSpace> policy(ExecutionSpace(),0,dataExtent);
824 Kokkos::parallel_for(
"apply operator in-place", policy,
825 KOKKOS_LAMBDA (
const int &i0) {
826 view(i0) = unaryOperator(view(i0));
833 const int dataRank = 2;
834 auto policy = dataExtentRangePolicy<dataRank>();
835 auto view = getUnderlyingView<dataRank>();
837 Kokkos::parallel_for(
"apply operator in-place", policy,
838 KOKKOS_LAMBDA (
const int &i0,
const int &i1) {
839 view(i0,i1) = unaryOperator(view(i0,i1));
845 const int dataRank = 3;
846 auto policy = dataExtentRangePolicy<dataRank>();
847 auto view = getUnderlyingView<dataRank>();
849 Kokkos::parallel_for(
"apply operator in-place", policy,
850 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2) {
851 view(i0,i1,i2) = unaryOperator(view(i0,i1,i2));
857 const int dataRank = 4;
858 auto policy = dataExtentRangePolicy<dataRank>();
859 auto view = getUnderlyingView<dataRank>();
861 Kokkos::parallel_for(
"apply operator in-place", policy,
862 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2,
const int &i3) {
863 view(i0,i1,i2,i3) = unaryOperator(view(i0,i1,i2,i3));
869 const int dataRank = 5;
870 auto policy = dataExtentRangePolicy<dataRank>();
871 auto view = getUnderlyingView<dataRank>();
873 Kokkos::parallel_for(
"apply operator in-place", policy,
874 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2,
const int &i3,
const int &i4) {
875 view(i0,i1,i2,i3,i4) = unaryOperator(view(i0,i1,i2,i3,i4));
881 const int dataRank = 6;
882 auto policy = dataExtentRangePolicy<dataRank>();
883 auto view = getUnderlyingView<dataRank>();
885 Kokkos::parallel_for(
"apply operator in-place", policy,
886 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2,
const int &i3,
const int &i4,
const int &i5) {
887 view(i0,i1,i2,i3,i4,i5) = unaryOperator(view(i0,i1,i2,i3,i4,i5));
893 const int dataRank = 7;
894 auto policy6 = dataExtentRangePolicy<6>();
895 auto view = getUnderlyingView<dataRank>();
897 const int dim_i6 = view.extent_int(6);
899 Kokkos::parallel_for(
"apply operator in-place", policy6,
900 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2,
const int &i3,
const int &i4,
const int &i5) {
901 for (
int i6=0; i6<dim_i6; i6++)
903 view(i0,i1,i2,i3,i4,i5,i6) = unaryOperator(view(i0,i1,i2,i3,i4,i5,i6));
909 INTREPID2_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
"Unsupported data rank");
914 template<
class ...IntArgs>
915 KOKKOS_INLINE_FUNCTION
918 #ifdef INTREPID2_HAVE_DEBUG 921 constexpr
int numArgs =
sizeof...(intArgs);
922 if (underlyingMatchesLogical_)
925 return getUnderlyingView<numArgs>()(intArgs...);
929 using int_type = std::tuple_element_t<0, std::tuple<IntArgs...>>;
931 const Kokkos::Array<int_type, numArgs+1> args {intArgs...,0};
932 Kokkos::Array<int_type, 7> refEntry;
933 for (
int d=0; d<numArgs; d++)
935 switch (variationType_[d])
937 case CONSTANT: refEntry[d] = 0;
break;
938 case GENERAL: refEntry[d] = args[d];
break;
939 case MODULAR: refEntry[d] = args[d] % variationModulus_[d];
break;
942 if (passThroughBlockDiagonalArgs)
944 refEntry[d] = args[d];
945 refEntry[d+1] = args[d+1];
952 const int_type &i = args[d];
959 const int_type &j = args[d+1];
961 if ((i > static_cast<int_type>(blockPlusDiagonalLastNonDiagonal_)) || (j > static_cast<int_type>(blockPlusDiagonalLastNonDiagonal_)))
987 for (
int d=numArgs; d<7; d++)
994 return data1_(refEntry[activeDims_[0]]);
996 else if (dataRank_ == 2)
998 return data2_(refEntry[activeDims_[0]],refEntry[activeDims_[1]]);
1000 else if (dataRank_ == 3)
1002 return data3_(refEntry[activeDims_[0]],refEntry[activeDims_[1]],refEntry[activeDims_[2]]);
1004 else if (dataRank_ == 4)
1006 return data4_(refEntry[activeDims_[0]],refEntry[activeDims_[1]],refEntry[activeDims_[2]],refEntry[activeDims_[3]]);
1008 else if (dataRank_ == 5)
1010 return data5_(refEntry[activeDims_[0]],refEntry[activeDims_[1]],refEntry[activeDims_[2]],refEntry[activeDims_[3]],
1011 refEntry[activeDims_[4]]);
1013 else if (dataRank_ == 6)
1015 return data6_(refEntry[activeDims_[0]],refEntry[activeDims_[1]],refEntry[activeDims_[2]],refEntry[activeDims_[3]],
1016 refEntry[activeDims_[4]],refEntry[activeDims_[5]]);
1020 return data7_(refEntry[activeDims_[0]],refEntry[activeDims_[1]],refEntry[activeDims_[2]],refEntry[activeDims_[3]],
1021 refEntry[activeDims_[4]],refEntry[activeDims_[5]],refEntry[activeDims_[6]]);
1027 template<
class ...IntArgs>
1028 KOKKOS_INLINE_FUNCTION
1035 template<
class ToContainer,
class FromContainer>
1039 auto policy = Kokkos::MDRangePolicy<execution_space,Kokkos::Rank<6>>({0,0,0,0,0,0},{from.extent_int(0),from.extent_int(1),from.extent_int(2), from.extent_int(3), from.extent_int(4), from.extent_int(5)});
1041 Kokkos::parallel_for(
"copyContainer", policy,
1042 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2,
const int &i3,
const int &i4,
const int &i5) {
1043 for (
int i6=0; i6<from.extent_int(6); i6++)
1045 to.access(i0,i1,i2,i3,i4,i5,i6) = from.access(i0,i1,i2,i3,i4,i5,i6);
1056 case 1: data1_ = Kokkos::View<DataScalar*, DeviceType>(
"Intrepid2 Data", data.extent_int(0));
break;
1057 case 2: data2_ = Kokkos::View<DataScalar**, DeviceType>(
"Intrepid2 Data", data.extent_int(0), data.extent_int(1));
break;
1058 case 3: data3_ = Kokkos::View<DataScalar***, DeviceType>(
"Intrepid2 Data", data.extent_int(0), data.extent_int(1), data.extent_int(2));
break;
1059 case 4: data4_ = Kokkos::View<DataScalar****, DeviceType>(
"Intrepid2 Data", data.extent_int(0), data.extent_int(1), data.extent_int(2), data.extent_int(3));
break;
1060 case 5: data5_ = Kokkos::View<DataScalar*****, DeviceType>(
"Intrepid2 Data", data.extent_int(0), data.extent_int(1), data.extent_int(2), data.extent_int(3), data.extent_int(4));
break;
1061 case 6: data6_ = Kokkos::View<DataScalar******, DeviceType>(
"Intrepid2 Data", data.extent_int(0), data.extent_int(1), data.extent_int(2), data.extent_int(3), data.extent_int(4), data.extent_int(5));
break;
1062 case 7: data7_ = Kokkos::View<DataScalar*******, DeviceType>(
"Intrepid2 Data", data.extent_int(0), data.extent_int(1), data.extent_int(2), data.extent_int(3), data.extent_int(4), data.extent_int(5), data.extent_int(6));
break;
1063 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1075 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1080 Data(std::vector<DimensionInfo> dimInfoVector)
1083 dataRank_(0), extents_({0,0,0,0,0,0,0}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(-1), rank_(dimInfoVector.size())
1087 if (dimInfoVector.size() != 0)
1089 std::vector<int> dataExtents;
1091 bool blockPlusDiagonalEncountered =
false;
1092 for (
int d=0; d<rank_; d++)
1094 const DimensionInfo & dimInfo = dimInfoVector[d];
1095 extents_[d] = dimInfo.logicalExtent;
1096 variationType_[d] = dimInfo.variationType;
1097 const bool isBlockPlusDiagonal = (variationType_[d] == BLOCK_PLUS_DIAGONAL);
1098 const bool isSecondBlockPlusDiagonal = isBlockPlusDiagonal && blockPlusDiagonalEncountered;
1099 if (isBlockPlusDiagonal)
1101 blockPlusDiagonalEncountered =
true;
1102 blockPlusDiagonalLastNonDiagonal_ = dimInfo.blockPlusDiagonalLastNonDiagonal;
1104 if ((variationType_[d] != CONSTANT) && (!isSecondBlockPlusDiagonal))
1106 dataExtents.push_back(dimInfo.dataExtent);
1109 if (dataExtents.size() == 0)
1112 dataExtents.push_back(1);
1114 dataRank_ = dataExtents.size();
1117 case 1: data1_ = Kokkos::View<DataScalar*, DeviceType>(
"Intrepid2 Data", dataExtents[0]);
break;
1118 case 2: data2_ = Kokkos::View<DataScalar**, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1]);
break;
1119 case 3: data3_ = Kokkos::View<DataScalar***, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1], dataExtents[2]);
break;
1120 case 4: data4_ = Kokkos::View<DataScalar****, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1], dataExtents[2], dataExtents[3]);
break;
1121 case 5: data5_ = Kokkos::View<DataScalar*****, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1], dataExtents[2], dataExtents[3], dataExtents[4]);
break;
1122 case 6: data6_ = Kokkos::View<DataScalar******, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1], dataExtents[2], dataExtents[3], dataExtents[4], dataExtents[5]);
break;
1123 case 7: data7_ = Kokkos::View<DataScalar*******, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1], dataExtents[2], dataExtents[3], dataExtents[4], dataExtents[5], dataExtents[6]);
break;
1124 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1140 template<typename OtherDeviceType, class = typename std::enable_if< std::is_same<typename DeviceType::memory_space, typename OtherDeviceType::memory_space>::value>::type,
1141 class = typename std::enable_if<!std::is_same<DeviceType,OtherDeviceType>::value>::type>
1142 Data(const Data<DataScalar,OtherDeviceType> &data)
1144 dataRank_(data.getUnderlyingViewRank()), extents_(data.getExtents()), variationType_(data.getVariationTypes()), blockPlusDiagonalLastNonDiagonal_(data.blockPlusDiagonalLastNonDiagonal()), rank_(data.rank())
1152 case 1: data1_ = data.getUnderlyingView1();
break;
1153 case 2: data2_ = data.getUnderlyingView2();
break;
1154 case 3: data3_ = data.getUnderlyingView3();
break;
1155 case 4: data4_ = data.getUnderlyingView4();
break;
1156 case 5: data5_ = data.getUnderlyingView5();
break;
1157 case 6: data6_ = data.getUnderlyingView6();
break;
1158 case 7: data7_ = data.getUnderlyingView7();
break;
1159 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1166 template<typename OtherDeviceType, class = typename std::enable_if<!std::is_same<typename DeviceType::memory_space, typename OtherDeviceType::memory_space>::value>::type>
1177 case 1: data1_ = Kokkos::View<DataScalar*, DeviceType>(
"Intrepid2 Data", view.extent_int(0));
break;
1178 case 2: data2_ = Kokkos::View<DataScalar**, DeviceType>(
"Intrepid2 Data", view.extent_int(0), view.extent_int(1));
break;
1179 case 3: data3_ = Kokkos::View<DataScalar***, DeviceType>(
"Intrepid2 Data", view.extent_int(0), view.extent_int(1), view.extent_int(2));
break;
1180 case 4: data4_ = Kokkos::View<DataScalar****, DeviceType>(
"Intrepid2 Data", view.extent_int(0), view.extent_int(1), view.extent_int(2), view.extent_int(3));
break;
1181 case 5: data5_ = Kokkos::View<DataScalar*****, DeviceType>(
"Intrepid2 Data", view.extent_int(0), view.extent_int(1), view.extent_int(2), view.extent_int(3), view.extent_int(4));
break;
1182 case 6: data6_ = Kokkos::View<DataScalar******, DeviceType>(
"Intrepid2 Data", view.extent_int(0), view.extent_int(1), view.extent_int(2), view.extent_int(3), view.extent_int(4), view.extent_int(5));
break;
1183 case 7: data7_ = Kokkos::View<DataScalar*******, DeviceType>(
"Intrepid2 Data", view.extent_int(0), view.extent_int(1), view.extent_int(2), view.extent_int(3), view.extent_int(4), view.extent_int(5), view.extent_int(6));
break;
1184 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1190 using MemorySpace =
typename DeviceType::memory_space;
1193 case 1: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView1());
copyContainer(data1_, dataViewMirror);}
break;
1194 case 2: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView2());
copyContainer(data2_, dataViewMirror);}
break;
1195 case 3: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView3());
copyContainer(data3_, dataViewMirror);}
break;
1196 case 4: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView4());
copyContainer(data4_, dataViewMirror);}
break;
1197 case 5: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView5());
copyContainer(data5_, dataViewMirror);}
break;
1198 case 6: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView6());
copyContainer(data6_, dataViewMirror);}
break;
1199 case 7: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView7());
copyContainer(data7_, dataViewMirror);}
break;
1200 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1248 Data(ScalarView<DataScalar,DeviceType> data)
1252 Kokkos::Array<int,7> {data.extent_int(0),data.extent_int(1),data.extent_int(2),data.extent_int(3),data.extent_int(4),data.extent_int(5),data.extent_int(6)},
1257 template<
size_t rank,
class ...DynRankViewProperties>
1258 Data(
const Kokkos::DynRankView<DataScalar,DeviceType, DynRankViewProperties...> &data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
1260 dataRank_(data.
rank()), extents_({1,1,1,1,1,1,1}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
1264 for (
unsigned d=0; d<
rank; d++)
1266 extents_[d] = extents[d];
1267 variationType_[d] = variationType[d];
1272 template<
size_t rank,
class ...ViewProperties>
1273 Data(Kokkos::View<DataScalar*,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
1275 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
1278 for (
unsigned d=0; d<
rank; d++)
1280 extents_[d] = extents[d];
1281 variationType_[d] = variationType[d];
1286 template<
size_t rank,
class ...ViewProperties>
1287 Data(Kokkos::View<DataScalar**,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
1289 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
1292 for (
unsigned d=0; d<
rank; d++)
1294 extents_[d] = extents[d];
1295 variationType_[d] = variationType[d];
1300 template<
size_t rank,
class ...ViewProperties>
1301 Data(Kokkos::View<DataScalar***,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
1303 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
1306 for (
unsigned d=0; d<
rank; d++)
1308 extents_[d] = extents[d];
1309 variationType_[d] = variationType[d];
1314 template<
size_t rank,
class ...ViewProperties>
1315 Data(Kokkos::View<DataScalar****,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
1317 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
1320 for (
unsigned d=0; d<
rank; d++)
1322 extents_[d] = extents[d];
1323 variationType_[d] = variationType[d];
1328 template<
size_t rank,
class ...ViewProperties>
1329 Data(Kokkos::View<DataScalar*****,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
1331 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
1334 for (
unsigned d=0; d<
rank; d++)
1336 extents_[d] = extents[d];
1337 variationType_[d] = variationType[d];
1342 template<
size_t rank,
class ...ViewProperties>
1343 Data(Kokkos::View<DataScalar******,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
1345 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
1348 for (
unsigned d=0; d<
rank; d++)
1350 extents_[d] = extents[d];
1351 variationType_[d] = variationType[d];
1356 template<
size_t rank,
class ...ViewProperties>
1357 Data(Kokkos::View<DataScalar*******,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
1359 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
1362 for (
unsigned d=0; d<
rank; d++)
1364 extents_[d] = extents[d];
1365 variationType_[d] = variationType[d];
1371 template<
size_t rank>
1372 Data(DataScalar constantValue, Kokkos::Array<int,rank> extents)
1374 dataRank_(1), extents_({1,1,1,1,1,1,1}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(-1), rank_(
rank)
1376 data1_ = Kokkos::View<DataScalar*,DeviceType>(
"Constant Data",1);
1377 Kokkos::deep_copy(data1_, constantValue);
1378 for (
unsigned d=0; d<
rank; d++)
1380 extents_[d] = extents[d];
1388 dataRank_(0), extents_({0,0,0,0,0,0,0}), variationType_({
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT,
CONSTANT}), blockPlusDiagonalLastNonDiagonal_(-1), rank_(0)
1394 KOKKOS_INLINE_FUNCTION
1397 return blockPlusDiagonalLastNonDiagonal_;
1401 KOKKOS_INLINE_FUNCTION
1408 KOKKOS_INLINE_FUNCTION
1414 dimInfo.variationType = variationType_[dim];
1416 dimInfo.variationModulus = variationModulus_[dim];
1420 dimInfo.blockPlusDiagonalLastNonDiagonal = blockPlusDiagonalLastNonDiagonal_;
1426 KOKKOS_INLINE_FUNCTION
1437 KOKKOS_INLINE_FUNCTION
1438 enable_if_t<rank==1, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
1441 #ifdef HAVE_INTREPID2_DEBUG 1449 KOKKOS_INLINE_FUNCTION
1450 enable_if_t<rank==2, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
1453 #ifdef HAVE_INTREPID2_DEBUG 1461 KOKKOS_INLINE_FUNCTION
1462 enable_if_t<rank==3, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
1465 #ifdef HAVE_INTREPID2_DEBUG 1473 KOKKOS_INLINE_FUNCTION
1474 enable_if_t<rank==4, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
1477 #ifdef HAVE_INTREPID2_DEBUG 1485 KOKKOS_INLINE_FUNCTION
1486 enable_if_t<rank==5, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
1489 #ifdef HAVE_INTREPID2_DEBUG 1497 KOKKOS_INLINE_FUNCTION
1498 enable_if_t<rank==6, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
1501 #ifdef HAVE_INTREPID2_DEBUG 1509 KOKKOS_INLINE_FUNCTION
1510 enable_if_t<rank==7, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
1513 #ifdef HAVE_INTREPID2_DEBUG 1520 KOKKOS_INLINE_FUNCTION
1523 return getUnderlyingView<1>();
1527 KOKKOS_INLINE_FUNCTION
1530 return getUnderlyingView<2>();
1534 KOKKOS_INLINE_FUNCTION
1537 return getUnderlyingView<3>();
1541 KOKKOS_INLINE_FUNCTION
1544 return getUnderlyingView<4>();
1548 KOKKOS_INLINE_FUNCTION
1551 return getUnderlyingView<5>();
1555 KOKKOS_INLINE_FUNCTION
1558 return getUnderlyingView<6>();
1562 KOKKOS_INLINE_FUNCTION
1565 return getUnderlyingView<7>();
1569 KOKKOS_INLINE_FUNCTION
1576 KOKKOS_INLINE_FUNCTION
1583 KOKKOS_INLINE_FUNCTION
1590 KOKKOS_INLINE_FUNCTION
1597 KOKKOS_INLINE_FUNCTION
1604 KOKKOS_INLINE_FUNCTION
1611 KOKKOS_INLINE_FUNCTION
1622 case 1:
return data1_;
1623 case 2:
return data2_;
1624 case 3:
return data3_;
1625 case 4:
return data4_;
1626 case 5:
return data5_;
1627 case 6:
return data6_;
1628 case 7:
return data7_;
1629 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1634 KOKKOS_INLINE_FUNCTION
1641 KOKKOS_INLINE_FUNCTION
1644 ordinal_type size = 1;
1645 for (ordinal_type r=0; r<dataRank_; r++)
1659 case 3:
return getMatchingViewWithLabel(data3_,
"Intrepid2 Data", data3_.extent_int(0), data3_.extent_int(1), data3_.extent_int(2));
1660 case 4:
return getMatchingViewWithLabel(data4_,
"Intrepid2 Data", data4_.extent_int(0), data4_.extent_int(1), data4_.extent_int(2), data4_.extent_int(3));
1661 case 5:
return getMatchingViewWithLabel(data5_,
"Intrepid2 Data", data5_.extent_int(0), data5_.extent_int(1), data5_.extent_int(2), data5_.extent_int(3), data5_.extent_int(4));
1662 case 6:
return getMatchingViewWithLabel(data6_,
"Intrepid2 Data", data6_.extent_int(0), data6_.extent_int(1), data6_.extent_int(2), data6_.extent_int(3), data6_.extent_int(4), data6_.extent_int(5));
1663 case 7:
return getMatchingViewWithLabel(data7_,
"Intrepid2 Data", data7_.extent_int(0), data7_.extent_int(1), data7_.extent_int(2), data7_.extent_int(3), data7_.extent_int(4), data7_.extent_int(5), data7_.extent_int(6));
1664 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1669 template<
class ... DimArgs>
1681 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1688 #ifdef KOKKOS_COMPILER_INTEL 1690 DataScalar zero = DataScalar(0);
1693 case 1: {Kokkos::parallel_for(Kokkos::RangePolicy<execution_space>(0, data1_.extent_int(0)), KOKKOS_LAMBDA(
int i) {data1_(i) = zero;});
break; }
1694 case 2: {Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<2>, execution_space>({0,0},{data2_.extent_int(0),data2_.extent_int(1)}), KOKKOS_LAMBDA(
int i0,
int i1) {data2_(i0, i1) = zero;});
break; }
1695 case 3: {Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<3>, execution_space>({0,0,0},{data3_.extent_int(0),data3_.extent_int(1),data3_.extent_int(2)}), KOKKOS_LAMBDA(
int i0,
int i1,
int i2) {data3_(i0, i1, i2) = zero;});
break; }
1696 case 4: {Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<4>, execution_space>({0,0,0,0},{data4_.extent_int(0),data4_.extent_int(1),data4_.extent_int(2),data4_.extent_int(3)}), KOKKOS_LAMBDA(
int i0,
int i1,
int i2,
int i3) {data4_(i0, i1, i2, i3) = zero;});
break; }
1697 case 5: {Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<5>, execution_space>({0,0,0,0,0},{data5_.extent_int(0),data5_.extent_int(1),data5_.extent_int(2),data5_.extent_int(3),data5_.extent_int(4)}), KOKKOS_LAMBDA(
int i0,
int i1,
int i2,
int i3,
int i4) {data5_(i0, i1, i2, i3, i4) = zero;});
break; }
1698 case 6: {Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<6>, execution_space>({0,0,0,0,0,0},{data6_.extent_int(0),data6_.extent_int(1),data6_.extent_int(2),data6_.extent_int(3),data6_.extent_int(4),data6_.extent_int(5)}), KOKKOS_LAMBDA(
int i0,
int i1,
int i2,
int i3,
int i4,
int i5) {data6_(i0, i1, i2, i3, i4, i5) = zero;});
break; }
1699 case 7: {Kokkos::parallel_for(Kokkos::MDRangePolicy<Kokkos::Rank<6>, execution_space>({0,0,0,0,0,0},{data7_.extent_int(0),data7_.extent_int(1),data7_.extent_int(2),data7_.extent_int(3),data7_.extent_int(4),data7_.extent_int(5)}), KOKKOS_LAMBDA(
int i0,
int i1,
int i2,
int i3,
int i4,
int i5 ) {
for (
int i6 = 0; i6 < data7_.extent_int(6); ++i6) data7_(i0, i1, i2, i3, i4, i5, i6) = zero;});
break; }
1700 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1705 case 1: Kokkos::deep_copy(data1_, 0.0);
break;
1706 case 2: Kokkos::deep_copy(data2_, 0.0);
break;
1707 case 3: Kokkos::deep_copy(data3_, 0.0);
break;
1708 case 4: Kokkos::deep_copy(data4_, 0.0);
break;
1709 case 5: Kokkos::deep_copy(data5_, 0.0);
break;
1710 case 6: Kokkos::deep_copy(data6_, 0.0);
break;
1711 case 7: Kokkos::deep_copy(data7_, 0.0);
break;
1712 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1730 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1737 for (
int i=0; i<numActiveDims_; i++)
1739 if (activeDims_[i] == d)
1743 else if (activeDims_[i] > d)
1762 KOKKOS_INLINE_FUNCTION
1765 return variationModulus_[d];
1769 KOKKOS_INLINE_FUNCTION
1772 return variationType_;
1776 template<
class ...IntArgs>
1777 KOKKOS_INLINE_FUNCTION
1784 template<
class ...IntArgs>
1785 KOKKOS_INLINE_FUNCTION
1793 template <
bool... v>
1796 template <
class ...IntArgs>
1797 using valid_args = all_true<std::is_integral<IntArgs>{}...>;
1799 static_assert(valid_args<int,long,unsigned>::value,
"valid args works");
1802 template <
class ...IntArgs>
1803 KOKKOS_INLINE_FUNCTION
1804 #ifndef __INTEL_COMPILER 1808 enable_if_t<valid_args<IntArgs...>::value && (
sizeof...(IntArgs) <= 7),return_type>
1817 KOKKOS_INLINE_FUNCTION
1823 template <
typename iType>
1824 KOKKOS_INLINE_FUNCTION constexpr
1825 typename std::enable_if<std::is_integral<iType>::value,
size_t>::type
1826 extent(
const iType& r)
const {
1833 if (blockPlusDiagonalLastNonDiagonal_ >= 1)
return false;
1834 int numBlockPlusDiagonalTypes = 0;
1835 for (
unsigned r = 0; r<variationType_.size(); r++)
1837 const auto &entryType = variationType_[r];
1841 if (numBlockPlusDiagonalTypes == 2)
return true;
1842 else if (numBlockPlusDiagonalTypes == 0)
return false;
1864 std::vector<DimensionInfo> dimInfo(
rank);
1865 for (
int d=0; d<
rank; d++)
1885 const int D1_DIM = A_MatData.
rank() - 2;
1886 const int D2_DIM = A_MatData.
rank() - 1;
1888 const int A_rows = A_MatData.
extent_int(D1_DIM);
1889 const int A_cols = A_MatData.
extent_int(D2_DIM);
1890 const int B_rows = B_MatData.
extent_int(D1_DIM);
1891 const int B_cols = B_MatData.
extent_int(D2_DIM);
1893 const int leftRows = transposeA ? A_cols : A_rows;
1894 const int leftCols = transposeA ? A_rows : A_cols;
1895 const int rightRows = transposeB ? B_cols : B_rows;
1896 const int rightCols = transposeB ? B_rows : B_cols;
1898 INTREPID2_TEST_FOR_EXCEPTION(leftCols != rightRows, std::invalid_argument,
"incompatible matrix dimensions");
1900 Kokkos::Array<int,7> resultExtents;
1901 Kokkos::Array<DataVariationType,7> resultVariationTypes;
1903 resultExtents[D1_DIM] = leftRows;
1904 resultExtents[D2_DIM] = rightCols;
1905 int resultBlockPlusDiagonalLastNonDiagonal = -1;
1914 const int resultRank = A_MatData.
rank();
1919 Kokkos::Array<int,7> resultActiveDims;
1920 Kokkos::Array<int,7> resultDataDims;
1921 int resultNumActiveDims = 0;
1923 for (
int i=0; i<resultRank-2; i++)
1938 if ((A_VariationType ==
GENERAL) || (B_VariationType ==
GENERAL))
1940 resultVariationType =
GENERAL;
1941 dataSize = resultExtents[i];
1948 else if ((B_VariationType ==
MODULAR) && (A_VariationType ==
CONSTANT))
1950 resultVariationType =
MODULAR;
1953 else if ((B_VariationType ==
CONSTANT) && (A_VariationType ==
MODULAR))
1955 resultVariationType =
MODULAR;
1964 resultVariationType =
MODULAR;
1965 dataSize = A_Modulus;
1967 resultVariationTypes[i] = resultVariationType;
1969 if (resultVariationType !=
CONSTANT)
1971 resultActiveDims[resultNumActiveDims] = i;
1972 resultDataDims[resultNumActiveDims] = dataSize;
1973 resultNumActiveDims++;
1978 resultExtents[D1_DIM] = leftRows;
1979 resultExtents[D2_DIM] = rightCols;
1988 resultActiveDims[resultNumActiveDims] = resultRank - 2;
1990 const int numDiagonalEntries = leftRows - (resultBlockPlusDiagonalLastNonDiagonal + 1);
1991 const int numNondiagonalEntries = (resultBlockPlusDiagonalLastNonDiagonal + 1) * (resultBlockPlusDiagonalLastNonDiagonal + 1);
1993 resultDataDims[resultNumActiveDims] = numDiagonalEntries + numNondiagonalEntries;
1994 resultNumActiveDims++;
1999 resultVariationTypes[D1_DIM] =
GENERAL;
2000 resultVariationTypes[D2_DIM] =
GENERAL;
2002 resultActiveDims[resultNumActiveDims] = resultRank - 2;
2003 resultActiveDims[resultNumActiveDims+1] = resultRank - 1;
2005 resultDataDims[resultNumActiveDims] = leftRows;
2006 resultDataDims[resultNumActiveDims+1] = rightCols;
2007 resultNumActiveDims += 2;
2010 for (
int i=resultRank; i<7; i++)
2012 resultVariationTypes[i] =
CONSTANT;
2013 resultExtents[i] = 1;
2016 ScalarView<DataScalar,DeviceType> data;
2017 if (resultNumActiveDims == 1)
2022 else if (resultNumActiveDims == 2)
2027 else if (resultNumActiveDims == 3)
2030 data =
getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1], resultDataDims[2]);
2032 else if (resultNumActiveDims == 4)
2035 data =
getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1], resultDataDims[2],
2038 else if (resultNumActiveDims == 5)
2041 data =
getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1], resultDataDims[2],
2042 resultDataDims[3], resultDataDims[4]);
2044 else if (resultNumActiveDims == 6)
2047 data =
getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1], resultDataDims[2],
2048 resultDataDims[3], resultDataDims[4], resultDataDims[5]);
2053 data =
getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1], resultDataDims[2],
2054 resultDataDims[3], resultDataDims[4], resultDataDims[5], resultDataDims[6]);
2070 const int resultRank = vecData.
rank();
2074 Kokkos::Array<int,7> resultExtents;
2075 Kokkos::Array<DataVariationType,7> resultVariationTypes;
2079 Kokkos::Array<int,7> resultActiveDims;
2080 Kokkos::Array<int,7> resultDataDims;
2081 int resultNumActiveDims = 0;
2083 for (
int i=0; i<resultRank-1; i++)
2097 if ((vecVariationType ==
GENERAL) || (matVariationType ==
GENERAL))
2099 resultVariationType =
GENERAL;
2100 dataSize = resultExtents[i];
2107 else if ((matVariationType ==
MODULAR) && (vecVariationType ==
CONSTANT))
2109 resultVariationType =
MODULAR;
2112 else if ((matVariationType ==
CONSTANT) && (vecVariationType ==
MODULAR))
2114 resultVariationType =
MODULAR;
2123 resultVariationType =
MODULAR;
2124 dataSize = matModulus;
2126 resultVariationTypes[i] = resultVariationType;
2128 if (resultVariationType !=
CONSTANT)
2130 resultActiveDims[resultNumActiveDims] = i;
2131 resultDataDims[resultNumActiveDims] = dataSize;
2132 resultNumActiveDims++;
2137 resultVariationTypes[resultNumActiveDims] =
GENERAL;
2138 resultActiveDims[resultNumActiveDims] = resultRank - 1;
2139 resultDataDims[resultNumActiveDims] = matRows;
2140 resultExtents[resultRank-1] = matRows;
2141 resultNumActiveDims++;
2143 for (
int i=resultRank; i<7; i++)
2145 resultVariationTypes[i] =
CONSTANT;
2146 resultExtents[i] = 1;
2149 ScalarView<DataScalar,DeviceType> data;
2150 if (resultNumActiveDims == 1)
2154 else if (resultNumActiveDims == 2)
2158 else if (resultNumActiveDims == 3)
2162 else if (resultNumActiveDims == 4)
2167 else if (resultNumActiveDims == 5)
2170 resultDataDims[3], resultDataDims[4]);
2172 else if (resultNumActiveDims == 6)
2175 resultDataDims[3], resultDataDims[4], resultDataDims[5]);
2180 resultDataDims[3], resultDataDims[4], resultDataDims[5], resultDataDims[6]);
2188 enable_if_t<(rank!=1) && (rank!=7), Kokkos::MDRangePolicy<typename DeviceType::execution_space,Kokkos::Rank<rank>> >
2191 using ExecutionSpace =
typename DeviceType::execution_space;
2192 Kokkos::Array<int,rank> startingOrdinals;
2193 Kokkos::Array<int,rank> extents;
2195 for (
int d=0; d<
rank; d++)
2197 startingOrdinals[d] = 0;
2200 auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<rank>>(startingOrdinals,extents);
2206 enable_if_t<rank==7, Kokkos::MDRangePolicy<typename DeviceType::execution_space,Kokkos::Rank<6>> >
2209 using ExecutionSpace =
typename DeviceType::execution_space;
2210 Kokkos::Array<int,6> startingOrdinals;
2211 Kokkos::Array<int,6> extents;
2213 for (
int d=0; d<6; d++)
2215 startingOrdinals[d] = 0;
2218 auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<6>>(startingOrdinals,extents);
2224 enable_if_t<rank==1, Kokkos::RangePolicy<typename DeviceType::execution_space> >
2227 using ExecutionSpace =
typename DeviceType::execution_space;
2228 Kokkos::RangePolicy<ExecutionSpace> policy(ExecutionSpace(),0,
getDataExtent(0));
2233 Data shallowCopy(
const int rank,
const Kokkos::Array<int,7> &extents,
const Kokkos::Array<DataVariationType,7> &variationTypes)
2237 case 1:
return Data(data1_, extents, variationTypes);
2238 case 2:
return Data(data2_, extents, variationTypes);
2239 case 3:
return Data(data3_, extents, variationTypes);
2240 case 4:
return Data(data4_, extents, variationTypes);
2241 case 5:
return Data(data5_, extents, variationTypes);
2242 case 6:
return Data(data6_, extents, variationTypes);
2243 case 7:
return Data(data7_, extents, variationTypes);
2245 INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Unhandled dataRank_");
2250 template<
class BinaryOperator>
2253 using ExecutionSpace =
typename DeviceType::execution_space;
2255 #ifdef INTREPID2_HAVE_DEBUG 2257 for (
int d=0; d<rank_; d++)
2259 INTREPID2_TEST_FOR_EXCEPTION(A.
extent_int(d) != this->
extent_int(d), std::invalid_argument,
"A, B, and this must agree on all logical extents");
2260 INTREPID2_TEST_FOR_EXCEPTION(B.
extent_int(d) != this->
extent_int(d), std::invalid_argument,
"A, B, and this must agree on all logical extents");
2271 Kokkos::RangePolicy<ExecutionSpace> policy(ExecutionSpace(),0,1);
2272 auto this_underlying = this->getUnderlyingView<1>();
2275 Kokkos::parallel_for(
"compute in-place", policy,
2276 KOKKOS_LAMBDA (
const int &i0) {
2277 auto & result = this_underlying(0);
2278 const auto & A_val = A_underlying(0);
2279 const auto & B_val = B_underlying(0);
2281 result = binaryOperator(A_val,B_val);
2288 case 1: storeInPlaceCombination<BinaryOperator, 1>(A, B, binaryOperator);
break;
2289 case 2: storeInPlaceCombination<BinaryOperator, 2>(A, B, binaryOperator);
break;
2290 case 3: storeInPlaceCombination<BinaryOperator, 3>(A, B, binaryOperator);
break;
2291 case 4: storeInPlaceCombination<BinaryOperator, 4>(A, B, binaryOperator);
break;
2292 case 5: storeInPlaceCombination<BinaryOperator, 5>(A, B, binaryOperator);
break;
2293 case 6: storeInPlaceCombination<BinaryOperator, 6>(A, B, binaryOperator);
break;
2294 case 7: storeInPlaceCombination<BinaryOperator, 7>(A, B, binaryOperator);
break;
2304 auto sum = KOKKOS_LAMBDA(
const DataScalar &a,
const DataScalar &b) -> DataScalar
2314 auto product = KOKKOS_LAMBDA(
const DataScalar &a,
const DataScalar &b) -> DataScalar
2324 auto difference = KOKKOS_LAMBDA(
const DataScalar &a,
const DataScalar &b) -> DataScalar
2334 auto quotient = KOKKOS_LAMBDA(
const DataScalar &a,
const DataScalar &b) -> DataScalar
2353 using ExecutionSpace =
typename DeviceType::execution_space;
2359 Kokkos::parallel_for(
"compute mat-vec", policy,
2360 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &pointOrdinal,
const int &i) {
2363 for (
int j=0; j<matCols; j++)
2365 val_i += matData(cellOrdinal,pointOrdinal,i,j) * vecData(cellOrdinal,pointOrdinal,j);
2369 else if (rank_ == 2)
2372 auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<2>>({0,0},{
getDataExtent(0),matRows});
2373 Kokkos::parallel_for(
"compute mat-vec", policy,
2374 KOKKOS_LAMBDA (
const int &vectorOrdinal,
const int &i) {
2377 for (
int j=0; j<matCols; j++)
2379 val_i += matData(vectorOrdinal,i,j) * vecData(vectorOrdinal,j);
2383 else if (rank_ == 1)
2386 Kokkos::RangePolicy<ExecutionSpace> policy(0,matRows);
2387 Kokkos::parallel_for(
"compute mat-vec", policy,
2388 KOKKOS_LAMBDA (
const int &i) {
2391 for (
int j=0; j<matCols; j++)
2393 val_i += matData(i,j) * vecData(j);
2418 const int D1_DIM = A_MatData.
rank() - 2;
2419 const int D2_DIM = A_MatData.
rank() - 1;
2421 const int A_rows = A_MatData.
extent_int(D1_DIM);
2422 const int A_cols = A_MatData.
extent_int(D2_DIM);
2423 const int B_rows = B_MatData.
extent_int(D1_DIM);
2424 const int B_cols = B_MatData.
extent_int(D2_DIM);
2426 const int leftRows = transposeA ? A_cols : A_rows;
2427 const int leftCols = transposeA ? A_rows : A_cols;
2428 const int rightCols = transposeB ? B_rows : B_cols;
2430 #ifdef INTREPID2_HAVE_DEBUG 2431 const int rightRows = transposeB ? B_cols : B_rows;
2438 using ExecutionSpace =
typename DeviceType::execution_space;
2440 const int diagonalStart = (variationType_[D1_DIM] ==
BLOCK_PLUS_DIAGONAL) ? blockPlusDiagonalLastNonDiagonal_ + 1 : leftRows;
2445 auto policy = Kokkos::RangePolicy<ExecutionSpace>(0,
getDataExtent(0));
2446 Kokkos::parallel_for(
"compute mat-mat", policy,
2447 KOKKOS_LAMBDA (
const int &matrixOrdinal) {
2448 for (
int i=0; i<diagonalStart; i++)
2450 for (
int j=0; j<rightCols; j++)
2454 for (
int k=0; k<leftCols; k++)
2456 const auto & left = transposeA ? A_MatData(matrixOrdinal,k,i) : A_MatData(matrixOrdinal,i,k);
2457 const auto & right = transposeB ? B_MatData(matrixOrdinal,j,k) : B_MatData(matrixOrdinal,k,j);
2458 val_ij += left * right;
2462 for (
int i=diagonalStart; i<leftRows; i++)
2465 const auto & left = A_MatData(matrixOrdinal,i,i);
2466 const auto & right = B_MatData(matrixOrdinal,i,i);
2467 val_ii = left * right;
2471 else if (rank_ == 4)
2475 if (underlyingMatchesLogical_)
2477 Kokkos::parallel_for(
"compute mat-mat", policy,
2478 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &pointOrdinal) {
2479 for (
int i=0; i<leftCols; i++)
2481 for (
int j=0; j<rightCols; j++)
2485 for (
int k=0; k<leftCols; k++)
2487 const auto & left = transposeA ? A_MatData(cellOrdinal,pointOrdinal,k,i) : A_MatData(cellOrdinal,pointOrdinal,i,k);
2488 const auto & right = transposeB ? B_MatData(cellOrdinal,pointOrdinal,j,k) : B_MatData(cellOrdinal,pointOrdinal,k,j);
2489 val_ij += left * right;
2497 Kokkos::parallel_for(
"compute mat-mat", policy,
2498 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &pointOrdinal) {
2499 for (
int i=0; i<diagonalStart; i++)
2501 for (
int j=0; j<rightCols; j++)
2505 for (
int k=0; k<leftCols; k++)
2507 const auto & left = transposeA ? A_MatData(cellOrdinal,pointOrdinal,k,i) : A_MatData(cellOrdinal,pointOrdinal,i,k);
2508 const auto & right = transposeB ? B_MatData(cellOrdinal,pointOrdinal,j,k) : B_MatData(cellOrdinal,pointOrdinal,k,j);
2509 val_ij += left * right;
2513 for (
int i=diagonalStart; i<leftRows; i++)
2516 const auto & left = A_MatData(cellOrdinal,pointOrdinal,i,i);
2517 const auto & right = B_MatData(cellOrdinal,pointOrdinal,i,i);
2518 val_ii = left * right;
2531 KOKKOS_INLINE_FUNCTION constexpr
bool isValid()
const 2533 return extents_[0] > 0;
2537 KOKKOS_INLINE_FUNCTION
2549 void setExtent(
const ordinal_type &d,
const ordinal_type &newExtent)
2551 INTREPID2_TEST_FOR_EXCEPTION(variationType_[d] ==
BLOCK_PLUS_DIAGONAL, std::invalid_argument,
"setExtent is not supported for BLOCK_PLUS_DIAGONAL dimensions");
2553 if (variationType_[d] ==
MODULAR)
2555 bool dividesEvenly = ((newExtent / variationModulus_[d]) * variationModulus_[d] == newExtent);
2556 INTREPID2_TEST_FOR_EXCEPTION(!dividesEvenly, std::invalid_argument,
"when setExtent is called on dimenisions with MODULAR variation, the modulus must divide the new extent evenly");
2559 if ((newExtent != extents_[d]) && (variationType_[d] ==
GENERAL))
2562 std::vector<ordinal_type> newExtents(dataRank_,-1);
2563 for (
int r=0; r<dataRank_; r++)
2565 if (activeDims_[r] == d)
2568 newExtents[r] = newExtent;
2579 case 1: Kokkos::resize(data1_,newExtents[0]);
2581 case 2: Kokkos::resize(data2_,newExtents[0],newExtents[1]);
2583 case 3: Kokkos::resize(data3_,newExtents[0],newExtents[1],newExtents[2]);
2585 case 4: Kokkos::resize(data4_,newExtents[0],newExtents[1],newExtents[2],newExtents[3]);
2587 case 5: Kokkos::resize(data5_,newExtents[0],newExtents[1],newExtents[2],newExtents[3],newExtents[4]);
2589 case 6: Kokkos::resize(data6_,newExtents[0],newExtents[1],newExtents[2],newExtents[3],newExtents[4],newExtents[5]);
2591 case 7: Kokkos::resize(data7_,newExtents[0],newExtents[1],newExtents[2],newExtents[3],newExtents[4],newExtents[5],newExtents[6]);
2593 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Unexpected dataRank_ value");
2597 extents_[d] = newExtent;
2601 KOKKOS_INLINE_FUNCTION
2604 return underlyingMatchesLogical_;
enable_if_t< rank==7, Kokkos::MDRangePolicy< typename DeviceType::execution_space, Kokkos::Rank< 6 > > > dataExtentRangePolicy()
returns an MDRangePolicy over the first six underlying data extents (but with the logical shape)...
KOKKOS_INLINE_FUNCTION void setUnderlyingView4(Kokkos::View< DataScalar ****, DeviceType > &view) const
sets the View that stores the unique data. For rank-4 underlying containers.
KOKKOS_INLINE_FUNCTION bool isDiagonal() const
returns true for containers that have two dimensions marked as BLOCK_PLUS_DIAGONAL for which the non-...
void applyOperator(UnaryOperator unaryOperator)
applies the specified unary operator to each entry
KOKKOS_INLINE_FUNCTION DimensionInfo getDimensionInfo(const int &dim) const
Returns an object fully specifying the indicated dimension. This is used in determining appropriate s...
static KOKKOS_INLINE_FUNCTION int blockPlusDiagonalDiagonalEntryIndex(const int &lastNondiagonal, const int &numNondiagonalEntries, const int &i)
Returns flattened index of the specified (i,i) matrix entry, assuming that i > lastNondiagonal. Only applicable for BLOCK_PLUS_DIAGONAL DataVariationType.
ScalarView< DataScalar, DeviceType > getUnderlyingView() const
Returns a DynRankView constructed atop the same underlying data as the fixed-rank Kokkos::View used i...
KOKKOS_INLINE_FUNCTION enable_if_t< rank==4, const Kokkos::View< typename RankExpander< DataScalar, rank >::value_type, DeviceType > & > getUnderlyingView() const
Returns the underlying view. Throws an exception if the underlying view is not rank 4...
KOKKOS_INLINE_FUNCTION void setUnderlyingView6(Kokkos::View< DataScalar ******, DeviceType > &view) const
sets the View that stores the unique data. For rank-6 underlying containers.
static KOKKOS_INLINE_FUNCTION int blockPlusDiagonalBlockEntryIndex(const int &lastNondiagonal, const int &numNondiagonalEntries, const int &i, const int &j)
//! Returns flattened index of the specified (i,j) matrix entry, assuming that i,j ≤ lastNondiagonal...
static Data< DataScalar, DeviceType > allocateInPlaceCombinationResult(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B)
KOKKOS_INLINE_FUNCTION reference_type getWritableEntryWithPassThroughOption(const bool &passThroughBlockDiagonalArgs, const IntArgs... intArgs) const
Returns an l-value reference to the specified logical entry in the underlying view. Note that for variation types other than GENERAL, multiple valid argument sets will refer to the same memory location. Intended for Intrepid2 developers and expert users only. If passThroughBlockDiagonalArgs is TRUE, the corresponding arguments are interpreted as entries in the 1D packed matrix rather than as logical 2D matrix row and column.
KOKKOS_INLINE_FUNCTION Kokkos::Array< int, 7 > getExtents() const
Returns an array containing the logical extents in each dimension.
static void copyContainer(ToContainer to, FromContainer from)
Generic data copying method to allow construction of Data object from DynRankViews for which deep_cop...
KOKKOS_INLINE_FUNCTION enable_if_t< rank==3, const Kokkos::View< typename RankExpander< DataScalar, rank >::value_type, DeviceType > & > getUnderlyingView() const
Returns the underlying view. Throws an exception if the underlying view is not rank 3...
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar ******, DeviceType > & getUnderlyingView6() const
returns the View that stores the unique data. For rank-6 underlying containers.
#define INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(test, x, msg)
KOKKOS_INLINE_FUNCTION void setUnderlyingView7(Kokkos::View< DataScalar *******, DeviceType > &view) const
sets the View that stores the unique data. For rank-7 underlying containers.
KOKKOS_INLINE_FUNCTION ordinal_type getUnderlyingViewRank() const
returns the rank of the View that stores the unique data
enable_if_t< rank !=7, void > storeInPlaceCombination(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B, BinaryOperator binaryOperator)
storeInPlaceCombination with compile-time rank – implementation for rank < 7.
KOKKOS_INLINE_FUNCTION void setUnderlyingView2(Kokkos::View< DataScalar **, DeviceType > &view) const
sets the View that stores the unique data. For rank-2 underlying containers.
KOKKOS_INLINE_FUNCTION void setUnderlyingView3(Kokkos::View< DataScalar ***, DeviceType > &view) const
sets the View that stores the unique data. For rank-3 underlying containers.
KOKKOS_INLINE_FUNCTION DimensionInfo combinedDataDimensionInfo(const Data &otherData, const int &dim) const
Returns (DataVariationType, data extent) in the specified dimension for a Data container that combine...
void storeMatVec(const Data< DataScalar, DeviceType > &matData, const Data< DataScalar, DeviceType > &vecData)
Places the result of a matrix-vector multiply corresponding to the two provided containers into this ...
KOKKOS_INLINE_FUNCTION enable_if_t< rank==1, const Kokkos::View< typename RankExpander< DataScalar, rank >::value_type, DeviceType > & > getUnderlyingView() const
Returns the underlying view. Throws an exception if the underlying view is not rank 1...
KOKKOS_INLINE_FUNCTION enable_if_t< rank==7, const Kokkos::View< typename RankExpander< DataScalar, rank >::value_type, DeviceType > & > getUnderlyingView() const
Returns the underlying view. Throws an exception if the underlying view is not rank 7...
KOKKOS_INLINE_FUNCTION const int & blockPlusDiagonalLastNonDiagonal() const
For a Data object containing data with variation type BLOCK_PLUS_DIAGONAL, returns the row and column...
void clear() const
Copies 0.0 to the underlying View.
KOKKOS_INLINE_FUNCTION constexpr bool isValid() const
returns true for containers that have data; false for those that don't (namely, those that have been ...
one of two dimensions in a matrix; bottom-right part of matrix is diagonal
KOKKOS_INLINE_FUNCTION enable_if_t< rank==5, const Kokkos::View< typename RankExpander< DataScalar, rank >::value_type, DeviceType > & > getUnderlyingView() const
Returns the underlying view. Throws an exception if the underlying view is not rank 5...
Wrapper around a Kokkos::View that allows data that is constant or repeating in various logical dimen...
varies according to modulus of the index
void storeInPlaceCombination(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B, BinaryOperator binaryOperator)
Places the result of an in-place combination (e.g., entrywise sum) into this data container...
Header function for Intrepid2::Util class and other utility functions.
KOKKOS_INLINE_FUNCTION bool underlyingMatchesLogical() const
Returns true if the underlying container has exactly the same rank and extents as the logical contain...
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar *, DeviceType > & getUnderlyingView1() const
returns the View that stores the unique data. For rank-1 underlying containers.
enable_if_t< rank==7, void > storeInPlaceCombination(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B, BinaryOperator binaryOperator)
storeInPlaceCombination with compile-time rank – implementation for rank of 7. (Not optimized; expec...
Data(std::vector< DimensionInfo > dimInfoVector)
Constructor in terms of DimensionInfo for each logical dimension; does not require a View to be speci...
Struct expressing all variation information about a Data object in a single dimension, including its logical extent and storage extent.
KOKKOS_INLINE_FUNCTION unsigned rank() const
Returns the logical rank of the Data container.
void storeInPlaceDifference(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B)
stores the in-place (entrywise) difference, A .- B, into this container.
KOKKOS_INLINE_FUNCTION enable_if_t< valid_args< IntArgs... >::value &&(sizeof...(IntArgs)<=7), return_type > operator()(const IntArgs &... intArgs) const
Returns a value corresponding to the specified logical data location.
Data(DataScalar constantValue, Kokkos::Array< int, rank > extents)
constructor for everywhere-constant data
KOKKOS_INLINE_FUNCTION enable_if_t< rank==2, const Kokkos::View< typename RankExpander< DataScalar, rank >::value_type, DeviceType > & > getUnderlyingView() const
Returns the underlying view. Throws an exception if the underlying view is not rank 2...
enable_if_t<(rank!=1) &&(rank!=7), Kokkos::MDRangePolicy< typename DeviceType::execution_space, Kokkos::Rank< rank > > > dataExtentRangePolicy()
returns an MDRangePolicy over the underlying data extents (but with the logical shape).
Data< DataScalar, DeviceType > allocateConstantData(const DataScalar &value)
KOKKOS_INLINE_FUNCTION int extent_int(const int &r) const
Returns the logical extent in the specified dimension.
void copyDataFromDynRankViewMatchingUnderlying(const ScalarView< DataScalar, DeviceType > &dynRankView) const
Copies from the provided DynRankView into the underlying Kokkos::View container storing the unique da...
KOKKOS_INLINE_FUNCTION return_type getEntry(const IntArgs &... intArgs) const
Returns a (read-only) value corresponding to the specified logical data location. ...
static Data< DataScalar, DeviceType > allocateMatVecResult(const Data< DataScalar, DeviceType > &matData, const Data< DataScalar, DeviceType > &vecData)
void storeInPlaceQuotient(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B)
stores the in-place (entrywise) quotient, A ./ B, into this container.
void storeInPlaceSum(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B)
stores the in-place (entrywise) sum, A .+ B, into this container.
Data(const ScalarView< DataScalar, DeviceType > &data, int rank, Kokkos::Array< int, 7 > extents, Kokkos::Array< DataVariationType, 7 > variationType, const int blockPlusDiagonalLastNonDiagonal=-1)
DynRankView constructor. Will copy to a View of appropriate rank.
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar ****, DeviceType > & getUnderlyingView4() const
returns the View that stores the unique data. For rank-4 underlying containers.
void storeMatMat(const bool transposeA, const Data< DataScalar, DeviceType > &A_MatData, const bool transposeB, const Data< DataScalar, DeviceType > &B_MatData)
void allocateAndCopyFromDynRankView(ScalarView< DataScalar, DeviceType > data)
allocate an underlying View that matches the provided DynRankView in dimensions, and copy...
KOKKOS_INLINE_FUNCTION DimensionInfo combinedDimensionInfo(const DimensionInfo &myData, const DimensionInfo &otherData)
Returns DimensionInfo for a Data container that combines (through multiplication, say...
static KOKKOS_INLINE_FUNCTION int blockPlusDiagonalNumNondiagonalEntries(const int &lastNondiagonal)
Returns the number of non-diagonal entries based on the last non-diagonal. Only applicable for BLOCK_...
KOKKOS_INLINE_FUNCTION enable_if_t< rank==6, const Kokkos::View< typename RankExpander< DataScalar, rank >::value_type, DeviceType > & > getUnderlyingView() const
Returns the underlying view. Throws an exception if the underlying view is not rank 6...
void setActiveDims()
class initialization method. Called by constructors.
Kokkos::DynRankView< typename ViewType::value_type, typename DeduceLayout< ViewType >::result_layout, typename ViewType::device_type > getMatchingViewWithLabel(const ViewType &view, const std::string &label, DimArgs... dims)
Creates and returns a view that matches the provided view in Kokkos Layout.
Data()
default constructor (empty data)
ScalarView< DataScalar, DeviceType > allocateDynRankViewMatchingUnderlying() const
Returns a DynRankView that matches the underlying Kokkos::View object in value_type, layout, and dimension.
void setExtent(const ordinal_type &d, const ordinal_type &newExtent)
sets the logical extent in the specified dimension. If needed, the underlying data container is resiz...
A singleton class for a DynRankView containing exactly one zero entry. (Technically, the entry is DataScalar(), the default value for the scalar type.) This allows View-wrapping classes to return a reference to zero, even when that zero is not explicitly stored in the wrapped views.
void storeInPlaceProduct(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B)
stores the in-place (entrywise) product, A .* B, into this container.
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar *******, DeviceType > & getUnderlyingView7() const
returns the View that stores the unique data. For rank-7 underlying containers.
KOKKOS_INLINE_FUNCTION reference_type getWritableEntry(const IntArgs... intArgs) const
Returns an l-value reference to the specified logical entry in the underlying view. Note that for variation types other than GENERAL, multiple valid argument sets will refer to the same memory location. Intended for Intrepid2 developers and expert users only. If passThroughBlockDiagonalArgs is TRUE, the corresponding arguments are interpreted as entries in the 1D packed matrix rather than as logical 2D matrix row and column.
KOKKOS_INLINE_FUNCTION void setUnderlyingView1(Kokkos::View< DataScalar *, DeviceType > &view) const
sets the View that stores the unique data. For rank-1 underlying containers.
KOKKOS_INLINE_FUNCTION void setUnderlyingView5(Kokkos::View< DataScalar *****, DeviceType > &view) const
sets the View that stores the unique data. For rank-5 underlying containers.
void storeInPlaceCombination(PolicyType &policy, ThisUnderlyingViewType &this_underlying, AUnderlyingViewType &A_underlying, BUnderlyingViewType &B_underlying, BinaryOperator &binaryOperator, ArgExtractorThis argThis, ArgExtractorA argA, ArgExtractorB argB)
storeInPlaceCombination implementation for rank < 7, with compile-time underlying views and argument ...
Data shallowCopy(const int rank, const Kokkos::Array< int, 7 > &extents, const Kokkos::Array< DataVariationType, 7 > &variationTypes)
Creates a new Data object with the same underlying view, but with the specified logical rank...
KOKKOS_INLINE_FUNCTION int getVariationModulus(const int &d) const
Variation modulus accessor.
Data(ScalarView< DataScalar, DeviceType > data)
copy constructor modeled after the copy-like constructor above. Not as efficient as the implicit copy...
Data(const Kokkos::DynRankView< DataScalar, DeviceType, DynRankViewProperties... > &data, Kokkos::Array< int, rank > extents, Kokkos::Array< DataVariationType, rank > variationType, const int blockPlusDiagonalLastNonDiagonal=-1)
Constructor that accepts a DynRankView as an argument. The data belonging to the DynRankView will be ...
KOKKOS_INLINE_FUNCTION return_type getEntryWithPassThroughOption(const bool &passThroughBlockDiagonalArgs, const IntArgs &... intArgs) const
Returns a (read-only) value corresponding to the specified logical data location. If passThroughBlock...
KOKKOS_INLINE_FUNCTION int getDataExtent(const ordinal_type &d) const
returns the true extent of the data corresponding to the logical dimension provided; if the data does...
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar **, DeviceType > & getUnderlyingView2() const
returns the View that stores the unique data. For rank-2 underlying containers.
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar *****, DeviceType > & getUnderlyingView5() const
returns the View that stores the unique data. For rank-5 underlying containers.
DataVariationType
Enumeration to indicate how data varies in a particular dimension of an Intrepid2::Data object...
ScalarView< DataScalar, DeviceType > allocateDynRankViewMatchingUnderlying(DimArgs... dims) const
Returns a DynRankView that matches the underlying Kokkos::View object value_type and layout...
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar ***, DeviceType > & getUnderlyingView3() const
returns the View that stores the unique data. For rank-3 underlying containers.
static Data< DataScalar, DeviceType > allocateMatMatResult(const bool transposeA, const Data< DataScalar, DeviceType > &A_MatData, const bool transposeB, const Data< DataScalar, DeviceType > &B_MatData)
KOKKOS_INLINE_FUNCTION ordinal_type getUnderlyingViewSize() const
returns the number of entries in the View that stores the unique data
Data(const Data< DataScalar, OtherDeviceType > &data)
copy-like constructor for differing execution spaces. This does a deep_copy of the underlying view...
KOKKOS_INLINE_FUNCTION int getUnderlyingViewExtent(const int &dim) const
Returns the extent of the underlying view in the specified dimension.
KOKKOS_INLINE_FUNCTION const Kokkos::Array< DataVariationType, 7 > & getVariationTypes() const
Returns an array with the variation types in each logical dimension.