42 #ifndef SACADO_MP_VECTOR_HPP 43 #define SACADO_MP_VECTOR_HPP 47 #ifdef HAVE_STOKHOS_SACADO 50 #include <initializer_list> 52 #include "Kokkos_Macros.hpp" 56 #include "Sacado_Traits.hpp" 57 #include "Sacado_mpl_apply.hpp" 58 #include "Sacado_mpl_range_c.hpp" 94 typedef T derived_type;
101 KOKKOS_INLINE_FUNCTION
102 const derived_type& derived()
const {
103 return static_cast<const derived_type&
>(*this);
111 KOKKOS_INLINE_FUNCTION
112 const volatile derived_type& derived()
const volatile {
113 return static_cast<const volatile derived_type&
>(*this);
119 template <
typename Storage>
120 class Vector :
public Expr< Vector<Storage> > {
130 typedef typename storage_type::volatile_pointer volatile_pointer;
132 typedef typename storage_type::const_volatile_pointer const_volatile_pointer;
134 typedef typename storage_type::volatile_reference volatile_reference;
136 typedef typename storage_type::const_volatile_reference const_volatile_reference;
138 typedef typename execution_space::memory_space memory_space;
142 typedef typename ScalarType<value_type>::type
scalar_type;
144 typedef Vector base_expr_type;
147 template <
class NewStorageType >
149 typedef Vector< NewStorageType > type;
153 static const int num_args = 1;
155 #if STOKHOS_ALIGN_MEMORY 156 KOKKOS_INLINE_FUNCTION
157 static void*
operator new(std::size_t sz) {
158 return MemTraits::alloc(sz);
160 KOKKOS_INLINE_FUNCTION
161 static void*
operator new[](std::size_t sz) {
162 return MemTraits::alloc(sz);
164 KOKKOS_INLINE_FUNCTION
165 static void*
operator new(std::size_t sz,
void* ptr) {
168 KOKKOS_INLINE_FUNCTION
169 static void*
operator new[](std::size_t sz,
void* ptr) {
172 KOKKOS_INLINE_FUNCTION
173 static void operator delete(
void* ptr) {
174 MemTraits::free(ptr);
176 KOKKOS_INLINE_FUNCTION
177 static void operator delete[](
void* ptr) {
178 MemTraits::free(ptr);
180 KOKKOS_INLINE_FUNCTION
181 static void operator delete(
void* ptr,
void*) {
182 MemTraits::free(ptr);
184 KOKKOS_INLINE_FUNCTION
185 static void operator delete[](
void* ptr,
void*) {
186 MemTraits::free(ptr);
194 KOKKOS_DEFAULTED_FUNCTION
201 KOKKOS_INLINE_FUNCTION
209 KOKKOS_INLINE_FUNCTION
210 Vector(
ordinal_type sz, pointer v,
bool owned) : s(sz,v,owned) {}
216 KOKKOS_INLINE_FUNCTION
220 KOKKOS_INLINE_FUNCTION
224 KOKKOS_DEFAULTED_FUNCTION
225 Vector(
const Vector&
x) =
default;
228 KOKKOS_INLINE_FUNCTION
229 Vector(
const volatile Vector&
x) : s(
x.s) {}
232 template <
typename S>
233 KOKKOS_INLINE_FUNCTION
234 Vector(
const Expr<S>& xx) :
235 s(xx.derived().size()) {
236 typedef typename Expr<S>::derived_type expr_type;
237 const expr_type&
x = xx.derived();
240 if (s.size() !=
x.size())
244 if (
x.hasFastAccess(s.size())) {
245 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 248 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 249 #pragma vector aligned 251 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 255 s[i] =
x.fastAccessCoeff(i);
270 KOKKOS_INLINE_FUNCTION
271 Vector(std::initializer_list<value_type> l) : s(l.size(), l.begin()) {
272 if constexpr (Storage::is_static) {
277 Kokkos::abort(
"Size mismatch in list initialization of MP Vector with static fixed storage.");
288 KOKKOS_DEFAULTED_FUNCTION
292 KOKKOS_INLINE_FUNCTION
296 KOKKOS_INLINE_FUNCTION
297 void init(
const value_type& v)
volatile { s.init(v); }
300 KOKKOS_INLINE_FUNCTION
304 KOKKOS_INLINE_FUNCTION
305 void init(
const value_type* v)
volatile { s.init(v); }
308 template <
typename S>
309 KOKKOS_INLINE_FUNCTION
310 void init(
const Vector<S>& v) {
311 s.init(v.s.coeff(), v.s.size());
315 template <
typename S>
316 KOKKOS_INLINE_FUNCTION
317 void init(
const Vector<S>& v)
volatile {
318 s.init(v.s.coeff(), v.s.size());
322 KOKKOS_INLINE_FUNCTION
326 KOKKOS_INLINE_FUNCTION
327 void load(
value_type* v)
volatile { s.load(v); }
330 template <
typename S>
331 KOKKOS_INLINE_FUNCTION
332 void load(Vector<S>& v) { s.load(v.s.coeff()); }
335 template <
typename S>
336 KOKKOS_INLINE_FUNCTION
337 void load(Vector<S>& v)
volatile { s.load(v.s.coeff()); }
343 KOKKOS_INLINE_FUNCTION
347 if (sz == 1 && sz_new > sz)
356 KOKKOS_INLINE_FUNCTION
360 if (sz == 1 && sz_new > sz)
375 KOKKOS_INLINE_FUNCTION
376 void copyForWrite()
volatile { }
379 template <
typename S>
380 KOKKOS_INLINE_FUNCTION
381 bool isEqualTo(
const Expr<S>& xx)
const {
382 const typename Expr<S>::derived_type&
x = xx.derived();
383 typedef IsEqual<value_type> IE;
384 if (
x.size() != this->size())
return false;
387 eq = eq && IE::eval(
x.coeff(i), this->coeff(i));
392 template <
typename S>
393 KOKKOS_INLINE_FUNCTION
394 bool isEqualTo(
const Expr<S>& xx)
const volatile {
395 const typename Expr<S>::derived_type&
x = xx.derived();
396 typedef IsEqual<value_type> IE;
397 if (
x.size() != this->size())
return false;
400 eq = eq && IE::eval(
x.coeff(i), this->coeff(i));
413 Vector& operator=(std::initializer_list<value_type> l) {
417 s.init(l.begin(), lsz);
426 operator=(std::initializer_list<value_type> l)
volatile {
430 s.init(l.begin(), lsz);
431 return const_cast<Vector&
>(*this);
435 KOKKOS_INLINE_FUNCTION
442 KOKKOS_INLINE_FUNCTION
445 return const_cast<Vector&
>(*this);
449 KOKKOS_INLINE_FUNCTION
450 Vector& operator=(
const Vector&
x) {
464 if (s.size() >
x.s.size())
473 KOKKOS_INLINE_FUNCTION
474 Vector& operator=(
const volatile Vector&
x) {
488 if (s.size() >
x.s.size())
497 KOKKOS_INLINE_FUNCTION
498 Vector& operator=(
const Vector&
x)
volatile {
512 if (s.size() >
x.s.size())
517 return const_cast<Vector&
>(*this);
521 KOKKOS_INLINE_FUNCTION
522 Vector& operator=(
const volatile Vector&
x)
volatile {
536 if (s.size() >
x.s.size())
541 return const_cast<Vector&
>(*this);
545 template <
typename S>
546 KOKKOS_INLINE_FUNCTION
547 Vector& operator=(
const Expr<S>& xx) {
548 typedef typename Expr<S>::derived_type expr_type;
549 const expr_type&
x = xx.derived();
551 this->reset(
x.size());
554 if (s.size() !=
x.size())
558 if (
x.hasFastAccess(s.size())) {
559 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 562 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 563 #pragma vector aligned 565 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 569 s[i] =
x.fastAccessCoeff(i);
579 template <
typename S>
580 KOKKOS_INLINE_FUNCTION
581 Vector& operator=(
const Expr<S>& xx)
volatile {
582 typedef typename Expr<S>::derived_type expr_type;
583 const expr_type&
x = xx.derived();
585 this->reset(
x.size());
588 if (s.size() !=
x.size())
592 if (
x.hasFastAccess(s.size())) {
593 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 596 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 597 #pragma vector aligned 599 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 603 s[i] =
x.fastAccessCoeff(i);
609 return const_cast<Vector&
>(*this);
613 template<
typename S >
614 KOKKOS_INLINE_FUNCTION
615 typename std::enable_if<( ! std::is_same<S,void>::value &&
618 ::type
const &
operator = (
const Expr<S> & xx )
const 620 const typename Expr<S>::derived_type &
x = xx.derived();
622 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 625 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 626 #pragma vector aligned 628 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 631 for (
ordinal_type i = 0 ; i < s.size() ; ++i ) { s[i] =
x.coeff(i); }
637 template<
typename S >
638 KOKKOS_INLINE_FUNCTION
640 typename std::enable_if<( ! std::is_same<S,void>::value &&
643 ::type
const &
operator = (
const Expr<S> & xx )
const volatile 645 const typename Expr<S>::derived_type &
x = xx.derived();
647 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 650 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 651 #pragma vector aligned 653 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 656 for (
ordinal_type i = 0 ; i < s.size() ; ++i ) { s[i] =
x.coeff(i); }
667 KOKKOS_INLINE_FUNCTION
669 const volatile storage_type& storage()
const volatile {
return s; }
672 KOKKOS_INLINE_FUNCTION
676 KOKKOS_INLINE_FUNCTION
680 KOKKOS_INLINE_FUNCTION
689 KOKKOS_INLINE_FUNCTION
690 const_volatile_reference
val()
const volatile {
return s[0]; }
693 KOKKOS_INLINE_FUNCTION
694 const_reference
val()
const {
return s[0]; }
697 KOKKOS_INLINE_FUNCTION
698 volatile_reference
val()
volatile {
return s[0]; }
701 KOKKOS_INLINE_FUNCTION
702 reference
val() {
return s[0]; }
712 KOKKOS_INLINE_FUNCTION
716 KOKKOS_INLINE_FUNCTION
720 KOKKOS_INLINE_FUNCTION
721 bool hasFastAccess(
ordinal_type sz)
const {
return s.size()>=sz;}
724 KOKKOS_INLINE_FUNCTION
725 bool hasFastAccess(
ordinal_type sz)
const volatile {
return s.size()>=sz;}
728 KOKKOS_INLINE_FUNCTION
729 const_pointer coeff()
const {
return s.coeff();}
732 KOKKOS_INLINE_FUNCTION
733 const_volatile_pointer coeff()
const volatile {
return s.coeff();}
736 KOKKOS_INLINE_FUNCTION
737 volatile_pointer coeff()
volatile {
return s.coeff();}
740 KOKKOS_INLINE_FUNCTION
741 pointer coeff() {
return s.coeff();}
744 KOKKOS_INLINE_FUNCTION
746 return i<s.size() ? s[i] : s[0]; }
749 KOKKOS_INLINE_FUNCTION
751 return i<s.size() ? s[i] : s[0]; }
754 KOKKOS_INLINE_FUNCTION
756 return i<s.size() ? s[i] : s[0]; }
759 KOKKOS_INLINE_FUNCTION
761 return i<s.size() ? s[i] : s[0]; }
764 KOKKOS_INLINE_FUNCTION
769 KOKKOS_INLINE_FUNCTION
774 KOKKOS_INLINE_FUNCTION
779 KOKKOS_INLINE_FUNCTION
784 KOKKOS_INLINE_FUNCTION
785 const_volatile_reference operator[](
ordinal_type i)
const volatile {
789 KOKKOS_INLINE_FUNCTION
794 KOKKOS_INLINE_FUNCTION
795 volatile_reference operator[](
ordinal_type i)
volatile {
799 KOKKOS_INLINE_FUNCTION
804 KOKKOS_INLINE_FUNCTION
806 return s.template getCoeff<i>(); }
809 KOKKOS_INLINE_FUNCTION
811 return s.template getCoeff<i>(); }
814 KOKKOS_INLINE_FUNCTION
815 volatile_reference getCoeff()
volatile {
816 return s.template getCoeff<i>(); }
819 KOKKOS_INLINE_FUNCTION
820 reference getCoeff() {
821 return s.template getCoeff<i>(); }
824 KOKKOS_INLINE_FUNCTION
825 pointer begin() {
return s.coeff(); }
828 KOKKOS_INLINE_FUNCTION
829 const_pointer begin()
const {
return s.coeff(); }
832 KOKKOS_INLINE_FUNCTION
833 volatile_pointer begin()
volatile {
return s.coeff(); }
836 KOKKOS_INLINE_FUNCTION
837 const_volatile_pointer begin()
const volatile {
return s.coeff(); }
840 KOKKOS_INLINE_FUNCTION
841 const_pointer cbegin()
const {
return s.coeff(); }
844 KOKKOS_INLINE_FUNCTION
845 const_volatile_pointer cbegin()
const volatile {
return s.coeff(); }
848 KOKKOS_INLINE_FUNCTION
849 pointer end() {
return s.coeff() + s.size(); }
852 KOKKOS_INLINE_FUNCTION
853 const_pointer end()
const {
return s.coeff() + s.size(); }
856 KOKKOS_INLINE_FUNCTION
857 volatile_pointer end()
volatile {
return s.coeff() + s.size(); }
860 KOKKOS_INLINE_FUNCTION
861 const_volatile_pointer end()
const volatile {
return s.coeff() + s.size(); }
864 KOKKOS_INLINE_FUNCTION
865 const_pointer cend()
const {
return s.coeff()+ s.size(); }
868 KOKKOS_INLINE_FUNCTION
869 const_volatile_pointer cend()
const volatile {
return s.coeff()+ s.size(); }
879 KOKKOS_INLINE_FUNCTION
881 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 884 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 885 #pragma vector aligned 887 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 896 KOKKOS_INLINE_FUNCTION
897 Vector& operator += (
const volatile value_type&
x) {
898 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 901 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 902 #pragma vector aligned 904 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 913 KOKKOS_INLINE_FUNCTION
914 Vector& operator += (
const value_type&
x)
volatile {
915 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 918 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 919 #pragma vector aligned 921 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 926 return const_cast<Vector&
>(*this);
930 KOKKOS_INLINE_FUNCTION
931 Vector& operator += (
const volatile value_type&
x)
volatile {
932 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 935 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 936 #pragma vector aligned 938 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 943 return const_cast<Vector&
>(*this);
947 KOKKOS_INLINE_FUNCTION
949 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 952 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 953 #pragma vector aligned 955 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 964 KOKKOS_INLINE_FUNCTION
965 Vector& operator -= (
const volatile value_type&
x) {
966 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 969 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 970 #pragma vector aligned 972 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 981 KOKKOS_INLINE_FUNCTION
982 Vector& operator -= (
const value_type&
x)
volatile {
983 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 986 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 987 #pragma vector aligned 989 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 994 return const_cast<Vector&
>(*this);
998 KOKKOS_INLINE_FUNCTION
999 Vector& operator -= (
const volatile value_type&
x)
volatile {
1000 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1003 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1004 #pragma vector aligned 1006 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1011 return const_cast<Vector&
>(*this);
1015 KOKKOS_INLINE_FUNCTION
1017 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1020 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1021 #pragma vector aligned 1023 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1032 KOKKOS_INLINE_FUNCTION
1033 Vector& operator *= (
const volatile value_type&
x) {
1034 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1037 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1038 #pragma vector aligned 1040 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1049 KOKKOS_INLINE_FUNCTION
1050 Vector& operator *= (
const value_type&
x)
volatile {
1051 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1054 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1055 #pragma vector aligned 1057 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1062 return const_cast<Vector&
>(*this);
1066 KOKKOS_INLINE_FUNCTION
1067 Vector& operator *= (
const volatile value_type&
x)
volatile {
1068 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1071 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1072 #pragma vector aligned 1074 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1079 return const_cast<Vector&
>(*this);
1083 KOKKOS_INLINE_FUNCTION
1085 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1088 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1089 #pragma vector aligned 1091 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1100 KOKKOS_INLINE_FUNCTION
1101 Vector& operator /= (
const volatile value_type&
x) {
1102 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1105 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1106 #pragma vector aligned 1108 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1117 KOKKOS_INLINE_FUNCTION
1118 Vector& operator /= (
const value_type&
x)
volatile {
1119 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1122 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1123 #pragma vector aligned 1125 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1130 return const_cast<Vector&
>(*this);
1134 KOKKOS_INLINE_FUNCTION
1135 Vector& operator /= (
const volatile value_type&
x)
volatile {
1136 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1139 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1140 #pragma vector aligned 1142 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1147 return const_cast<Vector&
>(*this);
1151 template <
typename S>
1152 KOKKOS_INLINE_FUNCTION
1153 Vector& operator += (
const Expr<S>& xx) {
1155 typedef typename Expr<S>::derived_type expr_type;
1156 const expr_type&
x = xx.derived();
1158 if (
x.size() > s.size())
1159 this->reset(
x.size());
1161 #ifdef STOKHOS_DEBUG 1162 if (s.size() <
x.size())
1166 if (
x.hasFastAccess(s.size())) {
1167 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1170 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1171 #pragma vector aligned 1173 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1177 s[i] +=
x.fastAccessCoeff(i);
1187 template <
typename S>
1188 KOKKOS_INLINE_FUNCTION
1189 Vector& operator += (
const volatile Expr<S>& xx) {
1191 typedef typename Expr<S>::derived_type expr_type;
1192 const volatile expr_type&
x = xx.derived();
1194 if (
x.size() > s.size())
1195 this->reset(
x.size());
1197 #ifdef STOKHOS_DEBUG 1198 if (s.size() <
x.size())
1202 if (
x.hasFastAccess(s.size())) {
1203 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1206 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1207 #pragma vector aligned 1209 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1213 s[i] +=
x.fastAccessCoeff(i);
1223 template <
typename S>
1224 KOKKOS_INLINE_FUNCTION
1225 Vector& operator += (
const Expr<S>& xx)
volatile {
1227 typedef typename Expr<S>::derived_type expr_type;
1228 const expr_type&
x = xx.derived();
1230 if (
x.size() > s.size())
1231 this->reset(
x.size());
1233 #ifdef STOKHOS_DEBUG 1234 if (s.size() <
x.size())
1238 if (
x.hasFastAccess(s.size())) {
1239 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1242 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1243 #pragma vector aligned 1245 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1249 s[i] +=
x.fastAccessCoeff(i);
1255 return const_cast<Vector&
>(*this);
1259 template <
typename S>
1260 KOKKOS_INLINE_FUNCTION
1261 Vector& operator += (
const volatile Expr<S>& xx)
volatile {
1263 typedef typename Expr<S>::derived_type expr_type;
1264 const volatile expr_type&
x = xx.derived();
1266 if (
x.size() > s.size())
1267 this->reset(
x.size());
1269 #ifdef STOKHOS_DEBUG 1270 if (s.size() <
x.size())
1274 if (
x.hasFastAccess(s.size())) {
1275 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1278 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1279 #pragma vector aligned 1281 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1285 s[i] +=
x.fastAccessCoeff(i);
1291 return const_cast<Vector&
>(*this);
1295 template <
typename S>
1296 KOKKOS_INLINE_FUNCTION
1297 Vector& operator -= (
const Expr<S>& xx) {
1299 typedef typename Expr<S>::derived_type expr_type;
1300 const expr_type&
x = xx.derived();
1302 if (
x.size() > s.size())
1303 this->reset(
x.size());
1305 #ifdef STOKHOS_DEBUG 1306 if (s.size() <
x.size())
1310 if (
x.hasFastAccess(s.size())) {
1311 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1314 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1315 #pragma vector aligned 1317 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1321 s[i] -=
x.fastAccessCoeff(i);
1331 template <
typename S>
1332 KOKKOS_INLINE_FUNCTION
1333 Vector& operator -= (
const volatile Expr<S>& xx) {
1335 typedef typename Expr<S>::derived_type expr_type;
1336 const volatile expr_type&
x = xx.derived();
1338 if (
x.size() > s.size())
1339 this->reset(
x.size());
1341 #ifdef STOKHOS_DEBUG 1342 if (s.size() <
x.size())
1346 if (
x.hasFastAccess(s.size())) {
1347 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1350 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1351 #pragma vector aligned 1353 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1357 s[i] -=
x.fastAccessCoeff(i);
1367 template <
typename S>
1368 KOKKOS_INLINE_FUNCTION
1369 Vector& operator -= (
const Expr<S>& xx)
volatile {
1371 typedef typename Expr<S>::derived_type expr_type;
1372 const expr_type&
x = xx.derived();
1374 if (
x.size() > s.size())
1375 this->reset(
x.size());
1377 #ifdef STOKHOS_DEBUG 1378 if (s.size() <
x.size())
1382 if (
x.hasFastAccess(s.size())) {
1383 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1386 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1387 #pragma vector aligned 1389 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1393 s[i] -=
x.fastAccessCoeff(i);
1399 return const_cast<Vector&
>(*this);
1403 template <
typename S>
1404 KOKKOS_INLINE_FUNCTION
1405 Vector& operator -= (
const volatile Expr<S>& xx)
volatile {
1407 typedef typename Expr<S>::derived_type expr_type;
1408 const volatile expr_type&
x = xx.derived();
1410 if (
x.size() > s.size())
1411 this->reset(
x.size());
1413 #ifdef STOKHOS_DEBUG 1414 if (s.size() <
x.size())
1418 if (
x.hasFastAccess(s.size())) {
1419 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1422 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1423 #pragma vector aligned 1425 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1429 s[i] -=
x.fastAccessCoeff(i);
1435 return const_cast<Vector&
>(*this);
1439 template <
typename S>
1440 KOKKOS_INLINE_FUNCTION
1441 Vector& operator *= (
const Expr<S>& xx) {
1443 typedef typename Expr<S>::derived_type expr_type;
1444 const expr_type&
x = xx.derived();
1446 if (
x.size() > s.size())
1447 this->reset(
x.size());
1449 #ifdef STOKHOS_DEBUG 1450 if (s.size() <
x.size())
1454 if (
x.hasFastAccess(s.size())) {
1455 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1458 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1459 #pragma vector aligned 1461 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1465 s[i] *=
x.fastAccessCoeff(i);
1475 template <
typename S>
1476 KOKKOS_INLINE_FUNCTION
1477 Vector& operator *= (
const volatile Expr<S>& xx) {
1479 typedef typename Expr<S>::derived_type expr_type;
1480 const volatile expr_type&
x = xx.derived();
1482 if (
x.size() > s.size())
1483 this->reset(
x.size());
1485 #ifdef STOKHOS_DEBUG 1486 if (s.size() <
x.size())
1490 if (
x.hasFastAccess(s.size())) {
1491 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1494 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1495 #pragma vector aligned 1497 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1501 s[i] *=
x.fastAccessCoeff(i);
1511 template <
typename S>
1512 KOKKOS_INLINE_FUNCTION
1513 Vector& operator *= (
const Expr<S>& xx)
volatile {
1515 typedef typename Expr<S>::derived_type expr_type;
1516 const expr_type&
x = xx.derived();
1518 if (
x.size() > s.size())
1519 this->reset(
x.size());
1521 #ifdef STOKHOS_DEBUG 1522 if (s.size() <
x.size())
1526 if (
x.hasFastAccess(s.size())) {
1527 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1530 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1531 #pragma vector aligned 1533 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1537 s[i] *=
x.fastAccessCoeff(i);
1543 return const_cast<Vector&
>(*this);
1547 template <
typename S>
1548 KOKKOS_INLINE_FUNCTION
1549 Vector& operator *= (
const volatile Expr<S>& xx)
volatile {
1551 typedef typename Expr<S>::derived_type expr_type;
1552 const volatile expr_type&
x = xx.derived();
1554 if (
x.size() > s.size())
1555 this->reset(
x.size());
1557 #ifdef STOKHOS_DEBUG 1558 if (s.size() <
x.size())
1562 if (
x.hasFastAccess(s.size())) {
1563 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1566 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1567 #pragma vector aligned 1569 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1573 s[i] *=
x.fastAccessCoeff(i);
1579 return const_cast<Vector&
>(*this);
1583 template <
typename S>
1584 KOKKOS_INLINE_FUNCTION
1585 Vector& operator /= (
const Expr<S>& xx) {
1587 typedef typename Expr<S>::derived_type expr_type;
1588 const expr_type&
x = xx.derived();
1590 if (
x.size() > s.size())
1591 this->reset(
x.size());
1593 #ifdef STOKHOS_DEBUG 1594 if (s.size() <
x.size())
1598 if (
x.hasFastAccess(s.size())) {
1599 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1602 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1603 #pragma vector aligned 1605 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1609 s[i] /=
x.fastAccessCoeff(i);
1619 template <
typename S>
1620 KOKKOS_INLINE_FUNCTION
1621 Vector& operator /= (
const volatile Expr<S>& xx) {
1623 typedef typename Expr<S>::derived_type expr_type;
1624 const volatile expr_type&
x = xx.derived();
1626 if (
x.size() > s.size())
1627 this->reset(
x.size());
1629 #ifdef STOKHOS_DEBUG 1630 if (s.size() <
x.size())
1634 if (
x.hasFastAccess(s.size())) {
1635 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1638 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1639 #pragma vector aligned 1641 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1645 s[i] /=
x.fastAccessCoeff(i);
1655 template <
typename S>
1656 KOKKOS_INLINE_FUNCTION
1657 Vector& operator /= (
const Expr<S>& xx)
volatile {
1659 typedef typename Expr<S>::derived_type expr_type;
1660 const expr_type&
x = xx.derived();
1662 if (
x.size() > s.size())
1663 this->reset(
x.size());
1665 #ifdef STOKHOS_DEBUG 1666 if (s.size() <
x.size())
1670 if (
x.hasFastAccess(s.size())) {
1671 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1674 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1675 #pragma vector aligned 1677 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1681 s[i] /=
x.fastAccessCoeff(i);
1687 return const_cast<Vector&
>(*this);
1691 template <
typename S>
1692 KOKKOS_INLINE_FUNCTION
1693 Vector& operator /= (
const volatile Expr<S>& xx)
volatile {
1695 typedef typename Expr<S>::derived_type expr_type;
1696 const volatile expr_type&
x = xx.derived();
1698 if (
x.size() > s.size())
1699 this->reset(
x.size());
1701 #ifdef STOKHOS_DEBUG 1702 if (s.size() <
x.size())
1706 if (
x.hasFastAccess(s.size())) {
1707 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1710 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 1711 #pragma vector aligned 1713 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1717 s[i] /=
x.fastAccessCoeff(i);
1723 return const_cast<Vector&
>(*this);
1727 KOKKOS_INLINE_FUNCTION
1728 Vector& operator++() {
1735 KOKKOS_INLINE_FUNCTION
1736 volatile Vector& operator++()
volatile {
1743 KOKKOS_INLINE_FUNCTION
1744 Vector operator++(
int) {
1751 KOKKOS_INLINE_FUNCTION
1752 Vector operator++(
int)
volatile {
1759 KOKKOS_INLINE_FUNCTION
1760 Vector& operator--() {
1767 KOKKOS_INLINE_FUNCTION
1768 volatile Vector& operator--()
volatile {
1775 KOKKOS_INLINE_FUNCTION
1776 Vector operator--(
int) {
1783 KOKKOS_INLINE_FUNCTION
1784 Vector operator--(
int)
volatile {
1792 KOKKOS_INLINE_FUNCTION
1793 std::string name()
const volatile {
return "x"; }
1799 template <
typename expr_type>
1804 KOKKOS_INLINE_FUNCTION
1805 StaticOp(
storage_type& s_,
const expr_type& x_) : s(s_),
x(x_) {}
1807 template <
typename ArgT>
1808 KOKKOS_INLINE_FUNCTION
1809 void operator() (ArgT arg)
const {
1810 const int Arg = ArgT::value;
1811 s.template getCoeff<Arg>() =
x.template getCoeff<Arg>();
1820 #if STOKHOS_USE_MP_VECTOR_SFS_SPEC 1832 template <
typename T>
struct const_expr_ref {
1833 typedef const T type;
1841 template <
typename S>
struct const_expr_ref< Vector<S> > {
1842 typedef const Vector<S>& type;
1850 template <
typename S>
struct const_expr_ref< volatile Vector<S> > {
1851 typedef const volatile Vector<S>& type;
1855 template <
typename T>
struct remove_volatile {
1858 template <
typename T>
struct remove_volatile<volatile T> {
1863 template <
typename T>
struct add_volatile {
1864 typedef volatile T type;
1866 template <
typename T>
struct add_volatile<volatile T> {
1867 typedef volatile T type;
1870 template <
typename Storage>
1872 operator << (std::ostream& os, const Vector<Storage>& a)
1879 os << a.coeff(i) <<
" ";
1886 template <
typename Storage>
1888 operator << (std::ostream& os, const volatile Vector<Storage>& a)
1895 os << a.coeff(i) <<
" ";
1902 template <
typename Storage>
1904 operator >> (std::istream& is, Vector<Storage>& a)
1914 if (Storage::is_static) {
1917 is >> a.fastAccessCoeff(i);
1922 std::vector<value_type> c;
1925 while (is >> b && b !=
']') {
1933 a.fastAccessCoeff(i) = c[i];
1943 template <
unsigned Size = 0>
1944 struct VectorPartition {
1945 static const unsigned PartitionSize = Size;
1949 template<
typename iType0 ,
typename iType1 >
1950 KOKKOS_INLINE_FUNCTION
1951 VectorPartition(
const iType0 & i0 ,
const iType1 & i1 ) :
1952 begin(i0), end(i1) {
1956 template <
typename T>
1957 struct is_vector_partition {
1958 static const bool value =
false;
1961 template <
unsigned Size>
1962 struct is_vector_partition< VectorPartition<Size> > {
1963 static const bool value =
true;
1968 template <
typename T>
1969 struct IsExpr< MP::Expr<T> > {
1970 static const bool value =
true;
1973 template <
typename T>
1974 struct BaseExprType< MP::Expr<T> > {
1975 typedef typename MP::Expr<T>::derived_type derived_type;
1976 typedef typename derived_type::base_expr_type type;
1979 template <
typename S>
1980 struct IsExpr< MP::Vector<S> > {
1981 static const bool value =
true;
1984 template <
typename S>
1985 struct BaseExprType< MP::Vector<S> > {
1986 typedef MP::Vector<S> type;
1990 template <
typename T>
struct is_mp_vector {
1991 static const bool value =
false;
1993 template <
typename S>
struct is_mp_vector< MP::Vector<S> > {
1994 static const bool value =
true;
1996 template <
typename T>
struct is_mp_vector< const T > {
1997 static const bool value = is_mp_vector<T>::value;
1999 template <
typename T>
struct is_mp_vector< T* > {
2000 static const bool value = is_mp_vector<T>::value;
2002 template <
typename T>
struct is_mp_vector< T[] > {
2003 static const bool value = is_mp_vector<T>::value;
2005 template <
typename T,
unsigned N>
struct is_mp_vector< T[N] > {
2006 static const bool value = is_mp_vector<T>::value;
2010 template <
typename Storage>
2018 if (sz == 1)
return true;
2023 if (
x.fastAccessCoeff(i) !=
val)
return false;
2033 #if STOKHOS_ALIGN_MEMORY 2039 template <
typename Storage>
2040 class allocator<
Sacado::MP::Vector< Storage > >
2046 typedef typename Base::pointer pointer;
2047 typedef typename Base::const_pointer const_pointer;
2048 typedef typename Base::reference reference;
2049 typedef typename Base::const_reference const_reference;
2050 typedef typename Base::size_type size_type;
2051 typedef typename Base::difference_type difference_type;
2053 template <
class U>
struct rebind {
typedef allocator<U> other; };
2055 template <
class U> allocator(
const allocator<U>&) {}
2058 template <
typename Storage>
2059 class allocator< const
Sacado::MP::Vector< Storage > >
2065 typedef typename Base::pointer pointer;
2066 typedef typename Base::const_pointer const_pointer;
2067 typedef typename Base::reference reference;
2068 typedef typename Base::const_reference const_reference;
2069 typedef typename Base::size_type size_type;
2070 typedef typename Base::difference_type difference_type;
2072 template <
class U>
struct rebind {
typedef allocator<U> other; };
2074 template <
class U> allocator(
const allocator<U>&) {}
2081 #include "Kokkos_NumericTraits.hpp" 2085 template <
typename Storage>
2086 struct reduction_identity<
Sacado::MP::Vector<Storage> > {
2089 typedef reduction_identity<scalar> RIS;
2090 KOKKOS_FORCEINLINE_FUNCTION constexpr
static Vector
sum() {
2093 KOKKOS_FORCEINLINE_FUNCTION constexpr
static Vector prod() {
2094 return Vector(RIS::prod());
2096 KOKKOS_FORCEINLINE_FUNCTION constexpr
static Vector
max() {
2099 KOKKOS_FORCEINLINE_FUNCTION constexpr
static Vector
min() {
2105 template <
typename Storage>
2106 struct promote<
Sacado::MP::Vector<Storage>,false> {
2113 #endif // HAVE_STOKHOS_SACADO 2115 #endif // SACADO_MP_VECTOR_HPP
An aligned STL allocator.
Stokhos::StandardStorage< int, double > storage_type
const double & const_reference
Kokkos::DefaultExecutionSpace execution_space
expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 c fastAccessCoeff(j) - expr2.val(j)
KOKKOS_INLINE_FUNCTION void raise_error(const char *msg)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< RD, RP... > >::value &&Kokkos::is_view_uq_pce< Kokkos::View< XD, XP... > >::value >::type sum(const Kokkos::View< RD, RP... > &r, const Kokkos::View< XD, XP... > &x)
KOKKOS_INLINE_FUNCTION PCE< Storage > min(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
std::istream & operator>>(std::istream &is, PCE< Storage > &a)
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
const double * const_pointer
KOKKOS_INLINE_FUNCTION PCE< Storage > max(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
Traits class encapsulting memory alignment.
An aligned STL allocator.
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)