16 #ifndef Intrepid2_Data_h
17 #define Intrepid2_Data_h
23 #include "Intrepid2_ScalarView.hpp"
43 template<
class DataScalar,
typename DeviceType>
46 static ScalarView<DataScalar,DeviceType> zeroView()
48 static ScalarView<DataScalar,DeviceType> zeroView = ScalarView<DataScalar,DeviceType>(
"zero",1);
49 static bool havePushedFinalizeHook =
false;
50 if (!havePushedFinalizeHook)
52 Kokkos::push_finalize_hook( [=] {
53 zeroView = ScalarView<DataScalar,DeviceType>();
55 havePushedFinalizeHook =
true;
78 template<
class DataScalar,
typename DeviceType>
81 using value_type = DataScalar;
82 using execution_space =
typename DeviceType::execution_space;
84 using reference_type =
typename ScalarView<DataScalar,DeviceType>::reference_type;
85 using const_reference_type =
typename ScalarView<const DataScalar,DeviceType>::reference_type;
87 ordinal_type dataRank_;
88 using View1 = Kokkos::View<DataScalar*, DeviceType>;
89 using View2 = Kokkos::View<DataScalar**, DeviceType>;
90 using View3 = Kokkos::View<DataScalar***, DeviceType>;
91 using View4 = Kokkos::View<DataScalar****, DeviceType>;
92 using View5 = Kokkos::View<DataScalar*****, DeviceType>;
93 using View6 = Kokkos::View<DataScalar******, DeviceType>;
94 using View7 = Kokkos::View<DataScalar*******, DeviceType>;
95 std::variant<View1,View2,View3,View4,View5,View6,View7> underlyingView_;
96 Kokkos::Array<int,7> extents_;
97 Kokkos::Array<DataVariationType,7> variationType_;
98 Kokkos::Array<int,7> variationModulus_;
99 int blockPlusDiagonalLastNonDiagonal_ = -1;
101 bool underlyingMatchesLogical_;
102 Kokkos::Array<ordinal_type,7> activeDims_;
108 using return_type = const_reference_type;
110 ScalarView<DataScalar,DeviceType> zeroView_;
113 KOKKOS_INLINE_FUNCTION
116 return (lastNondiagonal + 1) * (lastNondiagonal + 1);
120 KOKKOS_INLINE_FUNCTION
123 return i * (lastNondiagonal + 1) + j;
127 KOKKOS_INLINE_FUNCTION
130 return i - (lastNondiagonal + 1) + numNondiagonalEntries;
134 KOKKOS_INLINE_FUNCTION
const T& get_fixed_view(
const std::variant<View1,View2,View3,View4,View5,View6,View7> & v)
const {
135 return *
reinterpret_cast<const T*
>(&v);
139 KOKKOS_INLINE_FUNCTION
144 case 1:
return get_fixed_view<View1>(underlyingView_).
extent_int(dim);
145 case 2:
return get_fixed_view<View2>(underlyingView_).
extent_int(dim);
146 case 3:
return get_fixed_view<View3>(underlyingView_).
extent_int(dim);
147 case 4:
return get_fixed_view<View4>(underlyingView_).
extent_int(dim);
148 case 5:
return get_fixed_view<View5>(underlyingView_).
extent_int(dim);
149 case 6:
return get_fixed_view<View6>(underlyingView_).
extent_int(dim);
150 case 7:
return get_fixed_view<View7>(underlyingView_).
extent_int(dim);
158 INTREPID2_TEST_FOR_EXCEPTION(underlyingView_.valueless_by_exception(), std::invalid_argument,
"underlyingView_ not correctly set!");
161 for (
int d=rank_; d<7; d++)
163 INTREPID2_TEST_FOR_EXCEPTION(extents_[d] > 1, std::invalid_argument,
"Nominal extents may not be > 1 in dimensions beyond the rank of the container");
167 int blockPlusDiagonalCount = 0;
168 underlyingMatchesLogical_ =
true;
169 for (ordinal_type i=0; i<7; i++)
171 if (variationType_[i] == GENERAL)
173 if (extents_[i] != 0)
175 variationModulus_[i] = extents_[i];
179 variationModulus_[i] = 1;
181 activeDims_[numActiveDims_] = i;
184 else if (variationType_[i] == MODULAR)
186 underlyingMatchesLogical_ =
false;
190 const int logicalExtent = extents_[i];
191 const int modulus = dataExtent;
193 INTREPID2_TEST_FOR_EXCEPTION( dataExtent * (logicalExtent / dataExtent) != logicalExtent, std::invalid_argument,
"data extent must evenly divide logical extent");
195 variationModulus_[i] = modulus;
199 variationModulus_[i] = extents_[i];
201 activeDims_[numActiveDims_] = i;
204 else if (variationType_[i] == BLOCK_PLUS_DIAGONAL)
206 underlyingMatchesLogical_ =
false;
207 blockPlusDiagonalCount++;
208 if (blockPlusDiagonalCount == 1)
211 #ifdef HAVE_INTREPID2_DEBUG
214 const int logicalExtent = extents_[i];
215 const int numDiagonalEntries = logicalExtent - (blockPlusDiagonalLastNonDiagonal_ + 1);
216 const int expectedDataExtent = numNondiagonalEntries + numDiagonalEntries;
217 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());
220 activeDims_[numActiveDims_] = i;
224 INTREPID2_TEST_FOR_EXCEPTION(variationType_[i+1] != BLOCK_PLUS_DIAGONAL, std::invalid_argument,
"BLOCK_PLUS_DIAGONAL ranks must be contiguous");
226 variationModulus_[i] = 1;
227 INTREPID2_TEST_FOR_EXCEPTION(blockPlusDiagonalCount > 1, std::invalid_argument,
"BLOCK_PLUS_DIAGONAL can only apply to two ranks");
233 underlyingMatchesLogical_ =
false;
235 variationModulus_[i] = 1;
239 if (rank_ != dataRank_)
241 underlyingMatchesLogical_ =
false;
244 for (
int d=numActiveDims_; d<7; d++)
250 for (
int d=0; d<7; d++)
252 INTREPID2_TEST_FOR_EXCEPTION(variationModulus_[d] == 0, std::logic_error,
"variationModulus should not ever be 0");
258 template<
class UnaryOperator>
261 using ExecutionSpace =
typename DeviceType::execution_space;
267 const int dataRank = 1;
268 auto view = getUnderlyingView<dataRank>();
271 Kokkos::RangePolicy<ExecutionSpace> policy(ExecutionSpace(),0,dataExtent);
272 Kokkos::parallel_for(
"apply operator in-place", policy,
273 KOKKOS_LAMBDA (
const int &i0) {
274 view(i0) = unaryOperator(view(i0));
281 const int dataRank = 2;
282 auto policy = dataExtentRangePolicy<dataRank>();
283 auto view = getUnderlyingView<dataRank>();
285 Kokkos::parallel_for(
"apply operator in-place", policy,
286 KOKKOS_LAMBDA (
const int &i0,
const int &i1) {
287 view(i0,i1) = unaryOperator(view(i0,i1));
293 const int dataRank = 3;
294 auto policy = dataExtentRangePolicy<dataRank>();
295 auto view = getUnderlyingView<dataRank>();
297 Kokkos::parallel_for(
"apply operator in-place", policy,
298 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2) {
299 view(i0,i1,i2) = unaryOperator(view(i0,i1,i2));
305 const int dataRank = 4;
306 auto policy = dataExtentRangePolicy<dataRank>();
307 auto view = getUnderlyingView<dataRank>();
309 Kokkos::parallel_for(
"apply operator in-place", policy,
310 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2,
const int &i3) {
311 view(i0,i1,i2,i3) = unaryOperator(view(i0,i1,i2,i3));
317 const int dataRank = 5;
318 auto policy = dataExtentRangePolicy<dataRank>();
319 auto view = getUnderlyingView<dataRank>();
321 Kokkos::parallel_for(
"apply operator in-place", policy,
322 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2,
const int &i3,
const int &i4) {
323 view(i0,i1,i2,i3,i4) = unaryOperator(view(i0,i1,i2,i3,i4));
329 const int dataRank = 6;
330 auto policy = dataExtentRangePolicy<dataRank>();
331 auto view = getUnderlyingView<dataRank>();
333 Kokkos::parallel_for(
"apply operator in-place", policy,
334 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2,
const int &i3,
const int &i4,
const int &i5) {
335 view(i0,i1,i2,i3,i4,i5) = unaryOperator(view(i0,i1,i2,i3,i4,i5));
341 const int dataRank = 7;
342 auto policy6 = dataExtentRangePolicy<6>();
343 auto view = getUnderlyingView<dataRank>();
345 const int dim_i6 = view.extent_int(6);
347 Kokkos::parallel_for(
"apply operator in-place", policy6,
348 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2,
const int &i3,
const int &i4,
const int &i5) {
349 for (
int i6=0; i6<dim_i6; i6++)
351 view(i0,i1,i2,i3,i4,i5,i6) = unaryOperator(view(i0,i1,i2,i3,i4,i5,i6));
357 INTREPID2_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
"Unsupported data rank");
362 template<
class ...IntArgs>
363 KOKKOS_INLINE_FUNCTION
366 #ifdef INTREPID2_HAVE_DEBUG
369 constexpr
int numArgs =
sizeof...(intArgs);
370 if (underlyingMatchesLogical_)
373 return getUnderlyingView<numArgs>()(intArgs...);
377 using int_type = std::tuple_element_t<0, std::tuple<IntArgs...>>;
379 const Kokkos::Array<int_type, numArgs+1> args {intArgs...,0};
380 Kokkos::Array<int_type, 7> refEntry;
381 for (
int d=0; d<numArgs; d++)
383 switch (variationType_[d])
385 case CONSTANT: refEntry[d] = 0;
break;
386 case GENERAL: refEntry[d] = args[d];
break;
387 case MODULAR: refEntry[d] = args[d] % variationModulus_[d];
break;
388 case BLOCK_PLUS_DIAGONAL:
390 if (passThroughBlockDiagonalArgs)
392 refEntry[d] = args[d];
393 refEntry[d+1] = args[d+1];
400 const int_type &i = args[d];
407 const int_type &j = args[d+1];
409 if ((i > static_cast<int_type>(blockPlusDiagonalLastNonDiagonal_)) || (j > static_cast<int_type>(blockPlusDiagonalLastNonDiagonal_)))
435 for (
int d=numArgs; d<7; d++)
442 return get_fixed_view<View1>(underlyingView_)(refEntry[activeDims_[0]]);
444 else if (dataRank_ == 2)
446 return get_fixed_view<View2>(underlyingView_)(refEntry[activeDims_[0]],refEntry[activeDims_[1]]);
448 else if (dataRank_ == 3)
450 return get_fixed_view<View3>(underlyingView_)(refEntry[activeDims_[0]],refEntry[activeDims_[1]],refEntry[activeDims_[2]]);
452 else if (dataRank_ == 4)
454 return get_fixed_view<View4>(underlyingView_)(refEntry[activeDims_[0]],refEntry[activeDims_[1]],refEntry[activeDims_[2]],refEntry[activeDims_[3]]);
456 else if (dataRank_ == 5)
458 return get_fixed_view<View5>(underlyingView_)(refEntry[activeDims_[0]],refEntry[activeDims_[1]],refEntry[activeDims_[2]],refEntry[activeDims_[3]],
459 refEntry[activeDims_[4]]);
461 else if (dataRank_ == 6)
463 return get_fixed_view<View6>(underlyingView_)(refEntry[activeDims_[0]],refEntry[activeDims_[1]],refEntry[activeDims_[2]],refEntry[activeDims_[3]],
464 refEntry[activeDims_[4]],refEntry[activeDims_[5]]);
468 return get_fixed_view<View7>(underlyingView_)(refEntry[activeDims_[0]],refEntry[activeDims_[1]],refEntry[activeDims_[2]],refEntry[activeDims_[3]],
469 refEntry[activeDims_[4]],refEntry[activeDims_[5]],refEntry[activeDims_[6]]);
475 template<
class ...IntArgs>
476 KOKKOS_INLINE_FUNCTION
483 template<
class ToContainer,
class FromContainer>
487 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)});
489 Kokkos::parallel_for(
"copyContainer", policy,
490 KOKKOS_LAMBDA (
const int &i0,
const int &i1,
const int &i2,
const int &i3,
const int &i4,
const int &i5) {
491 for (
int i6=0; i6<from.extent_int(6); i6++)
493 to.access(i0,i1,i2,i3,i4,i5,i6) = from.access(i0,i1,i2,i3,i4,i5,i6);
504 case 1: underlyingView_ = Kokkos::View<DataScalar*, DeviceType>(
"Intrepid2 Data", data.extent_int(0));
break;
505 case 2: underlyingView_ = Kokkos::View<DataScalar**, DeviceType>(
"Intrepid2 Data", data.extent_int(0), data.extent_int(1));
break;
506 case 3: underlyingView_ = Kokkos::View<DataScalar***, DeviceType>(
"Intrepid2 Data", data.extent_int(0), data.extent_int(1), data.extent_int(2));
break;
507 case 4: underlyingView_ = Kokkos::View<DataScalar****, DeviceType>(
"Intrepid2 Data", data.extent_int(0), data.extent_int(1), data.extent_int(2), data.extent_int(3));
break;
508 case 5: underlyingView_ = 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;
509 case 6: underlyingView_ = 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;
510 case 7: underlyingView_ = 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;
511 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
516 case 1:
copyContainer(get_fixed_view<View1>(underlyingView_),data);
break;
517 case 2:
copyContainer(get_fixed_view<View2>(underlyingView_),data);
break;
518 case 3:
copyContainer(get_fixed_view<View3>(underlyingView_),data);
break;
519 case 4:
copyContainer(get_fixed_view<View4>(underlyingView_),data);
break;
520 case 5:
copyContainer(get_fixed_view<View5>(underlyingView_),data);
break;
521 case 6:
copyContainer(get_fixed_view<View6>(underlyingView_),data);
break;
522 case 7:
copyContainer(get_fixed_view<View7>(underlyingView_),data);
break;
523 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
528 Data(std::vector<DimensionInfo> dimInfoVector)
531 dataRank_(0), extents_({0,0,0,0,0,0,0}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(-1), rank_(dimInfoVector.size())
535 if (dimInfoVector.size() != 0)
537 std::vector<int> dataExtents;
539 bool blockPlusDiagonalEncountered =
false;
540 for (
int d=0; d<rank_; d++)
542 const DimensionInfo & dimInfo = dimInfoVector[d];
543 extents_[d] = dimInfo.logicalExtent;
544 variationType_[d] = dimInfo.variationType;
545 const bool isBlockPlusDiagonal = (variationType_[d] == BLOCK_PLUS_DIAGONAL);
546 const bool isSecondBlockPlusDiagonal = isBlockPlusDiagonal && blockPlusDiagonalEncountered;
547 if (isBlockPlusDiagonal)
549 blockPlusDiagonalEncountered =
true;
550 blockPlusDiagonalLastNonDiagonal_ = dimInfo.blockPlusDiagonalLastNonDiagonal;
552 if ((variationType_[d] != CONSTANT) && (!isSecondBlockPlusDiagonal))
554 dataExtents.push_back(dimInfo.dataExtent);
557 if (dataExtents.size() == 0)
560 dataExtents.push_back(1);
562 dataRank_ = dataExtents.size();
565 case 1: underlyingView_ = Kokkos::View<DataScalar*, DeviceType>(
"Intrepid2 Data", dataExtents[0]);
break;
566 case 2: underlyingView_ = Kokkos::View<DataScalar**, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1]);
break;
567 case 3: underlyingView_ = Kokkos::View<DataScalar***, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1], dataExtents[2]);
break;
568 case 4: underlyingView_ = Kokkos::View<DataScalar****, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1], dataExtents[2], dataExtents[3]);
break;
569 case 5: underlyingView_ = Kokkos::View<DataScalar*****, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1], dataExtents[2], dataExtents[3], dataExtents[4]);
break;
570 case 6: underlyingView_ = Kokkos::View<DataScalar******, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1], dataExtents[2], dataExtents[3], dataExtents[4], dataExtents[5]);
break;
571 case 7: underlyingView_ = Kokkos::View<DataScalar*******, DeviceType>(
"Intrepid2 Data", dataExtents[0], dataExtents[1], dataExtents[2], dataExtents[3], dataExtents[4], dataExtents[5], dataExtents[6]);
break;
572 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
588 template<typename OtherDeviceType, class = typename std::enable_if< std::is_same<typename DeviceType::memory_space, typename OtherDeviceType::memory_space>::value>::type,
589 class = typename std::enable_if<!std::is_same<DeviceType,OtherDeviceType>::value>::type>
590 Data(const Data<DataScalar,OtherDeviceType> &data)
592 dataRank_(data.getUnderlyingViewRank()), extents_(data.getExtents()), variationType_(data.getVariationTypes()), blockPlusDiagonalLastNonDiagonal_(data.blockPlusDiagonalLastNonDiagonal()), rank_(data.rank())
600 case 1: underlyingView_ = data.getUnderlyingView1();
break;
601 case 2: underlyingView_ = data.getUnderlyingView2();
break;
602 case 3: underlyingView_ = data.getUnderlyingView3();
break;
603 case 4: underlyingView_ = data.getUnderlyingView4();
break;
604 case 5: underlyingView_ = data.getUnderlyingView5();
break;
605 case 6: underlyingView_ = data.getUnderlyingView6();
break;
606 case 7: underlyingView_ = data.getUnderlyingView7();
break;
607 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
614 template<typename OtherDeviceType, class = typename std::enable_if<!std::is_same<typename DeviceType::memory_space, typename OtherDeviceType::memory_space>::value>::type>
625 case 1: underlyingView_ = Kokkos::View<DataScalar*, DeviceType>(
"Intrepid2 Data", view.extent_int(0));
break;
626 case 2: underlyingView_ = Kokkos::View<DataScalar**, DeviceType>(
"Intrepid2 Data", view.extent_int(0), view.extent_int(1));
break;
627 case 3: underlyingView_ = Kokkos::View<DataScalar***, DeviceType>(
"Intrepid2 Data", view.extent_int(0), view.extent_int(1), view.extent_int(2));
break;
628 case 4: underlyingView_ = Kokkos::View<DataScalar****, DeviceType>(
"Intrepid2 Data", view.extent_int(0), view.extent_int(1), view.extent_int(2), view.extent_int(3));
break;
629 case 5: underlyingView_ = 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;
630 case 6: underlyingView_ = 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;
631 case 7: underlyingView_ = 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;
632 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
638 using MemorySpace =
typename DeviceType::memory_space;
641 case 1: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView1());
copyContainer(get_fixed_view<View1>(underlyingView_), dataViewMirror);}
break;
642 case 2: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView2());
copyContainer(get_fixed_view<View2>(underlyingView_), dataViewMirror);}
break;
643 case 3: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView3());
copyContainer(get_fixed_view<View3>(underlyingView_), dataViewMirror);}
break;
644 case 4: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView4());
copyContainer(get_fixed_view<View4>(underlyingView_), dataViewMirror);}
break;
645 case 5: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView5());
copyContainer(get_fixed_view<View5>(underlyingView_), dataViewMirror);}
break;
646 case 6: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView6());
copyContainer(get_fixed_view<View6>(underlyingView_), dataViewMirror);}
break;
647 case 7: {
auto dataViewMirror = Kokkos::create_mirror_view_and_copy(MemorySpace(), data.
getUnderlyingView7());
copyContainer(get_fixed_view<View7>(underlyingView_), dataViewMirror);}
break;
648 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
696 Data(ScalarView<DataScalar,DeviceType> data)
700 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)},
701 Kokkos::Array<DataVariationType,7> {GENERAL,GENERAL,GENERAL,GENERAL,GENERAL,GENERAL,GENERAL}, -1)
705 template<
size_t rank,
class ...DynRankViewProperties>
706 Data(
const Kokkos::DynRankView<DataScalar,DeviceType, DynRankViewProperties...> &data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
708 dataRank_(data.
rank()), extents_({1,1,1,1,1,1,1}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
712 for (
unsigned d=0; d<
rank; d++)
714 extents_[d] = extents[d];
715 variationType_[d] = variationType[d];
720 template<
size_t rank,
class ...ViewProperties>
721 Data(Kokkos::View<DataScalar*,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
723 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
725 underlyingView_ = data;
726 for (
unsigned d=0; d<
rank; d++)
728 extents_[d] = extents[d];
729 variationType_[d] = variationType[d];
734 template<
size_t rank,
class ...ViewProperties>
735 Data(Kokkos::View<DataScalar**,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
737 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
739 underlyingView_ = data;
740 for (
unsigned d=0; d<
rank; d++)
742 extents_[d] = extents[d];
743 variationType_[d] = variationType[d];
748 template<
size_t rank,
class ...ViewProperties>
749 Data(Kokkos::View<DataScalar***,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
751 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
753 underlyingView_ = data;
754 for (
unsigned d=0; d<
rank; d++)
756 extents_[d] = extents[d];
757 variationType_[d] = variationType[d];
762 template<
size_t rank,
class ...ViewProperties>
763 Data(Kokkos::View<DataScalar****,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
765 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
767 underlyingView_ = data;
768 for (
unsigned d=0; d<
rank; d++)
770 extents_[d] = extents[d];
771 variationType_[d] = variationType[d];
776 template<
size_t rank,
class ...ViewProperties>
777 Data(Kokkos::View<DataScalar*****,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
779 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
781 underlyingView_ = data;
782 for (
unsigned d=0; d<
rank; d++)
784 extents_[d] = extents[d];
785 variationType_[d] = variationType[d];
790 template<
size_t rank,
class ...ViewProperties>
791 Data(Kokkos::View<DataScalar******,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
793 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
795 underlyingView_ = data;
796 for (
unsigned d=0; d<
rank; d++)
798 extents_[d] = extents[d];
799 variationType_[d] = variationType[d];
804 template<
size_t rank,
class ...ViewProperties>
805 Data(Kokkos::View<DataScalar*******,DeviceType, ViewProperties...> data, Kokkos::Array<int,rank> extents, Kokkos::Array<DataVariationType,rank> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
807 dataRank_(data.
rank), extents_({1,1,1,1,1,1,1}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
809 underlyingView_ = data;
810 for (
unsigned d=0; d<
rank; d++)
812 extents_[d] = extents[d];
813 variationType_[d] = variationType[d];
819 template<
class ViewScalar,
class ...ViewProperties>
820 Data(
const unsigned rank, Kokkos::View<ViewScalar,DeviceType, ViewProperties...> data, Kokkos::Array<int,7> extents, Kokkos::Array<DataVariationType,7> variationType,
const int blockPlusDiagonalLastNonDiagonal = -1)
822 dataRank_(data.rank), extents_({1,1,1,1,1,1,1}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(
blockPlusDiagonalLastNonDiagonal), rank_(
rank)
824 underlyingView_ = data;
825 for (
unsigned d=0; d<
rank; d++)
827 extents_[d] = extents[d];
828 variationType_[d] = variationType[d];
834 template<
size_t rank>
835 Data(DataScalar constantValue, Kokkos::Array<int,rank> extents)
837 dataRank_(1), extents_({1,1,1,1,1,1,1}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(-1), rank_(
rank)
839 underlyingView_ = Kokkos::View<DataScalar*,DeviceType>(
"Constant Data",1);
840 Kokkos::deep_copy(get_fixed_view<View1>(underlyingView_), constantValue);
841 for (
unsigned d=0; d<
rank; d++)
843 extents_[d] = extents[d];
851 dataRank_(0), extents_({0,0,0,0,0,0,0}), variationType_({CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT,CONSTANT}), blockPlusDiagonalLastNonDiagonal_(-1), rank_(0)
857 KOKKOS_INLINE_FUNCTION
860 return blockPlusDiagonalLastNonDiagonal_;
864 KOKKOS_INLINE_FUNCTION
871 KOKKOS_INLINE_FUNCTION
877 dimInfo.variationType = variationType_[dim];
879 dimInfo.variationModulus = variationModulus_[dim];
881 if (dimInfo.variationType == BLOCK_PLUS_DIAGONAL)
883 dimInfo.blockPlusDiagonalLastNonDiagonal = blockPlusDiagonalLastNonDiagonal_;
889 KOKKOS_INLINE_FUNCTION
895 return combinedDimensionInfo(myDimInfo, otherDimInfo);
900 KOKKOS_INLINE_FUNCTION
901 enable_if_t<rank==1, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
904 #ifdef HAVE_INTREPID2_DEBUG
907 return get_fixed_view<View1>(underlyingView_);
912 KOKKOS_INLINE_FUNCTION
913 enable_if_t<rank==2, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
916 #ifdef HAVE_INTREPID2_DEBUG
919 return get_fixed_view<View2>(underlyingView_);
924 KOKKOS_INLINE_FUNCTION
925 enable_if_t<rank==3, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
928 #ifdef HAVE_INTREPID2_DEBUG
931 return get_fixed_view<View3>(underlyingView_);
936 KOKKOS_INLINE_FUNCTION
937 enable_if_t<rank==4, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
940 #ifdef HAVE_INTREPID2_DEBUG
943 return get_fixed_view<View4>(underlyingView_);
948 KOKKOS_INLINE_FUNCTION
949 enable_if_t<rank==5, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
952 #ifdef HAVE_INTREPID2_DEBUG
955 return get_fixed_view<View5>(underlyingView_);
960 KOKKOS_INLINE_FUNCTION
961 enable_if_t<rank==6, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
964 #ifdef HAVE_INTREPID2_DEBUG
967 return get_fixed_view<View6>(underlyingView_);
972 KOKKOS_INLINE_FUNCTION
973 enable_if_t<rank==7, const Kokkos::View<typename RankExpander<DataScalar, rank>::value_type, DeviceType> &>
976 #ifdef HAVE_INTREPID2_DEBUG
979 return get_fixed_view<View7>(underlyingView_);
983 KOKKOS_INLINE_FUNCTION
986 return getUnderlyingView<1>();
990 KOKKOS_INLINE_FUNCTION
993 return getUnderlyingView<2>();
997 KOKKOS_INLINE_FUNCTION
1000 return getUnderlyingView<3>();
1004 KOKKOS_INLINE_FUNCTION
1007 return getUnderlyingView<4>();
1011 KOKKOS_INLINE_FUNCTION
1014 return getUnderlyingView<5>();
1018 KOKKOS_INLINE_FUNCTION
1021 return getUnderlyingView<6>();
1025 KOKKOS_INLINE_FUNCTION
1028 return getUnderlyingView<7>();
1036 case 1:
return get_fixed_view<View1>(underlyingView_);
1037 case 2:
return get_fixed_view<View2>(underlyingView_);
1038 case 3:
return get_fixed_view<View3>(underlyingView_);
1039 case 4:
return get_fixed_view<View4>(underlyingView_);
1040 case 5:
return get_fixed_view<View5>(underlyingView_);
1041 case 6:
return get_fixed_view<View6>(underlyingView_);
1042 case 7:
return get_fixed_view<View7>(underlyingView_);
1043 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1048 KOKKOS_INLINE_FUNCTION
1055 KOKKOS_INLINE_FUNCTION
1058 ordinal_type size = 1;
1059 for (ordinal_type r=0; r<dataRank_; r++)
1071 case 1:
return getMatchingViewWithLabel(get_fixed_view<View1>(underlyingView_),
"Intrepid2 Data", get_fixed_view<View1>(underlyingView_).
extent_int(0));
1072 case 2:
return getMatchingViewWithLabel(get_fixed_view<View2>(underlyingView_),
"Intrepid2 Data", get_fixed_view<View2>(underlyingView_).
extent_int(0), get_fixed_view<View2>(underlyingView_).
extent_int(1));
1073 case 3:
return getMatchingViewWithLabel(get_fixed_view<View3>(underlyingView_),
"Intrepid2 Data", get_fixed_view<View3>(underlyingView_).
extent_int(0), get_fixed_view<View3>(underlyingView_).
extent_int(1), get_fixed_view<View3>(underlyingView_).
extent_int(2));
1074 case 4:
return getMatchingViewWithLabel(get_fixed_view<View4>(underlyingView_),
"Intrepid2 Data", get_fixed_view<View4>(underlyingView_).
extent_int(0), get_fixed_view<View4>(underlyingView_).
extent_int(1), get_fixed_view<View4>(underlyingView_).
extent_int(2), get_fixed_view<View4>(underlyingView_).
extent_int(3));
1075 case 5:
return getMatchingViewWithLabel(get_fixed_view<View5>(underlyingView_),
"Intrepid2 Data", get_fixed_view<View5>(underlyingView_).
extent_int(0), get_fixed_view<View5>(underlyingView_).
extent_int(1), get_fixed_view<View5>(underlyingView_).
extent_int(2), get_fixed_view<View5>(underlyingView_).
extent_int(3), get_fixed_view<View5>(underlyingView_).
extent_int(4));
1076 case 6:
return getMatchingViewWithLabel(get_fixed_view<View6>(underlyingView_),
"Intrepid2 Data", get_fixed_view<View6>(underlyingView_).
extent_int(0), get_fixed_view<View6>(underlyingView_).
extent_int(1), get_fixed_view<View6>(underlyingView_).
extent_int(2), get_fixed_view<View6>(underlyingView_).
extent_int(3), get_fixed_view<View6>(underlyingView_).
extent_int(4), get_fixed_view<View6>(underlyingView_).
extent_int(5));
1077 case 7:
return getMatchingViewWithLabel(get_fixed_view<View7>(underlyingView_),
"Intrepid2 Data", get_fixed_view<View7>(underlyingView_).
extent_int(0), get_fixed_view<View7>(underlyingView_).
extent_int(1), get_fixed_view<View7>(underlyingView_).
extent_int(2), get_fixed_view<View7>(underlyingView_).
extent_int(3), get_fixed_view<View7>(underlyingView_).
extent_int(4), get_fixed_view<View7>(underlyingView_).
extent_int(5), get_fixed_view<View7>(underlyingView_).
extent_int(6));
1078 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1083 template<
class ... DimArgs>
1088 case 1:
return getMatchingViewWithLabel(get_fixed_view<View1>(underlyingView_),
"Intrepid2 Data", dims...);
1089 case 2:
return getMatchingViewWithLabel(get_fixed_view<View2>(underlyingView_),
"Intrepid2 Data", dims...);
1090 case 3:
return getMatchingViewWithLabel(get_fixed_view<View3>(underlyingView_),
"Intrepid2 Data", dims...);
1091 case 4:
return getMatchingViewWithLabel(get_fixed_view<View4>(underlyingView_),
"Intrepid2 Data", dims...);
1092 case 5:
return getMatchingViewWithLabel(get_fixed_view<View5>(underlyingView_),
"Intrepid2 Data", dims...);
1093 case 6:
return getMatchingViewWithLabel(get_fixed_view<View6>(underlyingView_),
"Intrepid2 Data", dims...);
1094 case 7:
return getMatchingViewWithLabel(get_fixed_view<View7>(underlyingView_),
"Intrepid2 Data", dims...);
1095 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1104 case 1: Kokkos::deep_copy(get_fixed_view<View1>(underlyingView_), 0.0);
break;
1105 case 2: Kokkos::deep_copy(get_fixed_view<View2>(underlyingView_), 0.0);
break;
1106 case 3: Kokkos::deep_copy(get_fixed_view<View3>(underlyingView_), 0.0);
break;
1107 case 4: Kokkos::deep_copy(get_fixed_view<View4>(underlyingView_), 0.0);
break;
1108 case 5: Kokkos::deep_copy(get_fixed_view<View5>(underlyingView_), 0.0);
break;
1109 case 6: Kokkos::deep_copy(get_fixed_view<View6>(underlyingView_), 0.0);
break;
1110 case 7: Kokkos::deep_copy(get_fixed_view<View7>(underlyingView_), 0.0);
break;
1111 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1121 case 1:
copyContainer(get_fixed_view<View1>(underlyingView_),dynRankView);
break;
1122 case 2:
copyContainer(get_fixed_view<View2>(underlyingView_),dynRankView);
break;
1123 case 3:
copyContainer(get_fixed_view<View3>(underlyingView_),dynRankView);
break;
1124 case 4:
copyContainer(get_fixed_view<View4>(underlyingView_),dynRankView);
break;
1125 case 5:
copyContainer(get_fixed_view<View5>(underlyingView_),dynRankView);
break;
1126 case 6:
copyContainer(get_fixed_view<View6>(underlyingView_),dynRankView);
break;
1127 case 7:
copyContainer(get_fixed_view<View7>(underlyingView_),dynRankView);
break;
1128 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Invalid data rank");
1135 for (
int i=0; i<numActiveDims_; i++)
1137 if (activeDims_[i] == d)
1141 else if (activeDims_[i] > d)
1160 KOKKOS_INLINE_FUNCTION
1163 return variationModulus_[d];
1167 KOKKOS_INLINE_FUNCTION
1170 return variationType_;
1174 template<
class ...IntArgs>
1175 KOKKOS_INLINE_FUNCTION
1182 template<
class ...IntArgs>
1183 KOKKOS_INLINE_FUNCTION
1191 template <
bool... v>
1194 template <
class ...IntArgs>
1195 using valid_args = all_true<std::is_integral<IntArgs>{}...>;
1197 static_assert(valid_args<int,long,unsigned>::value,
"valid args works");
1200 template <
class ...IntArgs>
1201 KOKKOS_INLINE_FUNCTION
1202 #ifndef __INTEL_COMPILER
1206 enable_if_t<valid_args<IntArgs...>::value && (
sizeof...(IntArgs) <= 7),return_type>
1215 KOKKOS_INLINE_FUNCTION
1221 template <
typename iType>
1222 KOKKOS_INLINE_FUNCTION constexpr
1223 typename std::enable_if<std::is_integral<iType>::value,
size_t>::type
1224 extent(
const iType& r)
const {
1231 if (blockPlusDiagonalLastNonDiagonal_ >= 1)
return false;
1232 int numBlockPlusDiagonalTypes = 0;
1233 for (
unsigned r = 0; r<variationType_.size(); r++)
1235 const auto &entryType = variationType_[r];
1236 if (entryType == BLOCK_PLUS_DIAGONAL) numBlockPlusDiagonalTypes++;
1239 if (numBlockPlusDiagonalTypes == 2)
return true;
1240 else if (numBlockPlusDiagonalTypes == 0)
return false;
1262 std::vector<DimensionInfo> dimInfo(rank);
1263 for (
int d=0; d<
rank; d++)
1283 const int D1_DIM = A_MatData.
rank() - 2;
1284 const int D2_DIM = A_MatData.
rank() - 1;
1286 const int A_rows = A_MatData.
extent_int(D1_DIM);
1287 const int A_cols = A_MatData.
extent_int(D2_DIM);
1288 const int B_rows = B_MatData.
extent_int(D1_DIM);
1289 const int B_cols = B_MatData.
extent_int(D2_DIM);
1291 const int leftRows = transposeA ? A_cols : A_rows;
1292 const int leftCols = transposeA ? A_rows : A_cols;
1293 const int rightRows = transposeB ? B_cols : B_rows;
1294 const int rightCols = transposeB ? B_rows : B_cols;
1296 INTREPID2_TEST_FOR_EXCEPTION(leftCols != rightRows, std::invalid_argument,
"incompatible matrix dimensions");
1298 Kokkos::Array<int,7> resultExtents;
1299 Kokkos::Array<DataVariationType,7> resultVariationTypes;
1301 resultExtents[D1_DIM] = leftRows;
1302 resultExtents[D2_DIM] = rightCols;
1303 int resultBlockPlusDiagonalLastNonDiagonal = -1;
1307 resultVariationTypes[D1_DIM] = BLOCK_PLUS_DIAGONAL;
1308 resultVariationTypes[D2_DIM] = BLOCK_PLUS_DIAGONAL;
1312 const int resultRank = A_MatData.
rank();
1317 Kokkos::Array<int,7> resultActiveDims;
1318 Kokkos::Array<int,7> resultDataDims;
1319 int resultNumActiveDims = 0;
1321 for (
int i=0; i<resultRank-2; i++)
1327 const DataVariationType &A_VariationType = A_VariationTypes[i];
1328 const DataVariationType &B_VariationType = B_VariationTypes[i];
1335 DataVariationType resultVariationType;
1336 if ((A_VariationType == GENERAL) || (B_VariationType == GENERAL))
1338 resultVariationType = GENERAL;
1339 dataSize = resultExtents[i];
1341 else if ((B_VariationType == CONSTANT) && (A_VariationType == CONSTANT))
1343 resultVariationType = CONSTANT;
1346 else if ((B_VariationType == MODULAR) && (A_VariationType == CONSTANT))
1348 resultVariationType = MODULAR;
1351 else if ((B_VariationType == CONSTANT) && (A_VariationType == MODULAR))
1353 resultVariationType = MODULAR;
1362 resultVariationType = MODULAR;
1363 dataSize = A_Modulus;
1365 resultVariationTypes[i] = resultVariationType;
1367 if (resultVariationType != CONSTANT)
1369 resultActiveDims[resultNumActiveDims] = i;
1370 resultDataDims[resultNumActiveDims] = dataSize;
1371 resultNumActiveDims++;
1376 resultExtents[D1_DIM] = leftRows;
1377 resultExtents[D2_DIM] = rightCols;
1382 resultVariationTypes[D1_DIM] = BLOCK_PLUS_DIAGONAL;
1383 resultVariationTypes[D2_DIM] = BLOCK_PLUS_DIAGONAL;
1386 resultActiveDims[resultNumActiveDims] = resultRank - 2;
1388 const int numDiagonalEntries = leftRows - (resultBlockPlusDiagonalLastNonDiagonal + 1);
1389 const int numNondiagonalEntries = (resultBlockPlusDiagonalLastNonDiagonal + 1) * (resultBlockPlusDiagonalLastNonDiagonal + 1);
1391 resultDataDims[resultNumActiveDims] = numDiagonalEntries + numNondiagonalEntries;
1392 resultNumActiveDims++;
1397 resultVariationTypes[D1_DIM] = GENERAL;
1398 resultVariationTypes[D2_DIM] = GENERAL;
1400 resultActiveDims[resultNumActiveDims] = resultRank - 2;
1401 resultActiveDims[resultNumActiveDims+1] = resultRank - 1;
1403 resultDataDims[resultNumActiveDims] = leftRows;
1404 resultDataDims[resultNumActiveDims+1] = rightCols;
1405 resultNumActiveDims += 2;
1408 for (
int i=resultRank; i<7; i++)
1410 resultVariationTypes[i] = CONSTANT;
1411 resultExtents[i] = 1;
1414 ScalarView<DataScalar,DeviceType> data;
1416 if (resultNumActiveDims == 1)
1418 data = getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0]);
1420 else if (resultNumActiveDims == 2)
1422 data = getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1]);
1424 else if (resultNumActiveDims == 3)
1426 data = getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1], resultDataDims[2]);
1428 else if (resultNumActiveDims == 4)
1430 data = getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1], resultDataDims[2],
1433 else if (resultNumActiveDims == 5)
1435 data = getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1], resultDataDims[2],
1436 resultDataDims[3], resultDataDims[4]);
1438 else if (resultNumActiveDims == 6)
1440 data = getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1], resultDataDims[2],
1441 resultDataDims[3], resultDataDims[4], resultDataDims[5]);
1445 data = getMatchingViewWithLabel(viewToMatch,
"Data mat-mat result", resultDataDims[0], resultDataDims[1], resultDataDims[2],
1446 resultDataDims[3], resultDataDims[4], resultDataDims[5], resultDataDims[6]);
1462 const int resultRank = rank - numContractionDims;
1463 std::vector<DimensionInfo> dimInfo(resultRank);
1464 for (
int d=0; d<resultRank; d++)
1491 const int D1_DIM = matData.
rank() - 2;
1492 const int D2_DIM = matData.
rank() - 1;
1494 const int matRows = matData.
extent_int(D1_DIM);
1495 const int matCols = matData.
extent_int(D2_DIM);
1497 const int rows = transposeMatrix ? matCols : matRows;
1498 const int cols = transposeMatrix ? matRows : matCols;
1500 const int resultRank = vecData.
rank();
1504 Kokkos::Array<int,7> resultExtents;
1505 Kokkos::Array<DataVariationType,7> resultVariationTypes;
1509 Kokkos::Array<int,7> resultActiveDims;
1510 Kokkos::Array<int,7> resultDataDims;
1511 int resultNumActiveDims = 0;
1513 for (
int i=0; i<resultRank-1; i++)
1518 const DataVariationType &vecVariationType = vecVariationTypes[i];
1519 const DataVariationType &matVariationType = matVariationTypes[i];
1526 DataVariationType resultVariationType;
1527 if ((vecVariationType == GENERAL) || (matVariationType == GENERAL))
1529 resultVariationType = GENERAL;
1530 dataSize = resultExtents[i];
1532 else if ((matVariationType == CONSTANT) && (vecVariationType == CONSTANT))
1534 resultVariationType = CONSTANT;
1537 else if ((matVariationType == MODULAR) && (vecVariationType == CONSTANT))
1539 resultVariationType = MODULAR;
1542 else if ((matVariationType == CONSTANT) && (vecVariationType == MODULAR))
1544 resultVariationType = MODULAR;
1553 resultVariationType = MODULAR;
1554 dataSize = matModulus;
1556 resultVariationTypes[i] = resultVariationType;
1558 if (resultVariationType != CONSTANT)
1560 resultActiveDims[resultNumActiveDims] = i;
1561 resultDataDims[resultNumActiveDims] = dataSize;
1562 resultNumActiveDims++;
1567 resultActiveDims[resultNumActiveDims] = resultRank - 1;
1568 resultDataDims[resultNumActiveDims] = rows;
1569 resultNumActiveDims++;
1571 for (
int i=resultRank; i<7; i++)
1573 resultVariationTypes[i] = CONSTANT;
1574 resultExtents[i] = 1;
1576 resultVariationTypes[resultRank-1] = GENERAL;
1577 resultExtents[resultRank-1] = rows;
1579 ScalarView<DataScalar,DeviceType> data;
1580 if (resultNumActiveDims == 1)
1584 else if (resultNumActiveDims == 2)
1588 else if (resultNumActiveDims == 3)
1592 else if (resultNumActiveDims == 4)
1597 else if (resultNumActiveDims == 5)
1600 resultDataDims[3], resultDataDims[4]);
1602 else if (resultNumActiveDims == 6)
1605 resultDataDims[3], resultDataDims[4], resultDataDims[5]);
1610 resultDataDims[3], resultDataDims[4], resultDataDims[5], resultDataDims[6]);
1618 enable_if_t<(rank!=1) && (rank!=7), Kokkos::MDRangePolicy<typename DeviceType::execution_space,Kokkos::Rank<rank>> >
1621 using ExecutionSpace =
typename DeviceType::execution_space;
1622 Kokkos::Array<int,rank> startingOrdinals;
1623 Kokkos::Array<int,rank> extents;
1625 for (
int d=0; d<
rank; d++)
1627 startingOrdinals[d] = 0;
1630 auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<rank>>(startingOrdinals,extents);
1636 enable_if_t<rank==7, Kokkos::MDRangePolicy<typename DeviceType::execution_space,Kokkos::Rank<6>> >
1639 using ExecutionSpace =
typename DeviceType::execution_space;
1640 Kokkos::Array<int,6> startingOrdinals;
1641 Kokkos::Array<int,6> extents;
1643 for (
int d=0; d<6; d++)
1645 startingOrdinals[d] = 0;
1648 auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<6>>(startingOrdinals,extents);
1654 enable_if_t<rank==1, Kokkos::RangePolicy<typename DeviceType::execution_space> >
1657 using ExecutionSpace =
typename DeviceType::execution_space;
1658 Kokkos::RangePolicy<ExecutionSpace> policy(ExecutionSpace(),0,
getDataExtent(0));
1663 Data shallowCopy(
const int rank,
const Kokkos::Array<int,7> &extents,
const Kokkos::Array<DataVariationType,7> &variationTypes)
const
1667 case 1:
return Data(rank, get_fixed_view<View1>(underlyingView_), extents, variationTypes);
1668 case 2:
return Data(rank, get_fixed_view<View2>(underlyingView_), extents, variationTypes);
1669 case 3:
return Data(rank, get_fixed_view<View3>(underlyingView_), extents, variationTypes);
1670 case 4:
return Data(rank, get_fixed_view<View4>(underlyingView_), extents, variationTypes);
1671 case 5:
return Data(rank, get_fixed_view<View5>(underlyingView_), extents, variationTypes);
1672 case 6:
return Data(rank, get_fixed_view<View6>(underlyingView_), extents, variationTypes);
1673 case 7:
return Data(rank, get_fixed_view<View7>(underlyingView_), extents, variationTypes);
1675 INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
"Unhandled dataRank_");
1682 const int D_DIM = A.
rank() - 1;
1684 const int vectorComponents = A.
extent_int(D_DIM);
1689 using ExecutionSpace =
typename DeviceType::execution_space;
1693 Kokkos::parallel_for(
"compute dot product",
getDataExtent(0),
1694 KOKKOS_LAMBDA (
const int &pointOrdinal) {
1697 for (
int i=0; i<vectorComponents; i++)
1699 val += A(pointOrdinal,i) * B(pointOrdinal,i);
1703 else if (rank_ == 2)
1707 Kokkos::parallel_for(
"compute dot product", policy,
1708 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &pointOrdinal) {
1711 for (
int i=0; i<vectorComponents; i++)
1713 val += A(cellOrdinal,pointOrdinal,i) * B(cellOrdinal,pointOrdinal,i);
1717 else if (rank_ == 3)
1720 Kokkos::parallel_for(
"compute dot product", policy,
1721 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &pointOrdinal,
const int &d) {
1724 for (
int i=0; i<vectorComponents; i++)
1726 val += A(cellOrdinal,pointOrdinal,d,i) * B(cellOrdinal,pointOrdinal,d,i);
1738 template<
class BinaryOperator>
1775 const int D1_DIM = matData.
rank() - 2;
1776 const int D2_DIM = matData.
rank() - 1;
1778 const int matRows = matData.
extent_int(D1_DIM);
1779 const int matCols = matData.
extent_int(D2_DIM);
1781 const int rows = transposeMatrix ? matCols : matRows;
1782 const int cols = transposeMatrix ? matRows : matCols;
1787 using ExecutionSpace =
typename DeviceType::execution_space;
1793 Kokkos::parallel_for(
"compute mat-vec", policy,
1794 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &pointOrdinal,
const int &i) {
1797 for (
int j=0; j<cols; j++)
1799 const auto & mat_ij = transposeMatrix ? matData(cellOrdinal,pointOrdinal,j,i) : matData(cellOrdinal,pointOrdinal,i,j);
1800 val_i += mat_ij * vecData(cellOrdinal,pointOrdinal,j);
1804 else if (rank_ == 2)
1807 auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<2>>({0,0},{
getDataExtent(0),rows});
1808 Kokkos::parallel_for(
"compute mat-vec", policy,
1809 KOKKOS_LAMBDA (
const int &vectorOrdinal,
const int &i) {
1812 for (
int j=0; j<cols; j++)
1814 const auto & mat_ij = transposeMatrix ? matData(vectorOrdinal,j,i) : matData(vectorOrdinal,i,j);
1815 val_i += mat_ij * vecData(vectorOrdinal,j);
1819 else if (rank_ == 1)
1822 Kokkos::RangePolicy<ExecutionSpace> policy(0,rows);
1823 Kokkos::parallel_for(
"compute mat-vec", policy,
1824 KOKKOS_LAMBDA (
const int &i) {
1827 for (
int j=0; j<cols; j++)
1829 const auto & mat_ij = transposeMatrix ? matData(j,i) : matData(i,j);
1830 val_i += mat_ij * vecData(j);
1855 const int D1_DIM = A_MatData.
rank() - 2;
1856 const int D2_DIM = A_MatData.
rank() - 1;
1858 const int A_rows = A_MatData.
extent_int(D1_DIM);
1859 const int A_cols = A_MatData.
extent_int(D2_DIM);
1860 const int B_rows = B_MatData.
extent_int(D1_DIM);
1861 const int B_cols = B_MatData.
extent_int(D2_DIM);
1863 const int leftRows = transposeA ? A_cols : A_rows;
1864 const int leftCols = transposeA ? A_rows : A_cols;
1865 const int rightCols = transposeB ? B_rows : B_cols;
1867 #ifdef INTREPID2_HAVE_DEBUG
1868 const int rightRows = transposeB ? B_cols : B_rows;
1875 using ExecutionSpace =
typename DeviceType::execution_space;
1877 const int diagonalStart = (variationType_[D1_DIM] == BLOCK_PLUS_DIAGONAL) ? blockPlusDiagonalLastNonDiagonal_ + 1 : leftRows;
1882 auto policy = Kokkos::RangePolicy<ExecutionSpace>(0,
getDataExtent(0));
1883 Kokkos::parallel_for(
"compute mat-mat", policy,
1884 KOKKOS_LAMBDA (
const int &matrixOrdinal) {
1885 for (
int i=0; i<diagonalStart; i++)
1887 for (
int j=0; j<rightCols; j++)
1891 for (
int k=0; k<leftCols; k++)
1893 const auto & left = transposeA ? A_MatData(matrixOrdinal,k,i) : A_MatData(matrixOrdinal,i,k);
1894 const auto & right = transposeB ? B_MatData(matrixOrdinal,j,k) : B_MatData(matrixOrdinal,k,j);
1895 val_ij += left * right;
1899 for (
int i=diagonalStart; i<leftRows; i++)
1902 const auto & left = A_MatData(matrixOrdinal,i,i);
1903 const auto & right = B_MatData(matrixOrdinal,i,i);
1904 val_ii = left * right;
1908 else if (rank_ == 4)
1912 if (underlyingMatchesLogical_)
1914 Kokkos::parallel_for(
"compute mat-mat", policy,
1915 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &pointOrdinal) {
1916 for (
int i=0; i<leftRows; i++)
1918 for (
int j=0; j<rightCols; j++)
1922 for (
int k=0; k<leftCols; k++)
1924 const auto & left = transposeA ? A_MatData(cellOrdinal,pointOrdinal,k,i) : A_MatData(cellOrdinal,pointOrdinal,i,k);
1925 const auto & right = transposeB ? B_MatData(cellOrdinal,pointOrdinal,j,k) : B_MatData(cellOrdinal,pointOrdinal,k,j);
1926 val_ij += left * right;
1934 Kokkos::parallel_for(
"compute mat-mat", policy,
1935 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &pointOrdinal) {
1936 for (
int i=0; i<diagonalStart; i++)
1938 for (
int j=0; j<rightCols; j++)
1942 for (
int k=0; k<leftCols; k++)
1944 const auto & left = transposeA ? A_MatData(cellOrdinal,pointOrdinal,k,i) : A_MatData(cellOrdinal,pointOrdinal,i,k);
1945 const auto & right = transposeB ? B_MatData(cellOrdinal,pointOrdinal,j,k) : B_MatData(cellOrdinal,pointOrdinal,k,j);
1946 val_ij += left * right;
1950 for (
int i=diagonalStart; i<leftRows; i++)
1953 const auto & left = A_MatData(cellOrdinal,pointOrdinal,i,i);
1954 const auto & right = B_MatData(cellOrdinal,pointOrdinal,i,i);
1955 val_ii = left * right;
1968 KOKKOS_INLINE_FUNCTION constexpr
bool isValid()
const
1970 return extents_[0] > 0;
1974 KOKKOS_INLINE_FUNCTION
1986 void setExtent(
const ordinal_type &d,
const ordinal_type &newExtent)
1988 INTREPID2_TEST_FOR_EXCEPTION(variationType_[d] == BLOCK_PLUS_DIAGONAL, std::invalid_argument,
"setExtent is not supported for BLOCK_PLUS_DIAGONAL dimensions");
1990 if (variationType_[d] == MODULAR)
1992 bool dividesEvenly = ((newExtent / variationModulus_[d]) * variationModulus_[d] == newExtent);
1993 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");
1996 if ((newExtent != extents_[d]) && (variationType_[d] == GENERAL))
1999 std::vector<ordinal_type> newExtents(dataRank_,-1);
2000 for (
int r=0; r<dataRank_; r++)
2002 if (activeDims_[r] == d)
2005 newExtents[r] = newExtent;
2016 case 1: Kokkos::resize(std::get<View1>(underlyingView_),newExtents[0]);
2018 case 2: Kokkos::resize(std::get<View2>(underlyingView_),newExtents[0],newExtents[1]);
2020 case 3: Kokkos::resize(std::get<View3>(underlyingView_),newExtents[0],newExtents[1],newExtents[2]);
2022 case 4: Kokkos::resize(std::get<View4>(underlyingView_),newExtents[0],newExtents[1],newExtents[2],newExtents[3]);
2024 case 5: Kokkos::resize(std::get<View5>(underlyingView_),newExtents[0],newExtents[1],newExtents[2],newExtents[3],newExtents[4]);
2026 case 6: Kokkos::resize(std::get<View6>(underlyingView_),newExtents[0],newExtents[1],newExtents[2],newExtents[3],newExtents[4],newExtents[5]);
2028 case 7: Kokkos::resize(std::get<View7>(underlyingView_),newExtents[0],newExtents[1],newExtents[2],newExtents[3],newExtents[4],newExtents[5],newExtents[6]);
2030 default: INTREPID2_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Unexpected dataRank_ value");
2034 extents_[d] = newExtent;
2038 KOKKOS_INLINE_FUNCTION
2041 return underlyingMatchesLogical_;
2045 template<
class DataScalar,
typename DeviceType>
2046 KOKKOS_INLINE_FUNCTION constexpr
unsigned rank(
const Data<DataScalar, DeviceType>& D) {
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)...
void clear() const
Copies 0.0 to the underlying View.
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 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 ordinal_type getUnderlyingViewRank() const
returns the rank of the View that stores the unique data
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar *******, DeviceType > & getUnderlyingView7() const
returns the View that stores the unique data. For rank-7 underlying containers.
ScalarView< DataScalar, DeviceType > allocateDynRankViewMatchingUnderlying(DimArgs...dims) const
Returns a DynRankView that matches the underlying Kokkos::View object value_type and layout...
void applyOperator(UnaryOperator unaryOperator)
applies the specified unary operator to each entry
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.
void storeDotProduct(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B)
Places the result of a contraction along the final dimension of A and B into this data container...
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)
static Data< DataScalar, DeviceType > allocateMatVecResult(const Data< DataScalar, DeviceType > &matData, const Data< DataScalar, DeviceType > &vecData, const bool transposeMatrix=false)
void storeMatVec(const Data< DataScalar, DeviceType > &matData, const Data< DataScalar, DeviceType > &vecData, const bool transposeMatrix=false)
Places the result of a matrix-vector multiply corresponding to the two provided containers into this ...
Data(const unsigned rank, Kokkos::View< ViewScalar, DeviceType, ViewProperties...> data, Kokkos::Array< int, 7 > extents, Kokkos::Array< DataVariationType, 7 > variationType, const int blockPlusDiagonalLastNonDiagonal=-1)
constructor with run-time rank (requires full-length extents, variationType inputs; those beyond the ...
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...
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...
static void copyContainer(ToContainer to, FromContainer from)
Generic data copying method to allow construction of Data object from DynRankViews for which deep_cop...
#define INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(test, x, msg)
KOKKOS_INLINE_FUNCTION int getVariationModulus(const int &d) const
Variation modulus accessor.
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 Kokkos::View< DataScalar *****, DeviceType > & getUnderlyingView5() const
returns the View that stores the unique data. For rank-5 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...
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 Kokkos::Array< int, 7 > getExtents() const
Returns an array containing the logical extents in each dimension.
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar *, DeviceType > & getUnderlyingView1() const
returns the View that stores the unique data. For rank-1 underlying containers.
KOKKOS_INLINE_FUNCTION const Kokkos::Array< DataVariationType, 7 > & getVariationTypes() const
Returns an array with the variation types in each logical dimension.
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar ******, DeviceType > & getUnderlyingView6() const
returns the View that stores the unique data. For rank-6 underlying containers.
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...
Defines implementations for the Data class that are not present in the declaration.
KOKKOS_INLINE_FUNCTION bool underlyingMatchesLogical() const
Returns true if the underlying container has exactly the same rank and extents as the logical contain...
Wrapper around a Kokkos::View that allows data that is constant or repeating in various logical dimen...
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 isDiagonal() const
returns true for containers that have two dimensions marked as BLOCK_PLUS_DIAGONAL for which the non-...
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar ****, DeviceType > & getUnderlyingView4() const
returns the View that stores the unique data. For rank-4 underlying containers.
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 return_type getEntryWithPassThroughOption(const bool &passThroughBlockDiagonalArgs, const IntArgs &...intArgs) const
Returns a (read-only) value corresponding to the specified logical data location. If passThroughBlock...
Data shallowCopy(const int rank, const Kokkos::Array< int, 7 > &extents, const Kokkos::Array< DataVariationType, 7 > &variationTypes) const
Creates a new Data object with the same underlying view, but with the specified logical rank...
void storeInPlaceDifference(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B)
stores the in-place (entrywise) difference, A .- B, into this container.
Defines functors for use with Data objects: so far, we include simple arithmetical functors for sum...
KOKKOS_INLINE_FUNCTION DimensionInfo getDimensionInfo(const int &dim) const
Returns an object fully specifying the indicated dimension. This is used in determining appropriate s...
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar ***, DeviceType > & getUnderlyingView3() const
returns the View that stores the unique data. For rank-3 underlying containers.
Data(DataScalar constantValue, Kokkos::Array< int, rank > extents)
constructor for everywhere-constant data
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).
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.
Data< DataScalar, DeviceType > allocateConstantData(const DataScalar &value)
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 ...
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.
ScalarView< DataScalar, DeviceType > allocateDynRankViewMatchingUnderlying() const
Returns a DynRankView that matches the underlying Kokkos::View object in value_type, layout, and dimension.
void storeInPlaceQuotient(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B)
stores the in-place (entrywise) quotient, A ./ B, into this container.
static Data< DataScalar, DeviceType > allocateDotProductResult(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B)
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.
void storeMatMat(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
void allocateAndCopyFromDynRankView(ScalarView< DataScalar, DeviceType > data)
allocate an underlying View that matches the provided DynRankView in dimensions, and copy...
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==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...
void setActiveDims()
class initialization method. Called by constructors.
Data()
default constructor (empty data)
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 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 unsigned rank() const
Returns the logical rank of the Data container.
KOKKOS_INLINE_FUNCTION int extent_int(const int &r) const
Returns the logical extent in the specified dimension.
Defines DimensionInfo struct that allows specification of a dimension within a Data object...
Defines DataVariationType enum that specifies the types of variation possible within a Data object...
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...
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 int getUnderlyingViewExtent(const int &dim) const
Returns the extent of the underlying view in the specified dimension.
Data(ScalarView< DataScalar, DeviceType > data)
copy constructor modeled after the copy-like constructor above. Not as efficient as the implicit copy...
static Data< DataScalar, DeviceType > allocateContractionResult(const Data< DataScalar, DeviceType > &A, const Data< DataScalar, DeviceType > &B, const int &numContractionDims)
KOKKOS_INLINE_FUNCTION const int & blockPlusDiagonalLastNonDiagonal() const
For a Data object containing data with variation type BLOCK_PLUS_DIAGONAL, returns the row and column...
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 return_type getEntry(const IntArgs &...intArgs) const
Returns a (read-only) value corresponding to the specified logical data location. ...
static Data< DataScalar, DeviceType > allocateMatMatResult(const bool transposeA, const Data< DataScalar, DeviceType > &A_MatData, const bool transposeB, const Data< DataScalar, DeviceType > &B_MatData)
Data(const Data< DataScalar, OtherDeviceType > &data)
copy-like constructor for differing execution spaces. This does a deep_copy of the underlying view...