42 #ifndef SACADO_MP_VECTOR_SFS_HPP 43 #define SACADO_MP_VECTOR_SFS_HPP 47 #ifdef HAVE_STOKHOS_SACADO 57 template <
typename ordinal_t,
typename value_t,
int Num,
typename device_t>
58 class Vector<
Stokhos::StaticFixedStorage<ordinal_t,value_t,Num,device_t> >{
69 typedef typename storage_type::volatile_pointer volatile_pointer;
71 typedef typename storage_type::const_volatile_pointer const_volatile_pointer;
73 typedef typename storage_type::volatile_reference volatile_reference;
75 typedef typename storage_type::const_volatile_reference const_volatile_reference;
77 typedef typename execution_space::memory_space memory_space;
81 typedef typename ScalarType<value_type>::type
scalar_type;
84 template <
class NewStorageType >
86 typedef Vector< NewStorageType > type;
90 static const int num_args = 1;
92 #if STOKHOS_ALIGN_MEMORY 93 KOKKOS_INLINE_FUNCTION
94 static void*
operator new(std::size_t sz) {
95 return MemTraits::alloc(sz);
97 KOKKOS_INLINE_FUNCTION
98 static void*
operator new[](std::size_t sz) {
99 return MemTraits::alloc(sz);
101 KOKKOS_INLINE_FUNCTION
102 static void*
operator new(std::size_t sz,
void* ptr) {
105 KOKKOS_INLINE_FUNCTION
106 static void*
operator new[](std::size_t sz,
void* ptr) {
109 KOKKOS_INLINE_FUNCTION
110 static void operator delete(
void* ptr) {
111 MemTraits::free(ptr);
113 KOKKOS_INLINE_FUNCTION
114 static void operator delete[](
void* ptr) {
115 MemTraits::free(ptr);
117 KOKKOS_INLINE_FUNCTION
118 static void operator delete(
void* ptr,
void*) {
119 MemTraits::free(ptr);
121 KOKKOS_INLINE_FUNCTION
122 static void operator delete[](
void* ptr,
void*) {
123 MemTraits::free(ptr);
131 KOKKOS_INLINE_FUNCTION
138 KOKKOS_INLINE_FUNCTION
146 KOKKOS_INLINE_FUNCTION
147 Vector(
ordinal_type sz, pointer v,
bool owned) : s(sz,v,owned) {}
153 KOKKOS_INLINE_FUNCTION
157 KOKKOS_INLINE_FUNCTION
161 KOKKOS_INLINE_FUNCTION
162 Vector(
const Vector&
x) : s(
x.s) {}
165 KOKKOS_INLINE_FUNCTION
166 Vector(
const volatile Vector&
x) : s(
x.s) {}
172 Vector(std::initializer_list<value_type> l) : s(l.size(), l.begin()) {}
175 KOKKOS_INLINE_FUNCTION
179 KOKKOS_INLINE_FUNCTION
183 KOKKOS_INLINE_FUNCTION
184 void init(
const value_type& v)
volatile { s.init(v); }
187 KOKKOS_INLINE_FUNCTION
191 KOKKOS_INLINE_FUNCTION
192 void init(
const value_type* v)
volatile { s.init(v); }
195 template <
typename S>
196 KOKKOS_INLINE_FUNCTION
197 void init(
const Vector<S>& v) {
198 s.init(v.s.coeff(), v.s.size());
202 template <
typename S>
203 KOKKOS_INLINE_FUNCTION
204 void init(
const Vector<S>& v)
volatile {
205 s.init(v.s.coeff(), v.s.size());
209 KOKKOS_INLINE_FUNCTION
213 KOKKOS_INLINE_FUNCTION
214 void load(
value_type* v)
volatile { s.load(v); }
217 template <
typename S>
218 KOKKOS_INLINE_FUNCTION
219 void load(Vector<S>& v) { s.load(v.s.coeff()); }
222 template <
typename S>
223 KOKKOS_INLINE_FUNCTION
224 void load(Vector<S>& v)
volatile { s.load(v.s.coeff()); }
230 KOKKOS_INLINE_FUNCTION
237 KOKKOS_INLINE_FUNCTION
250 KOKKOS_INLINE_FUNCTION
251 void copyForWrite()
volatile { }
254 KOKKOS_INLINE_FUNCTION
255 bool isEqualTo(
const Vector&
x)
const {
256 typedef IsEqual<value_type> IE;
259 eq = eq && IE::eval(
x.coeff(i), this->coeff(i));
264 KOKKOS_INLINE_FUNCTION
265 bool isEqualTo(
const Vector&
x)
const volatile {
266 typedef IsEqual<value_type> IE;
269 eq = eq && IE::eval(
x.coeff(i), this->coeff(i));
279 KOKKOS_INLINE_FUNCTION
286 KOKKOS_INLINE_FUNCTION
289 return const_cast<Vector&
>(*this);
293 KOKKOS_INLINE_FUNCTION
294 Vector& operator=(
const Vector&
x) {
303 KOKKOS_INLINE_FUNCTION
304 Vector& operator=(
const volatile Vector&
x) {
313 KOKKOS_INLINE_FUNCTION
314 Vector& operator=(
const Vector&
x)
volatile {
319 return const_cast<Vector&
>(*this);
323 KOKKOS_INLINE_FUNCTION
324 Vector& operator=(
const volatile Vector&
x)
volatile {
329 return const_cast<Vector&
>(*this);
338 KOKKOS_INLINE_FUNCTION
340 const volatile storage_type& storage()
const volatile {
return s; }
343 KOKKOS_INLINE_FUNCTION
347 KOKKOS_INLINE_FUNCTION
351 KOKKOS_INLINE_FUNCTION
360 KOKKOS_INLINE_FUNCTION
361 const_volatile_reference
val()
const volatile {
return s[0]; }
364 KOKKOS_INLINE_FUNCTION
365 const_reference
val()
const {
return s[0]; }
368 KOKKOS_INLINE_FUNCTION
369 volatile_reference
val()
volatile {
return s[0]; }
372 KOKKOS_INLINE_FUNCTION
373 reference
val() {
return s[0]; }
383 KOKKOS_INLINE_FUNCTION
387 KOKKOS_INLINE_FUNCTION
388 static bool hasFastAccess(
ordinal_type sz) {
return true; }
391 KOKKOS_INLINE_FUNCTION
392 const_pointer coeff()
const {
return s.coeff();}
395 KOKKOS_INLINE_FUNCTION
396 const_volatile_pointer coeff()
const volatile {
return s.coeff();}
399 KOKKOS_INLINE_FUNCTION
400 volatile_pointer coeff()
volatile {
return s.coeff();}
403 KOKKOS_INLINE_FUNCTION
404 pointer coeff() {
return s.coeff();}
407 KOKKOS_INLINE_FUNCTION
411 KOKKOS_INLINE_FUNCTION
415 KOKKOS_INLINE_FUNCTION
419 KOKKOS_INLINE_FUNCTION
423 KOKKOS_INLINE_FUNCTION
428 KOKKOS_INLINE_FUNCTION
433 KOKKOS_INLINE_FUNCTION
438 KOKKOS_INLINE_FUNCTION
443 KOKKOS_INLINE_FUNCTION
444 const_volatile_reference operator[](
ordinal_type i)
const volatile {
448 KOKKOS_INLINE_FUNCTION
453 KOKKOS_INLINE_FUNCTION
454 volatile_reference operator[](
ordinal_type i)
volatile {
458 KOKKOS_INLINE_FUNCTION
463 KOKKOS_INLINE_FUNCTION
465 return s.template getCoeff<i>(); }
468 KOKKOS_INLINE_FUNCTION
470 return s.template getCoeff<i>(); }
473 KOKKOS_INLINE_FUNCTION
474 volatile_reference getCoeff()
volatile {
475 return s.template getCoeff<i>(); }
478 KOKKOS_INLINE_FUNCTION
479 reference getCoeff() {
480 return s.template getCoeff<i>(); }
483 KOKKOS_INLINE_FUNCTION
484 pointer begin() {
return s.coeff(); }
487 KOKKOS_INLINE_FUNCTION
488 const_pointer begin()
const {
return s.coeff(); }
491 KOKKOS_INLINE_FUNCTION
492 volatile_pointer begin()
volatile {
return s.coeff(); }
495 KOKKOS_INLINE_FUNCTION
496 const_volatile_pointer begin()
const volatile {
return s.coeff(); }
499 KOKKOS_INLINE_FUNCTION
500 const_pointer cbegin()
const {
return s.coeff(); }
503 KOKKOS_INLINE_FUNCTION
504 const_volatile_pointer cbegin()
const volatile {
return s.coeff(); }
507 KOKKOS_INLINE_FUNCTION
508 pointer end() {
return s.coeff() + s.size(); }
511 KOKKOS_INLINE_FUNCTION
512 const_pointer end()
const {
return s.coeff() + s.size(); }
515 KOKKOS_INLINE_FUNCTION
516 volatile_pointer end()
volatile {
return s.coeff() + s.size(); }
519 KOKKOS_INLINE_FUNCTION
520 const_volatile_pointer end()
const volatile {
return s.coeff() + s.size(); }
523 KOKKOS_INLINE_FUNCTION
524 const_pointer cend()
const {
return s.coeff()+ s.size(); }
527 KOKKOS_INLINE_FUNCTION
528 const_volatile_pointer cend()
const volatile {
return s.coeff()+ s.size(); }
538 KOKKOS_INLINE_FUNCTION
540 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 543 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 544 #pragma vector aligned 546 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 555 KOKKOS_INLINE_FUNCTION
556 Vector& operator += (
const volatile value_type&
x) {
557 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 560 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 561 #pragma vector aligned 563 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 572 KOKKOS_INLINE_FUNCTION
573 Vector& operator += (
const value_type&
x)
volatile {
574 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 577 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 578 #pragma vector aligned 580 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 585 return const_cast<Vector&
>(*this);
589 KOKKOS_INLINE_FUNCTION
590 Vector& operator += (
const volatile value_type&
x)
volatile {
591 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 594 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 595 #pragma vector aligned 597 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 602 return const_cast<Vector&
>(*this);
606 KOKKOS_INLINE_FUNCTION
608 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 611 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 612 #pragma vector aligned 614 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 623 KOKKOS_INLINE_FUNCTION
624 Vector& operator -= (
const volatile value_type&
x) {
625 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 628 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 629 #pragma vector aligned 631 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 640 KOKKOS_INLINE_FUNCTION
641 Vector& operator -= (
const value_type&
x)
volatile {
642 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 645 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 646 #pragma vector aligned 648 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 653 return const_cast<Vector&
>(*this);
657 KOKKOS_INLINE_FUNCTION
658 Vector& operator -= (
const volatile value_type&
x)
volatile {
659 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 662 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 663 #pragma vector aligned 665 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 670 return const_cast<Vector&
>(*this);
674 KOKKOS_INLINE_FUNCTION
676 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 679 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 680 #pragma vector aligned 682 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 691 KOKKOS_INLINE_FUNCTION
692 Vector& operator *= (
const volatile value_type&
x) {
693 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 696 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 697 #pragma vector aligned 699 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 708 KOKKOS_INLINE_FUNCTION
709 Vector& operator *= (
const value_type&
x)
volatile {
710 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 713 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 714 #pragma vector aligned 716 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 721 return const_cast<Vector&
>(*this);
725 KOKKOS_INLINE_FUNCTION
726 Vector& operator *= (
const volatile value_type&
x)
volatile {
727 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 730 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 731 #pragma vector aligned 733 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 738 return const_cast<Vector&
>(*this);
742 KOKKOS_INLINE_FUNCTION
744 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 747 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 748 #pragma vector aligned 750 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 759 KOKKOS_INLINE_FUNCTION
760 Vector& operator /= (
const volatile value_type&
x) {
761 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 764 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 765 #pragma vector aligned 767 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 776 KOKKOS_INLINE_FUNCTION
777 Vector& operator /= (
const value_type&
x)
volatile {
778 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 781 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 782 #pragma vector aligned 784 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 789 return const_cast<Vector&
>(*this);
793 KOKKOS_INLINE_FUNCTION
794 Vector& operator /= (
const volatile value_type&
x)
volatile {
795 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 798 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 799 #pragma vector aligned 801 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 806 return const_cast<Vector&
>(*this);
810 KOKKOS_INLINE_FUNCTION
811 Vector& operator += (
const Vector&
x) {
812 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP 815 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 816 #pragma vector aligned 818 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL 822 s[i] +=
x.fastAccessCoeff(i);
827 KOKKOS_INLINE_FUNCTION
828 Vector& operator += (
const volatile Vector&
x) {
834 KOKKOS_INLINE_FUNCTION
835 Vector& operator += (
const Vector&
x)
volatile {
837 return const_cast<Vector&
>(*this);
841 KOKKOS_INLINE_FUNCTION
842 Vector& operator += (
const volatile Vector&
x)
volatile {
844 return const_cast<Vector&
>(*this);
848 KOKKOS_INLINE_FUNCTION
849 Vector& operator -= (
const Vector&
x) {
855 KOKKOS_INLINE_FUNCTION
856 Vector& operator -= (
const volatile Vector&
x) {
862 KOKKOS_INLINE_FUNCTION
863 Vector& operator -= (
const Vector&
x)
volatile {
865 return const_cast<Vector&
>(*this);
869 KOKKOS_INLINE_FUNCTION
870 Vector& operator -= (
const volatile Vector&
x)
volatile {
872 return const_cast<Vector&
>(*this);
876 KOKKOS_INLINE_FUNCTION
877 Vector& operator *= (
const Vector&
x) {
883 KOKKOS_INLINE_FUNCTION
884 Vector& operator *= (
const volatile Vector&
x) {
890 KOKKOS_INLINE_FUNCTION
891 Vector& operator *= (
const Vector&
x)
volatile {
893 return const_cast<Vector&
>(*this);
897 KOKKOS_INLINE_FUNCTION
898 Vector& operator *= (
const volatile Vector&
x)
volatile {
900 return const_cast<Vector&
>(*this);
904 KOKKOS_INLINE_FUNCTION
905 Vector& operator /= (
const Vector&
x) {
911 KOKKOS_INLINE_FUNCTION
912 Vector& operator /= (
const volatile Vector&
x) {
918 KOKKOS_INLINE_FUNCTION
919 Vector& operator /= (
const Vector&
x)
volatile {
921 return const_cast<Vector&
>(*this);
925 KOKKOS_INLINE_FUNCTION
926 Vector& operator /= (
const volatile Vector&
x)
volatile {
928 return const_cast<Vector&
>(*this);
932 KOKKOS_INLINE_FUNCTION
933 Vector& operator++() {
940 KOKKOS_INLINE_FUNCTION
941 volatile Vector& operator++()
volatile {
948 KOKKOS_INLINE_FUNCTION
949 Vector operator++(
int) {
956 KOKKOS_INLINE_FUNCTION
957 Vector operator++(
int)
volatile {
964 KOKKOS_INLINE_FUNCTION
965 Vector& operator--() {
972 KOKKOS_INLINE_FUNCTION
973 volatile Vector& operator--()
volatile {
980 KOKKOS_INLINE_FUNCTION
981 Vector operator--(
int) {
988 KOKKOS_INLINE_FUNCTION
989 Vector operator--(
int)
volatile {
997 KOKKOS_INLINE_FUNCTION
998 std::string name()
const volatile {
return "x"; }
1015 #endif // HAVE_STOKHOS_SACADO 1017 #endif // SACADO_MP_VECTOR_SFS_HPP
Stokhos::StandardStorage< int, double > storage_type
Stokhos::StandardStorage< int, double > Storage
const double & const_reference
Statically allocated storage class.
Kokkos::DefaultExecutionSpace execution_space
expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 c fastAccessCoeff(j) - expr2.val(j)
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
const double * const_pointer
Top-level namespace for Stokhos classes and functions.
Traits class encapsulting memory alignment.
int size() const
Return size.