10 #ifndef STOKHOS_STATIC_ARRAY_TRAITS_HPP
11 #define STOKHOS_STATIC_ARRAY_TRAITS_HPP
15 #include "Sacado_Traits.hpp"
17 #include "Kokkos_Macros.hpp"
26 template <
typename T,
typename device,
27 bool isScalar = Sacado::IsScalarType<T>::value>
33 template <
typename T,
typename D>
41 KOKKOS_INLINE_FUNCTION
42 void copy(
const volatile T* src,
volatile T* dest, std::size_t sz) {
43 for (std::size_t i=0; i<sz; ++i)
49 KOKKOS_INLINE_FUNCTION
50 void copy(
const volatile T* src, T* dest, std::size_t sz) {
51 for (std::size_t i=0; i<sz; ++i)
57 KOKKOS_INLINE_FUNCTION
58 void copy(
const T* src,
volatile T* dest, std::size_t sz) {
59 for (std::size_t i=0; i<sz; ++i)
65 KOKKOS_INLINE_FUNCTION
66 void copy(
const T* src, T* dest, std::size_t sz) {
67 for (std::size_t i=0; i<sz; ++i)
73 KOKKOS_INLINE_FUNCTION
74 void zero(T* dest, std::size_t sz) {
75 for (std::size_t i=0; i<sz; ++i)
81 KOKKOS_INLINE_FUNCTION
82 void zero(
volatile T* dest, std::size_t sz) {
83 for (std::size_t i=0; i<sz; ++i)
89 KOKKOS_INLINE_FUNCTION
90 void fill(T* dest, std::size_t sz,
const T& v) {
91 for (std::size_t i=0; i<sz; ++i)
97 KOKKOS_INLINE_FUNCTION
98 void fill(
volatile T* dest, std::size_t sz,
const T& v) {
99 for (std::size_t i=0; i<sz; ++i)
109 template <
typename T,
typename D>
117 KOKKOS_INLINE_FUNCTION
118 void copy(
const volatile T* src,
volatile T* dest, std::size_t sz) {
121 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
124 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
125 #pragma vector aligned
127 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
130 for (std::size_t i=0; i<sz; ++i)
131 *(dest++) = *(src++);
136 KOKKOS_INLINE_FUNCTION
137 void copy(
const volatile T* src, T* dest, std::size_t sz) {
140 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
143 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
144 #pragma vector aligned
146 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
149 for (std::size_t i=0; i<sz; ++i)
150 *(dest++) = *(src++);
155 KOKKOS_INLINE_FUNCTION
156 void copy(
const T* src,
volatile T* dest, std::size_t sz) {
159 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
162 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
163 #pragma vector aligned
165 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
168 for (std::size_t i=0; i<sz; ++i)
169 *(dest++) = *(src++);
174 KOKKOS_INLINE_FUNCTION
175 void copy(
const T* src, T* dest, std::size_t sz) {
177 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
180 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
181 #pragma vector aligned
183 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
186 for (std::size_t i=0; i<sz; ++i)
187 *(dest++) = *(src++);
192 KOKKOS_INLINE_FUNCTION
193 void zero(T* dest, std::size_t sz) {
195 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
198 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
199 #pragma vector aligned
201 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
204 for (std::size_t i=0; i<sz; ++i)
210 KOKKOS_INLINE_FUNCTION
211 void zero(
volatile T* dest, std::size_t sz) {
213 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
216 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
217 #pragma vector aligned
219 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
222 for (std::size_t i=0; i<sz; ++i)
228 KOKKOS_INLINE_FUNCTION
229 void fill(T* dest, std::size_t sz, T v) {
231 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
234 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
235 #pragma vector aligned
237 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
240 for (std::size_t i=0; i<sz; ++i)
246 KOKKOS_INLINE_FUNCTION
247 void fill(
volatile T* dest, std::size_t sz, T v) {
249 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
252 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
253 #pragma vector aligned
255 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
258 for (std::size_t i=0; i<sz; ++i)
266 #endif // STOKHOS_STATIC_ARRAY_TRAITS_HPP
static KOKKOS_INLINE_FUNCTION void copy(const T *src, T *dest, std::size_t sz)
Copy array from src to dest of length sz.
static KOKKOS_INLINE_FUNCTION void zero(volatile T *dest, std::size_t sz)
Zero out array dest of length sz.
static KOKKOS_INLINE_FUNCTION void copy(const volatile T *src, T *dest, std::size_t sz)
Copy array from src to dest of length sz.
Static array allocation class.
static KOKKOS_INLINE_FUNCTION void fill(T *dest, std::size_t sz, const T &v)
Fill array dest of length sz with value v.
static KOKKOS_INLINE_FUNCTION void copy(const T *src, volatile T *dest, std::size_t sz)
Copy array from src to dest of length sz.
static KOKKOS_INLINE_FUNCTION void copy(const T *src, volatile T *dest, std::size_t sz)
Copy array from src to dest of length sz.
static KOKKOS_INLINE_FUNCTION void copy(const volatile T *src, volatile T *dest, std::size_t sz)
Copy array from src to dest of length sz.
static KOKKOS_INLINE_FUNCTION void copy(const volatile T *src, T *dest, std::size_t sz)
Copy array from src to dest of length sz.
static KOKKOS_INLINE_FUNCTION void copy(const T *src, T *dest, std::size_t sz)
Copy array from src to dest of length sz.
static KOKKOS_INLINE_FUNCTION void copy(const volatile T *src, volatile T *dest, std::size_t sz)
Copy array from src to dest of length sz.
static KOKKOS_INLINE_FUNCTION void zero(volatile T *dest, std::size_t sz)
Zero out array dest of length sz.
static KOKKOS_INLINE_FUNCTION void fill(volatile T *dest, std::size_t sz, const T &v)
Fill array dest of length sz with value v.
static KOKKOS_INLINE_FUNCTION void fill(T *dest, std::size_t sz, T v)
Fill array dest of length sz with value v.
static KOKKOS_INLINE_FUNCTION void zero(T *dest, std::size_t sz)
Zero out array dest of length sz.
static KOKKOS_INLINE_FUNCTION void zero(T *dest, std::size_t sz)
Zero out array dest of length sz.
static KOKKOS_INLINE_FUNCTION void fill(volatile T *dest, std::size_t sz, T v)
Fill array dest of length sz with value v.