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" 67 #if defined(__INTEL_COMPILER) && ! defined(__CUDA_ARCH__) 68 #define STOKHOS_HAVE_PRAGMA_IVDEP 72 #if 0 && ( defined(__INTEL_COMPILER) || defined(__CUDA_ARCH__) ) 73 #define STOKHOS_HAVE_PRAGMA_UNROLL 104 typedef T derived_type;
111 KOKKOS_INLINE_FUNCTION
112 const derived_type& derived()
const {
113 return static_cast<const derived_type&
>(*this);
121 KOKKOS_INLINE_FUNCTION
122 const volatile derived_type& derived()
const volatile {
123 return static_cast<const volatile derived_type&
>(*this);
129 template <
typename Storage>
130 class Vector :
public Expr< Vector<Storage> > {
140 typedef typename storage_type::volatile_pointer volatile_pointer;
142 typedef typename storage_type::const_volatile_pointer const_volatile_pointer;
144 typedef typename storage_type::volatile_reference volatile_reference;
146 typedef typename storage_type::const_volatile_reference const_volatile_reference;
148 typedef typename execution_space::memory_space memory_space;
152 typedef typename ScalarType<value_type>::type
scalar_type;
154 typedef Vector base_expr_type;
157 template <
class NewStorageType >
159 typedef Vector< NewStorageType > type;
163 static const int num_args = 1;
165 #if STOKHOS_ALIGN_MEMORY 166 KOKKOS_INLINE_FUNCTION
167 static void*
operator new(std::size_t sz) {
168 return MemTraits::alloc(sz);
170 KOKKOS_INLINE_FUNCTION
171 static void*
operator new[](std::size_t sz) {
172 return MemTraits::alloc(sz);
174 KOKKOS_INLINE_FUNCTION
175 static void*
operator new(std::size_t sz,
void* ptr) {
178 KOKKOS_INLINE_FUNCTION
179 static void*
operator new[](std::size_t sz,
void* ptr) {
182 KOKKOS_INLINE_FUNCTION
183 static void operator delete(
void* ptr) {
184 MemTraits::free(ptr);
186 KOKKOS_INLINE_FUNCTION
187 static void operator delete[](
void* ptr) {
188 MemTraits::free(ptr);
190 KOKKOS_INLINE_FUNCTION
191 static void operator delete(
void* ptr,
void*) {
192 MemTraits::free(ptr);
194 KOKKOS_INLINE_FUNCTION
195 static void operator delete[](
void* ptr,
void*) {
196 MemTraits::free(ptr);
204 KOKKOS_INLINE_FUNCTION
211 KOKKOS_INLINE_FUNCTION
219 KOKKOS_INLINE_FUNCTION
220 Vector(
ordinal_type sz, pointer v,
bool owned) : s(sz,v,owned) {}
226 KOKKOS_INLINE_FUNCTION
230 KOKKOS_INLINE_FUNCTION
234 KOKKOS_INLINE_FUNCTION
235 Vector(
const Vector&
x) =
default;
238 KOKKOS_INLINE_FUNCTION
239 Vector(
const volatile Vector&
x) : s(
x.s) {}
242 template <
typename S>
243 KOKKOS_INLINE_FUNCTION
244 Vector(
const Expr<S>& xx) :
245 s(xx.derived().size()) {
246 typedef typename Expr<S>::derived_type expr_type;
247 const expr_type&
x = xx.derived();
250 if (s.size() !=
x.size())
254 if (
x.hasFastAccess(s.size())) {
255 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 258 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 262 s[i] =
x.fastAccessCoeff(i);
274 Vector(std::initializer_list<value_type> l) : s(l.size(), l.begin()) {}
277 KOKKOS_INLINE_FUNCTION
281 KOKKOS_INLINE_FUNCTION
285 KOKKOS_INLINE_FUNCTION
286 void init(
const value_type& v)
volatile { s.init(v); }
289 KOKKOS_INLINE_FUNCTION
293 KOKKOS_INLINE_FUNCTION
294 void init(
const value_type* v)
volatile { s.init(v); }
297 template <
typename S>
298 KOKKOS_INLINE_FUNCTION
299 void init(
const Vector<S>& v) {
300 s.init(v.s.coeff(), v.s.size());
304 template <
typename S>
305 KOKKOS_INLINE_FUNCTION
306 void init(
const Vector<S>& v)
volatile {
307 s.init(v.s.coeff(), v.s.size());
311 KOKKOS_INLINE_FUNCTION
315 KOKKOS_INLINE_FUNCTION
316 void load(
value_type* v)
volatile { s.load(v); }
319 template <
typename S>
320 KOKKOS_INLINE_FUNCTION
321 void load(Vector<S>& v) { s.load(v.s.coeff()); }
324 template <
typename S>
325 KOKKOS_INLINE_FUNCTION
326 void load(Vector<S>& v)
volatile { s.load(v.s.coeff()); }
332 KOKKOS_INLINE_FUNCTION
336 if (sz == 1 && sz_new > sz)
345 KOKKOS_INLINE_FUNCTION
349 if (sz == 1 && sz_new > sz)
364 KOKKOS_INLINE_FUNCTION
365 void copyForWrite()
volatile { }
368 template <
typename S>
369 KOKKOS_INLINE_FUNCTION
370 bool isEqualTo(
const Expr<S>& xx)
const {
371 const typename Expr<S>::derived_type&
x = xx.derived();
372 typedef IsEqual<value_type> IE;
373 if (
x.size() != this->size())
return false;
376 eq = eq && IE::eval(
x.coeff(i), this->coeff(i));
381 template <
typename S>
382 KOKKOS_INLINE_FUNCTION
383 bool isEqualTo(
const Expr<S>& xx)
const volatile {
384 const typename Expr<S>::derived_type&
x = xx.derived();
385 typedef IsEqual<value_type> IE;
386 if (
x.size() != this->size())
return false;
389 eq = eq && IE::eval(
x.coeff(i), this->coeff(i));
402 Vector& operator=(std::initializer_list<value_type> l) {
406 s.init(l.begin(), lsz);
415 operator=(std::initializer_list<value_type> l)
volatile {
419 s.init(l.begin(), lsz);
420 return const_cast<Vector&
>(*this);
424 KOKKOS_INLINE_FUNCTION
431 KOKKOS_INLINE_FUNCTION
434 return const_cast<Vector&
>(*this);
438 KOKKOS_INLINE_FUNCTION
439 Vector& operator=(
const Vector&
x) {
453 if (s.size() >
x.s.size())
462 KOKKOS_INLINE_FUNCTION
463 Vector& operator=(
const volatile Vector&
x) {
477 if (s.size() >
x.s.size())
486 KOKKOS_INLINE_FUNCTION
487 Vector& operator=(
const Vector&
x)
volatile {
501 if (s.size() >
x.s.size())
506 return const_cast<Vector&
>(*this);
510 KOKKOS_INLINE_FUNCTION
511 Vector& operator=(
const volatile Vector&
x)
volatile {
525 if (s.size() >
x.s.size())
530 return const_cast<Vector&
>(*this);
534 template <
typename S>
535 KOKKOS_INLINE_FUNCTION
536 Vector& operator=(
const Expr<S>& xx) {
537 typedef typename Expr<S>::derived_type expr_type;
538 const expr_type&
x = xx.derived();
540 this->reset(
x.size());
543 if (s.size() !=
x.size())
547 if (
x.hasFastAccess(s.size())) {
548 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 551 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 555 s[i] =
x.fastAccessCoeff(i);
565 template <
typename S>
566 KOKKOS_INLINE_FUNCTION
567 Vector& operator=(
const Expr<S>& xx)
volatile {
568 typedef typename Expr<S>::derived_type expr_type;
569 const expr_type&
x = xx.derived();
571 this->reset(
x.size());
574 if (s.size() !=
x.size())
578 if (
x.hasFastAccess(s.size())) {
579 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 582 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 586 s[i] =
x.fastAccessCoeff(i);
592 return const_cast<Vector&
>(*this);
596 template<
typename S >
597 KOKKOS_INLINE_FUNCTION
598 typename Kokkos::Impl::enable_if<( ! Kokkos::Impl::is_same<S,void>::value &&
601 ::type
const &
operator = (
const Expr<S> & xx )
const 603 const typename Expr<S>::derived_type &
x = xx.derived();
605 for (
ordinal_type i = 0 ; i < s.size() ; ++i ) { s[i] =
x.coeff(i); }
611 template<
typename S >
612 KOKKOS_INLINE_FUNCTION
614 typename Kokkos::Impl::enable_if<( ! Kokkos::Impl::is_same<S,void>::value &&
617 ::type
const &
operator = (
const Expr<S> & xx )
const volatile 619 const typename Expr<S>::derived_type &
x = xx.derived();
621 for (
ordinal_type i = 0 ; i < s.size() ; ++i ) { s[i] =
x.coeff(i); }
632 KOKKOS_INLINE_FUNCTION
634 const volatile storage_type& storage()
const volatile {
return s; }
637 KOKKOS_INLINE_FUNCTION
641 KOKKOS_INLINE_FUNCTION
645 KOKKOS_INLINE_FUNCTION
654 KOKKOS_INLINE_FUNCTION
655 const_volatile_reference
val()
const volatile {
return s[0]; }
658 KOKKOS_INLINE_FUNCTION
659 const_reference
val()
const {
return s[0]; }
662 KOKKOS_INLINE_FUNCTION
663 volatile_reference
val()
volatile {
return s[0]; }
666 KOKKOS_INLINE_FUNCTION
667 reference
val() {
return s[0]; }
677 KOKKOS_INLINE_FUNCTION
681 KOKKOS_INLINE_FUNCTION
685 KOKKOS_INLINE_FUNCTION
686 bool hasFastAccess(
ordinal_type sz)
const {
return s.size()>=sz;}
689 KOKKOS_INLINE_FUNCTION
690 bool hasFastAccess(
ordinal_type sz)
const volatile {
return s.size()>=sz;}
693 KOKKOS_INLINE_FUNCTION
694 const_pointer coeff()
const {
return s.coeff();}
697 KOKKOS_INLINE_FUNCTION
698 const_volatile_pointer coeff()
const volatile {
return s.coeff();}
701 KOKKOS_INLINE_FUNCTION
702 volatile_pointer coeff()
volatile {
return s.coeff();}
705 KOKKOS_INLINE_FUNCTION
706 pointer coeff() {
return s.coeff();}
709 KOKKOS_INLINE_FUNCTION
711 return i<s.size() ? s[i] : s[0]; }
714 KOKKOS_INLINE_FUNCTION
716 return i<s.size() ? s[i] : s[0]; }
719 KOKKOS_INLINE_FUNCTION
721 return i<s.size() ? s[i] : s[0]; }
724 KOKKOS_INLINE_FUNCTION
726 return i<s.size() ? s[i] : s[0]; }
729 KOKKOS_INLINE_FUNCTION
730 const_volatile_reference fastAccessCoeff(
ordinal_type i)
const volatile {
734 KOKKOS_INLINE_FUNCTION
739 KOKKOS_INLINE_FUNCTION
740 volatile_reference fastAccessCoeff(
ordinal_type i)
volatile {
744 KOKKOS_INLINE_FUNCTION
749 KOKKOS_INLINE_FUNCTION
751 return s.template getCoeff<i>(); }
754 KOKKOS_INLINE_FUNCTION
756 return s.template getCoeff<i>(); }
759 KOKKOS_INLINE_FUNCTION
760 volatile_reference getCoeff()
volatile {
761 return s.template getCoeff<i>(); }
764 KOKKOS_INLINE_FUNCTION
765 reference getCoeff() {
766 return s.template getCoeff<i>(); }
769 KOKKOS_INLINE_FUNCTION
770 pointer begin() {
return s.coeff(); }
773 KOKKOS_INLINE_FUNCTION
774 const_pointer begin()
const {
return s.coeff(); }
777 KOKKOS_INLINE_FUNCTION
778 volatile_pointer begin()
volatile {
return s.coeff(); }
781 KOKKOS_INLINE_FUNCTION
782 const_volatile_pointer begin()
const volatile {
return s.coeff(); }
785 KOKKOS_INLINE_FUNCTION
786 const_pointer cbegin()
const {
return s.coeff(); }
789 KOKKOS_INLINE_FUNCTION
790 const_volatile_pointer cbegin()
const volatile {
return s.coeff(); }
793 KOKKOS_INLINE_FUNCTION
794 pointer end() {
return s.coeff() + s.size(); }
797 KOKKOS_INLINE_FUNCTION
798 const_pointer end()
const {
return s.coeff() + s.size(); }
801 KOKKOS_INLINE_FUNCTION
802 volatile_pointer end()
volatile {
return s.coeff() + s.size(); }
805 KOKKOS_INLINE_FUNCTION
806 const_volatile_pointer end()
const volatile {
return s.coeff() + s.size(); }
809 KOKKOS_INLINE_FUNCTION
810 const_pointer cend()
const {
return s.coeff()+ s.size(); }
813 KOKKOS_INLINE_FUNCTION
814 const_volatile_pointer cend()
const volatile {
return s.coeff()+ s.size(); }
824 KOKKOS_INLINE_FUNCTION
832 KOKKOS_INLINE_FUNCTION
833 Vector& operator += (
const volatile value_type&
x) {
840 KOKKOS_INLINE_FUNCTION
841 Vector& operator += (
const value_type&
x)
volatile {
844 return const_cast<Vector&
>(*this);
848 KOKKOS_INLINE_FUNCTION
849 Vector& operator += (
const volatile value_type&
x)
volatile {
852 return const_cast<Vector&
>(*this);
856 KOKKOS_INLINE_FUNCTION
864 KOKKOS_INLINE_FUNCTION
865 Vector& operator -= (
const volatile value_type&
x) {
872 KOKKOS_INLINE_FUNCTION
873 Vector& operator -= (
const value_type&
x)
volatile {
876 return const_cast<Vector&
>(*this);
880 KOKKOS_INLINE_FUNCTION
881 Vector& operator -= (
const volatile value_type&
x)
volatile {
884 return const_cast<Vector&
>(*this);
888 KOKKOS_INLINE_FUNCTION
896 KOKKOS_INLINE_FUNCTION
897 Vector& operator *= (
const volatile value_type&
x) {
904 KOKKOS_INLINE_FUNCTION
905 Vector& operator *= (
const value_type&
x)
volatile {
908 return const_cast<Vector&
>(*this);
912 KOKKOS_INLINE_FUNCTION
913 Vector& operator *= (
const volatile value_type&
x)
volatile {
916 return const_cast<Vector&
>(*this);
920 KOKKOS_INLINE_FUNCTION
928 KOKKOS_INLINE_FUNCTION
929 Vector& operator /= (
const volatile value_type&
x) {
936 KOKKOS_INLINE_FUNCTION
937 Vector& operator /= (
const value_type&
x)
volatile {
940 return const_cast<Vector&
>(*this);
944 KOKKOS_INLINE_FUNCTION
945 Vector& operator /= (
const volatile value_type&
x)
volatile {
948 return const_cast<Vector&
>(*this);
952 template <
typename S>
953 KOKKOS_INLINE_FUNCTION
954 Vector& operator += (
const Expr<S>& xx) {
956 typedef typename Expr<S>::derived_type expr_type;
957 const expr_type&
x = xx.derived();
959 if (
x.size() > s.size())
960 this->reset(
x.size());
963 if (s.size() <
x.size())
967 if (
x.hasFastAccess(s.size())) {
968 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 971 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 975 s[i] +=
x.fastAccessCoeff(i);
985 template <
typename S>
986 KOKKOS_INLINE_FUNCTION
987 Vector& operator += (
const volatile Expr<S>& xx) {
989 typedef typename Expr<S>::derived_type expr_type;
990 const volatile expr_type&
x = xx.derived();
992 if (
x.size() > s.size())
993 this->reset(
x.size());
996 if (s.size() <
x.size())
1000 if (
x.hasFastAccess(s.size())) {
1001 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1004 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1008 s[i] +=
x.fastAccessCoeff(i);
1018 template <
typename S>
1019 KOKKOS_INLINE_FUNCTION
1020 Vector& operator += (
const Expr<S>& xx)
volatile {
1022 typedef typename Expr<S>::derived_type expr_type;
1023 const expr_type&
x = xx.derived();
1025 if (
x.size() > s.size())
1026 this->reset(
x.size());
1028 #ifdef STOKHOS_DEBUG 1029 if (s.size() <
x.size())
1033 if (
x.hasFastAccess(s.size())) {
1034 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1037 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1041 s[i] +=
x.fastAccessCoeff(i);
1047 return const_cast<Vector&
>(*this);
1051 template <
typename S>
1052 KOKKOS_INLINE_FUNCTION
1053 Vector& operator += (
const volatile Expr<S>& xx)
volatile {
1055 typedef typename Expr<S>::derived_type expr_type;
1056 const volatile expr_type&
x = xx.derived();
1058 if (
x.size() > s.size())
1059 this->reset(
x.size());
1061 #ifdef STOKHOS_DEBUG 1062 if (s.size() <
x.size())
1066 if (
x.hasFastAccess(s.size())) {
1067 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1070 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1074 s[i] +=
x.fastAccessCoeff(i);
1080 return const_cast<Vector&
>(*this);
1084 template <
typename S>
1085 KOKKOS_INLINE_FUNCTION
1086 Vector& operator -= (
const Expr<S>& xx) {
1088 typedef typename Expr<S>::derived_type expr_type;
1089 const expr_type&
x = xx.derived();
1091 if (
x.size() > s.size())
1092 this->reset(
x.size());
1094 #ifdef STOKHOS_DEBUG 1095 if (s.size() <
x.size())
1099 if (
x.hasFastAccess(s.size())) {
1100 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1103 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1107 s[i] -=
x.fastAccessCoeff(i);
1117 template <
typename S>
1118 KOKKOS_INLINE_FUNCTION
1119 Vector& operator -= (
const volatile Expr<S>& xx) {
1121 typedef typename Expr<S>::derived_type expr_type;
1122 const volatile expr_type&
x = xx.derived();
1124 if (
x.size() > s.size())
1125 this->reset(
x.size());
1127 #ifdef STOKHOS_DEBUG 1128 if (s.size() <
x.size())
1132 if (
x.hasFastAccess(s.size())) {
1133 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1136 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1140 s[i] -=
x.fastAccessCoeff(i);
1150 template <
typename S>
1151 KOKKOS_INLINE_FUNCTION
1152 Vector& operator -= (
const Expr<S>& xx)
volatile {
1154 typedef typename Expr<S>::derived_type expr_type;
1155 const expr_type&
x = xx.derived();
1157 if (
x.size() > s.size())
1158 this->reset(
x.size());
1160 #ifdef STOKHOS_DEBUG 1161 if (s.size() <
x.size())
1165 if (
x.hasFastAccess(s.size())) {
1166 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1169 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1173 s[i] -=
x.fastAccessCoeff(i);
1179 return const_cast<Vector&
>(*this);
1183 template <
typename S>
1184 KOKKOS_INLINE_FUNCTION
1185 Vector& operator -= (
const volatile Expr<S>& xx)
volatile {
1187 typedef typename Expr<S>::derived_type expr_type;
1188 const volatile expr_type&
x = xx.derived();
1190 if (
x.size() > s.size())
1191 this->reset(
x.size());
1193 #ifdef STOKHOS_DEBUG 1194 if (s.size() <
x.size())
1198 if (
x.hasFastAccess(s.size())) {
1199 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1202 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1206 s[i] -=
x.fastAccessCoeff(i);
1212 return const_cast<Vector&
>(*this);
1216 template <
typename S>
1217 KOKKOS_INLINE_FUNCTION
1218 Vector& operator *= (
const Expr<S>& xx) {
1220 typedef typename Expr<S>::derived_type expr_type;
1221 const expr_type&
x = xx.derived();
1223 if (
x.size() > s.size())
1224 this->reset(
x.size());
1226 #ifdef STOKHOS_DEBUG 1227 if (s.size() <
x.size())
1231 if (
x.hasFastAccess(s.size())) {
1232 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1235 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1239 s[i] *=
x.fastAccessCoeff(i);
1249 template <
typename S>
1250 KOKKOS_INLINE_FUNCTION
1251 Vector& operator *= (
const volatile Expr<S>& xx) {
1253 typedef typename Expr<S>::derived_type expr_type;
1254 const volatile expr_type&
x = xx.derived();
1256 if (
x.size() > s.size())
1257 this->reset(
x.size());
1259 #ifdef STOKHOS_DEBUG 1260 if (s.size() <
x.size())
1264 if (
x.hasFastAccess(s.size())) {
1265 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1268 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1272 s[i] *=
x.fastAccessCoeff(i);
1282 template <
typename S>
1283 KOKKOS_INLINE_FUNCTION
1284 Vector& operator *= (
const Expr<S>& xx)
volatile {
1286 typedef typename Expr<S>::derived_type expr_type;
1287 const expr_type&
x = xx.derived();
1289 if (
x.size() > s.size())
1290 this->reset(
x.size());
1292 #ifdef STOKHOS_DEBUG 1293 if (s.size() <
x.size())
1297 if (
x.hasFastAccess(s.size())) {
1298 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1301 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1305 s[i] *=
x.fastAccessCoeff(i);
1311 return const_cast<Vector&
>(*this);
1315 template <
typename S>
1316 KOKKOS_INLINE_FUNCTION
1317 Vector& operator *= (
const volatile Expr<S>& xx)
volatile {
1319 typedef typename Expr<S>::derived_type expr_type;
1320 const volatile expr_type&
x = xx.derived();
1322 if (
x.size() > s.size())
1323 this->reset(
x.size());
1325 #ifdef STOKHOS_DEBUG 1326 if (s.size() <
x.size())
1330 if (
x.hasFastAccess(s.size())) {
1331 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1334 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1338 s[i] *=
x.fastAccessCoeff(i);
1344 return const_cast<Vector&
>(*this);
1348 template <
typename S>
1349 KOKKOS_INLINE_FUNCTION
1350 Vector& operator /= (
const Expr<S>& xx) {
1352 typedef typename Expr<S>::derived_type expr_type;
1353 const expr_type&
x = xx.derived();
1355 if (
x.size() > s.size())
1356 this->reset(
x.size());
1358 #ifdef STOKHOS_DEBUG 1359 if (s.size() <
x.size())
1363 if (
x.hasFastAccess(s.size())) {
1364 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1367 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1371 s[i] /=
x.fastAccessCoeff(i);
1381 template <
typename S>
1382 KOKKOS_INLINE_FUNCTION
1383 Vector& operator /= (
const volatile Expr<S>& xx) {
1385 typedef typename Expr<S>::derived_type expr_type;
1386 const volatile expr_type&
x = xx.derived();
1388 if (
x.size() > s.size())
1389 this->reset(
x.size());
1391 #ifdef STOKHOS_DEBUG 1392 if (s.size() <
x.size())
1396 if (
x.hasFastAccess(s.size())) {
1397 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1400 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1404 s[i] /=
x.fastAccessCoeff(i);
1414 template <
typename S>
1415 KOKKOS_INLINE_FUNCTION
1416 Vector& operator /= (
const Expr<S>& xx)
volatile {
1418 typedef typename Expr<S>::derived_type expr_type;
1419 const expr_type&
x = xx.derived();
1421 if (
x.size() > s.size())
1422 this->reset(
x.size());
1424 #ifdef STOKHOS_DEBUG 1425 if (s.size() <
x.size())
1429 if (
x.hasFastAccess(s.size())) {
1430 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1433 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1437 s[i] /=
x.fastAccessCoeff(i);
1443 return const_cast<Vector&
>(*this);
1447 template <
typename S>
1448 KOKKOS_INLINE_FUNCTION
1449 Vector& operator /= (
const volatile Expr<S>& xx)
volatile {
1451 typedef typename Expr<S>::derived_type expr_type;
1452 const volatile expr_type&
x = xx.derived();
1454 if (
x.size() > s.size())
1455 this->reset(
x.size());
1457 #ifdef STOKHOS_DEBUG 1458 if (s.size() <
x.size())
1462 if (
x.hasFastAccess(s.size())) {
1463 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 1466 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 1470 s[i] /=
x.fastAccessCoeff(i);
1476 return const_cast<Vector&
>(*this);
1480 KOKKOS_INLINE_FUNCTION
1481 Vector& operator++() {
1488 KOKKOS_INLINE_FUNCTION
1489 volatile Vector& operator++()
volatile {
1496 KOKKOS_INLINE_FUNCTION
1497 Vector operator++(
int) {
1504 KOKKOS_INLINE_FUNCTION
1505 Vector operator++(
int)
volatile {
1512 KOKKOS_INLINE_FUNCTION
1513 Vector& operator--() {
1520 KOKKOS_INLINE_FUNCTION
1521 volatile Vector& operator--()
volatile {
1528 KOKKOS_INLINE_FUNCTION
1529 Vector operator--(
int) {
1536 KOKKOS_INLINE_FUNCTION
1537 Vector operator--(
int)
volatile {
1545 KOKKOS_INLINE_FUNCTION
1546 std::string name()
const volatile {
return "x"; }
1552 template <
typename expr_type>
1557 KOKKOS_INLINE_FUNCTION
1558 StaticOp(
storage_type& s_,
const expr_type& x_) : s(s_),
x(x_) {}
1560 template <
typename ArgT>
1561 KOKKOS_INLINE_FUNCTION
1562 void operator() (ArgT arg)
const {
1563 const int Arg = ArgT::value;
1564 s.template getCoeff<Arg>() =
x.template getCoeff<Arg>();
1576 template <
typename T>
struct const_expr_ref {
1577 typedef const T type;
1585 template <
typename S>
struct const_expr_ref< Vector<S> > {
1586 typedef const Vector<S>& type;
1594 template <
typename S>
struct const_expr_ref< volatile Vector<S> > {
1595 typedef const volatile Vector<S>& type;
1599 template <
typename T>
struct remove_volatile {
1602 template <
typename T>
struct remove_volatile<volatile T> {
1607 template <
typename T>
struct add_volatile {
1608 typedef volatile T type;
1610 template <
typename T>
struct add_volatile<volatile T> {
1611 typedef volatile T type;
1614 template <
typename Storage>
1616 operator << (std::ostream& os, const volatile Vector<Storage>& a)
1623 os << a.coeff(i) <<
" ";
1630 template <
typename Storage>
1632 operator >> (std::istream& is, Vector<Storage>& a)
1642 if (Storage::is_static) {
1645 is >> a.fastAccessCoeff(i);
1650 std::vector<value_type> c;
1653 while (is >> b && b !=
']') {
1661 a.fastAccessCoeff(i) = c[i];
1671 template <
unsigned Size = 0>
1672 struct VectorPartition {
1673 static const unsigned PartitionSize = Size;
1677 template<
typename iType0 ,
typename iType1 >
1678 KOKKOS_INLINE_FUNCTION
1679 VectorPartition(
const iType0 & i0 ,
const iType1 & i1 ) :
1680 begin(i0), end(i1) {
1684 template <
typename T>
1685 struct is_vector_partition {
1686 static const bool value =
false;
1689 template <
unsigned Size>
1690 struct is_vector_partition< VectorPartition<Size> > {
1691 static const bool value =
true;
1696 template <
typename T>
1697 struct IsExpr< MP::Expr<T> > {
1698 static const bool value =
true;
1701 template <
typename T>
1702 struct BaseExprType< MP::Expr<T> > {
1703 typedef typename MP::Expr<T>::derived_type derived_type;
1704 typedef typename derived_type::base_expr_type type;
1707 template <
typename S>
1708 struct IsExpr< MP::Vector<S> > {
1709 static const bool value =
true;
1712 template <
typename S>
1713 struct BaseExprType< MP::Vector<S> > {
1714 typedef MP::Vector<S> type;
1718 template <
typename T>
struct is_mp_vector {
1719 static const bool value =
false;
1721 template <
typename S>
struct is_mp_vector< MP::Vector<S> > {
1722 static const bool value =
true;
1724 template <
typename T>
struct is_mp_vector< const T > {
1725 static const bool value = is_mp_vector<T>::value;
1727 template <
typename T>
struct is_mp_vector< T* > {
1728 static const bool value = is_mp_vector<T>::value;
1730 template <
typename T>
struct is_mp_vector< T[] > {
1731 static const bool value = is_mp_vector<T>::value;
1733 template <
typename T,
unsigned N>
struct is_mp_vector< T[N] > {
1734 static const bool value = is_mp_vector<T>::value;
1738 template <
typename Storage>
1746 if (sz == 1)
return true;
1751 if (
x.fastAccessCoeff(i) !=
val)
return false;
1760 #if STOKHOS_ALIGN_MEMORY 1766 template <
typename Storage>
1767 class allocator<
Sacado::MP::Vector< Storage > >
1773 typedef typename Base::pointer pointer;
1774 typedef typename Base::const_pointer const_pointer;
1775 typedef typename Base::reference reference;
1776 typedef typename Base::const_reference const_reference;
1777 typedef typename Base::size_type size_type;
1778 typedef typename Base::difference_type difference_type;
1780 template <
class U>
struct rebind {
typedef allocator<U> other; };
1782 template <
class U> allocator(
const allocator<U>&) {}
1785 template <
typename Storage>
1786 class allocator< const
Sacado::MP::Vector< Storage > >
1792 typedef typename Base::pointer pointer;
1793 typedef typename Base::const_pointer const_pointer;
1794 typedef typename Base::reference reference;
1795 typedef typename Base::const_reference const_reference;
1796 typedef typename Base::size_type size_type;
1797 typedef typename Base::difference_type difference_type;
1799 template <
class U>
struct rebind {
typedef allocator<U> other; };
1801 template <
class U> allocator(
const allocator<U>&) {}
1808 #endif // HAVE_STOKHOS_SACADO 1812 #endif // SACADO_MP_VECTOR_HPP
An aligned STL allocator.
Stokhos::StandardStorage< int, double > storage_type
const double & const_reference
Kokkos::DefaultExecutionSpace execution_space
KOKKOS_INLINE_FUNCTION void raise_error(const char *msg)
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
Traits class encapsulting memory alignment.
An aligned STL allocator.
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)