10 #ifndef SACADO_MP_VECTOR_SFS_HPP
11 #define SACADO_MP_VECTOR_SFS_HPP
15 #ifdef HAVE_STOKHOS_SACADO
25 template <
typename ordinal_t,
typename value_t,
int Num,
typename device_t>
26 class Vector< Stokhos::StaticFixedStorage<ordinal_t,value_t,Num,device_t> >{
37 typedef typename storage_type::volatile_pointer volatile_pointer;
39 typedef typename storage_type::const_volatile_pointer const_volatile_pointer;
41 typedef typename storage_type::volatile_reference volatile_reference;
43 typedef typename storage_type::const_volatile_reference const_volatile_reference;
45 typedef typename execution_space::memory_space memory_space;
49 typedef typename ScalarType<value_type>::type
scalar_type;
52 template <
class NewStorageType >
54 typedef Vector< NewStorageType > type;
58 static const int num_args = 1;
60 #if STOKHOS_ALIGN_MEMORY
61 KOKKOS_INLINE_FUNCTION
62 static void*
operator new(std::size_t sz) {
63 return MemTraits::alloc(sz);
65 KOKKOS_INLINE_FUNCTION
66 static void*
operator new[](std::size_t sz) {
67 return MemTraits::alloc(sz);
69 KOKKOS_INLINE_FUNCTION
70 static void*
operator new(std::size_t sz,
void* ptr) {
73 KOKKOS_INLINE_FUNCTION
74 static void*
operator new[](std::size_t sz,
void* ptr) {
77 KOKKOS_INLINE_FUNCTION
78 static void operator delete(
void* ptr) {
81 KOKKOS_INLINE_FUNCTION
82 static void operator delete[](
void* ptr) {
85 KOKKOS_INLINE_FUNCTION
86 static void operator delete(
void* ptr,
void*) {
89 KOKKOS_INLINE_FUNCTION
90 static void operator delete[](
void* ptr,
void*) {
99 KOKKOS_INLINE_FUNCTION
106 KOKKOS_INLINE_FUNCTION
114 KOKKOS_INLINE_FUNCTION
115 Vector(
ordinal_type sz, pointer v,
bool owned) : s(sz,v,owned) {}
121 KOKKOS_INLINE_FUNCTION
125 KOKKOS_INLINE_FUNCTION
129 KOKKOS_INLINE_FUNCTION
130 Vector(
const Vector& x) : s(x.s) {}
133 KOKKOS_INLINE_FUNCTION
134 Vector(
const volatile Vector& x) : s(x.s) {}
140 Vector(std::initializer_list<value_type> l) : s(l.size(), l.begin()) {}
143 KOKKOS_INLINE_FUNCTION
147 KOKKOS_INLINE_FUNCTION
151 KOKKOS_INLINE_FUNCTION
152 void init(
const value_type& v)
volatile { s.init(v); }
155 KOKKOS_INLINE_FUNCTION
159 KOKKOS_INLINE_FUNCTION
160 void init(
const value_type* v)
volatile { s.init(v); }
163 template <
typename S>
164 KOKKOS_INLINE_FUNCTION
165 void init(
const Vector<S>& v) {
166 s.init(v.s.coeff(), v.s.size());
170 template <
typename S>
171 KOKKOS_INLINE_FUNCTION
172 void init(
const Vector<S>& v)
volatile {
173 s.init(v.s.coeff(), v.s.size());
177 KOKKOS_INLINE_FUNCTION
181 KOKKOS_INLINE_FUNCTION
182 void load(
value_type* v)
volatile { s.load(v); }
185 template <
typename S>
186 KOKKOS_INLINE_FUNCTION
187 void load(Vector<S>& v) { s.load(v.s.coeff()); }
190 template <
typename S>
191 KOKKOS_INLINE_FUNCTION
192 void load(Vector<S>& v)
volatile { s.load(v.s.coeff()); }
198 KOKKOS_INLINE_FUNCTION
205 KOKKOS_INLINE_FUNCTION
218 KOKKOS_INLINE_FUNCTION
219 void copyForWrite()
volatile { }
222 KOKKOS_INLINE_FUNCTION
223 bool isEqualTo(
const Vector& x)
const {
224 typedef IsEqual<value_type> IE;
227 eq = eq && IE::eval(x.coeff(i), this->coeff(i));
232 KOKKOS_INLINE_FUNCTION
233 bool isEqualTo(
const Vector& x)
const volatile {
234 typedef IsEqual<value_type> IE;
237 eq = eq && IE::eval(x.coeff(i), this->coeff(i));
247 KOKKOS_INLINE_FUNCTION
254 KOKKOS_INLINE_FUNCTION
255 Vector& operator=(
const value_type& x)
volatile {
257 return const_cast<Vector&
>(*this);
261 KOKKOS_INLINE_FUNCTION
262 Vector& operator=(
const Vector& x) {
271 KOKKOS_INLINE_FUNCTION
272 Vector& operator=(
const volatile Vector& x) {
281 KOKKOS_INLINE_FUNCTION
282 Vector& operator=(
const Vector& x)
volatile {
287 return const_cast<Vector&
>(*this);
291 KOKKOS_INLINE_FUNCTION
292 Vector& operator=(
const volatile Vector& x)
volatile {
297 return const_cast<Vector&
>(*this);
306 KOKKOS_INLINE_FUNCTION
308 const volatile storage_type& storage()
const volatile {
return s; }
311 KOKKOS_INLINE_FUNCTION
315 KOKKOS_INLINE_FUNCTION
319 KOKKOS_INLINE_FUNCTION
328 KOKKOS_INLINE_FUNCTION
329 const_volatile_reference
val()
const volatile {
return s[0]; }
332 KOKKOS_INLINE_FUNCTION
333 const_reference
val()
const {
return s[0]; }
336 KOKKOS_INLINE_FUNCTION
337 volatile_reference
val()
volatile {
return s[0]; }
340 KOKKOS_INLINE_FUNCTION
341 reference
val() {
return s[0]; }
351 KOKKOS_INLINE_FUNCTION
355 KOKKOS_INLINE_FUNCTION
356 static bool hasFastAccess(
ordinal_type sz) {
return true; }
359 KOKKOS_INLINE_FUNCTION
360 const_pointer coeff()
const {
return s.coeff();}
363 KOKKOS_INLINE_FUNCTION
364 const_volatile_pointer coeff()
const volatile {
return s.coeff();}
367 KOKKOS_INLINE_FUNCTION
368 volatile_pointer coeff()
volatile {
return s.coeff();}
371 KOKKOS_INLINE_FUNCTION
372 pointer coeff() {
return s.coeff();}
375 KOKKOS_INLINE_FUNCTION
379 KOKKOS_INLINE_FUNCTION
383 KOKKOS_INLINE_FUNCTION
387 KOKKOS_INLINE_FUNCTION
391 KOKKOS_INLINE_FUNCTION
396 KOKKOS_INLINE_FUNCTION
401 KOKKOS_INLINE_FUNCTION
406 KOKKOS_INLINE_FUNCTION
411 KOKKOS_INLINE_FUNCTION
412 const_volatile_reference operator[](
ordinal_type i)
const volatile {
416 KOKKOS_INLINE_FUNCTION
421 KOKKOS_INLINE_FUNCTION
422 volatile_reference operator[](
ordinal_type i)
volatile {
426 KOKKOS_INLINE_FUNCTION
431 KOKKOS_INLINE_FUNCTION
433 return s.template getCoeff<i>(); }
436 KOKKOS_INLINE_FUNCTION
438 return s.template getCoeff<i>(); }
441 KOKKOS_INLINE_FUNCTION
442 volatile_reference getCoeff()
volatile {
443 return s.template getCoeff<i>(); }
446 KOKKOS_INLINE_FUNCTION
447 reference getCoeff() {
448 return s.template getCoeff<i>(); }
451 KOKKOS_INLINE_FUNCTION
452 pointer begin() {
return s.coeff(); }
455 KOKKOS_INLINE_FUNCTION
456 const_pointer begin()
const {
return s.coeff(); }
459 KOKKOS_INLINE_FUNCTION
460 volatile_pointer begin()
volatile {
return s.coeff(); }
463 KOKKOS_INLINE_FUNCTION
464 const_volatile_pointer begin()
const volatile {
return s.coeff(); }
467 KOKKOS_INLINE_FUNCTION
468 const_pointer cbegin()
const {
return s.coeff(); }
471 KOKKOS_INLINE_FUNCTION
472 const_volatile_pointer cbegin()
const volatile {
return s.coeff(); }
475 KOKKOS_INLINE_FUNCTION
476 pointer end() {
return s.coeff() + s.size(); }
479 KOKKOS_INLINE_FUNCTION
480 const_pointer end()
const {
return s.coeff() + s.size(); }
483 KOKKOS_INLINE_FUNCTION
484 volatile_pointer end()
volatile {
return s.coeff() + s.size(); }
487 KOKKOS_INLINE_FUNCTION
488 const_volatile_pointer end()
const volatile {
return s.coeff() + s.size(); }
491 KOKKOS_INLINE_FUNCTION
492 const_pointer cend()
const {
return s.coeff()+ s.size(); }
495 KOKKOS_INLINE_FUNCTION
496 const_volatile_pointer cend()
const volatile {
return s.coeff()+ s.size(); }
506 KOKKOS_INLINE_FUNCTION
508 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
511 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
512 #pragma vector aligned
514 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
523 KOKKOS_INLINE_FUNCTION
524 Vector& operator += (
const volatile value_type& x) {
525 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
528 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
529 #pragma vector aligned
531 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
540 KOKKOS_INLINE_FUNCTION
541 Vector& operator += (
const value_type& x)
volatile {
542 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
545 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
546 #pragma vector aligned
548 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
553 return const_cast<Vector&
>(*this);
557 KOKKOS_INLINE_FUNCTION
558 Vector& operator += (
const volatile value_type& x)
volatile {
559 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
562 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
563 #pragma vector aligned
565 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
570 return const_cast<Vector&
>(*this);
574 KOKKOS_INLINE_FUNCTION
576 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
579 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
580 #pragma vector aligned
582 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
591 KOKKOS_INLINE_FUNCTION
592 Vector& operator -= (
const volatile value_type& x) {
593 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
596 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
597 #pragma vector aligned
599 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
608 KOKKOS_INLINE_FUNCTION
609 Vector& operator -= (
const value_type& x)
volatile {
610 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
613 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
614 #pragma vector aligned
616 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
621 return const_cast<Vector&
>(*this);
625 KOKKOS_INLINE_FUNCTION
626 Vector& operator -= (
const volatile value_type& x)
volatile {
627 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
630 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
631 #pragma vector aligned
633 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
638 return const_cast<Vector&
>(*this);
642 KOKKOS_INLINE_FUNCTION
644 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
647 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
648 #pragma vector aligned
650 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
659 KOKKOS_INLINE_FUNCTION
660 Vector& operator *= (
const volatile value_type& x) {
661 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
664 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
665 #pragma vector aligned
667 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
676 KOKKOS_INLINE_FUNCTION
677 Vector& operator *= (
const value_type& x)
volatile {
678 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
681 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
682 #pragma vector aligned
684 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
689 return const_cast<Vector&
>(*this);
693 KOKKOS_INLINE_FUNCTION
694 Vector& operator *= (
const volatile value_type& x)
volatile {
695 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
698 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
699 #pragma vector aligned
701 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
706 return const_cast<Vector&
>(*this);
710 KOKKOS_INLINE_FUNCTION
712 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
715 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
716 #pragma vector aligned
718 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
727 KOKKOS_INLINE_FUNCTION
728 Vector& operator /= (
const volatile value_type& x) {
729 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
732 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
733 #pragma vector aligned
735 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
744 KOKKOS_INLINE_FUNCTION
745 Vector& operator /= (
const value_type& x)
volatile {
746 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
749 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
750 #pragma vector aligned
752 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
757 return const_cast<Vector&
>(*this);
761 KOKKOS_INLINE_FUNCTION
762 Vector& operator /= (
const volatile value_type& x)
volatile {
763 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
766 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
767 #pragma vector aligned
769 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
774 return const_cast<Vector&
>(*this);
778 KOKKOS_INLINE_FUNCTION
779 Vector& operator += (
const Vector& x) {
780 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
783 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
784 #pragma vector aligned
786 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
790 s[i] += x.fastAccessCoeff(i);
795 KOKKOS_INLINE_FUNCTION
796 Vector& operator += (
const volatile Vector& x) {
802 KOKKOS_INLINE_FUNCTION
803 Vector& operator += (
const Vector& x)
volatile {
805 return const_cast<Vector&
>(*this);
809 KOKKOS_INLINE_FUNCTION
810 Vector& operator += (
const volatile Vector& x)
volatile {
812 return const_cast<Vector&
>(*this);
816 KOKKOS_INLINE_FUNCTION
817 Vector& operator -= (
const Vector& x) {
823 KOKKOS_INLINE_FUNCTION
824 Vector& operator -= (
const volatile Vector& x) {
830 KOKKOS_INLINE_FUNCTION
831 Vector& operator -= (
const Vector& x)
volatile {
833 return const_cast<Vector&
>(*this);
837 KOKKOS_INLINE_FUNCTION
838 Vector& operator -= (
const volatile Vector& x)
volatile {
840 return const_cast<Vector&
>(*this);
844 KOKKOS_INLINE_FUNCTION
845 Vector& operator *= (
const Vector& x) {
851 KOKKOS_INLINE_FUNCTION
852 Vector& operator *= (
const volatile Vector& x) {
858 KOKKOS_INLINE_FUNCTION
859 Vector& operator *= (
const Vector& x)
volatile {
861 return const_cast<Vector&
>(*this);
865 KOKKOS_INLINE_FUNCTION
866 Vector& operator *= (
const volatile Vector& x)
volatile {
868 return const_cast<Vector&
>(*this);
872 KOKKOS_INLINE_FUNCTION
873 Vector& operator /= (
const Vector& x) {
879 KOKKOS_INLINE_FUNCTION
880 Vector& operator /= (
const volatile Vector& x) {
886 KOKKOS_INLINE_FUNCTION
887 Vector& operator /= (
const Vector& x)
volatile {
889 return const_cast<Vector&
>(*this);
893 KOKKOS_INLINE_FUNCTION
894 Vector& operator /= (
const volatile Vector& x)
volatile {
896 return const_cast<Vector&
>(*this);
900 KOKKOS_INLINE_FUNCTION
901 Vector& operator++() {
908 KOKKOS_INLINE_FUNCTION
909 volatile Vector& operator++()
volatile {
916 KOKKOS_INLINE_FUNCTION
917 Vector operator++(
int) {
924 KOKKOS_INLINE_FUNCTION
925 Vector operator++(
int)
volatile {
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 {
965 KOKKOS_INLINE_FUNCTION
966 std::string name()
const volatile {
return "x"; }
983 #endif // HAVE_STOKHOS_SACADO
985 #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
const double * const_pointer
Traits class encapsulting memory alignment.
expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 c fastAccessCoeff(j)-expr2.val(j)
int size() const
Return size.