44 #ifndef KOKKOS_COPYVIEWS_HPP_ 45 #define KOKKOS_COPYVIEWS_HPP_ 51 #ifndef KOKKOS_IMPL_COMPILING_LIBRARY 52 #define KOKKOS_IMPL_COMPILING_LIBRARY false 59 template<
class Layout>
60 struct ViewFillLayoutSelector {
64 struct ViewFillLayoutSelector<
Kokkos::LayoutLeft> {
65 static const Kokkos::Iterate iterate = Kokkos::Iterate::Left;
69 struct ViewFillLayoutSelector<
Kokkos::LayoutRight> {
70 static const Kokkos::Iterate iterate = Kokkos::Iterate::Right;
76 #include<impl/Kokkos_ViewFillCopyETIAvail.hpp> 81 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
82 struct ViewFill<ViewType,Layout,ExecSpace,0,iType,ETIAvail> {
84 typename ViewType::const_value_type val;
85 typedef typename ViewType::non_const_value_type ST;
86 ViewFill(
const ViewType&,
const ST&);
89 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
90 struct ViewFill<ViewType,Layout,ExecSpace,1,iType,ETIAvail> {
92 typename ViewType::const_value_type val;
93 typedef typename ViewType::non_const_value_type ST;
94 ViewFill(
const ViewType&,
const ST&);
95 KOKKOS_INLINE_FUNCTION
96 void operator() (
const iType&)
const;
99 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
100 struct ViewFill<ViewType,Layout,ExecSpace,2,iType,ETIAvail> {
102 typename ViewType::const_value_type val;
103 typedef typename ViewType::non_const_value_type ST;
104 ViewFill(
const ViewType&,
const ST&);
105 KOKKOS_INLINE_FUNCTION
106 void operator() (
const iType&,
const iType&)
const;
109 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
110 struct ViewFill<ViewType,Layout,ExecSpace,3,iType,ETIAvail> {
112 typename ViewType::const_value_type val;
113 typedef typename ViewType::non_const_value_type ST;
114 ViewFill(
const ViewType&,
const ST&);
115 KOKKOS_INLINE_FUNCTION
116 void operator() (
const iType&,
const iType&,
const iType&)
const;
119 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
120 struct ViewFill<ViewType,Layout,ExecSpace,4,iType,ETIAvail> {
122 typename ViewType::const_value_type val;
123 typedef typename ViewType::non_const_value_type ST;
124 ViewFill(
const ViewType&,
const ST&);
125 KOKKOS_INLINE_FUNCTION
126 void operator() (
const iType&,
const iType&,
const iType&,
const iType&)
const;
129 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
130 struct ViewFill<ViewType,Layout,ExecSpace,5,iType,ETIAvail> {
132 typename ViewType::const_value_type val;
133 typedef typename ViewType::non_const_value_type ST;
134 ViewFill(
const ViewType&,
const ST&);
135 KOKKOS_INLINE_FUNCTION
136 void operator() (
const iType&,
const iType&,
const iType&,
const iType&,
140 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
141 struct ViewFill<ViewType,Layout,ExecSpace,6,iType,ETIAvail> {
143 typename ViewType::const_value_type val;
144 typedef typename ViewType::non_const_value_type ST;
145 ViewFill(
const ViewType&,
const ST&);
146 KOKKOS_INLINE_FUNCTION
147 void operator() (
const iType&,
const iType&,
const iType&,
const iType&,
148 const iType&,
const iType&)
const;
151 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
152 struct ViewFill<ViewType,Layout,ExecSpace,7,iType,ETIAvail> {
154 typename ViewType::const_value_type val;
155 typedef typename ViewType::non_const_value_type ST;
156 ViewFill(
const ViewType&,
const ST&);
157 KOKKOS_INLINE_FUNCTION
158 void operator() (
const iType&,
const iType&,
const iType&,
const iType&,
159 const iType&,
const iType&,
const iType&)
const;
162 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
163 struct ViewFill<ViewType,Layout,ExecSpace,8,iType,ETIAvail> {
165 typename ViewType::const_value_type val;
166 typedef typename ViewType::non_const_value_type ST;
167 ViewFill(
const ViewType&,
const ST&);
168 KOKKOS_INLINE_FUNCTION
169 void operator() (
const iType&,
const iType&,
const iType&,
const iType&,
170 const iType&,
const iType&,
const iType&,
const iType&)
const;
173 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType>
174 struct ViewFill<ViewType,Layout,ExecSpace,0,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
175 typedef typename ViewType::non_const_value_type ST;
176 ViewFill(
const ViewType& a,
const ST& val) {
177 Kokkos::Impl::DeepCopy< typename ViewType::memory_space, Kokkos::HostSpace >( a.data() , &val,
sizeof(ST) );
182 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType>
183 struct ViewFill<ViewType,Layout,ExecSpace,1,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
185 typename ViewType::const_value_type val;
188 ViewFill(
const ViewType& a_,
typename ViewType::const_value_type& val_):a(a_),val(val_) {
194 KOKKOS_INLINE_FUNCTION
195 void operator() (
const iType& i)
const {
200 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType>
201 struct ViewFill<ViewType,Layout,ExecSpace,2,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
203 typename ViewType::const_value_type val;
205 typedef Kokkos::Rank<2,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
206 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
208 ViewFill(
const ViewType& a_,
typename ViewType::const_value_type& val_):a(a_),val(val_) {
211 policy_type({0,0},{a.extent(0),a.extent(1)}),*
this);
215 KOKKOS_INLINE_FUNCTION
216 void operator() (
const iType& i0,
const iType& i1)
const {
221 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType>
222 struct ViewFill<ViewType,Layout,ExecSpace,3,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
224 typename ViewType::const_value_type val;
226 typedef Kokkos::Rank<3,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
227 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
229 ViewFill(
const ViewType& a_,
typename ViewType::const_value_type& val_):a(a_),val(val_) {
232 policy_type({0,0,0},{a.extent(0),a.extent(1),a.extent(2)}),*
this);
236 KOKKOS_INLINE_FUNCTION
237 void operator() (
const iType& i0,
const iType& i1,
const iType& i2)
const {
242 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType>
243 struct ViewFill<ViewType,Layout,ExecSpace,4,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
245 typename ViewType::const_value_type val;
247 typedef Kokkos::Rank<4,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
248 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
250 ViewFill(
const ViewType& a_,
typename ViewType::const_value_type& val_):a(a_),val(val_) {
253 policy_type({0,0,0,0},{a.extent(0),a.extent(1),a.extent(2),a.extent(3)}),*
this);
257 KOKKOS_INLINE_FUNCTION
258 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
const iType& i3)
const {
259 a(i0,i1,i2,i3) = val;
263 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType>
264 struct ViewFill<ViewType,Layout,ExecSpace,5,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
266 typename ViewType::const_value_type val;
268 typedef Kokkos::Rank<5,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
269 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
271 ViewFill(
const ViewType& a_,
typename ViewType::const_value_type& val_):a(a_),val(val_) {
274 policy_type({0,0,0,0,0},{a.extent(0),a.extent(1),a.extent(2),a.extent(3),a.extent(4)}),*
this);
278 KOKKOS_INLINE_FUNCTION
279 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
const iType& i3,
const iType& i4)
const {
280 a(i0,i1,i2,i3,i4) = val;
284 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType>
285 struct ViewFill<ViewType,Layout,ExecSpace,6,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
287 typename ViewType::const_value_type val;
289 typedef Kokkos::Rank<6,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
290 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
292 ViewFill(
const ViewType& a_,
typename ViewType::const_value_type& val_):a(a_),val(val_) {
295 policy_type({0,0,0,0,0,0},{a.extent(0),a.extent(1),a.extent(2),a.extent(3),a.extent(4),a.extent(5)}),*
this);
299 KOKKOS_INLINE_FUNCTION
300 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
const iType& i3,
const iType& i4,
const iType& i5)
const {
301 a(i0,i1,i2,i3,i4,i5) = val;
305 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType>
306 struct ViewFill<ViewType,Layout,ExecSpace,7,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
308 typename ViewType::const_value_type val;
310 typedef Kokkos::Rank<6,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
311 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
313 ViewFill(
const ViewType& a_,
typename ViewType::const_value_type& val_):a(a_),val(val_) {
316 policy_type({0,0,0,0,0,0},{a.extent(0),a.extent(1),a.extent(2),a.extent(3),
317 a.extent(5),a.extent(6)}),*
this);
321 KOKKOS_INLINE_FUNCTION
322 void operator() (
const iType& i0,
const iType& i1,
const iType& i3,
323 const iType& i4,
const iType& i5,
const iType& i6)
const {
324 for(iType i2=0; i2<iType(a.extent(2));i2++)
325 a(i0,i1,i2,i3,i4,i5,i6) = val;
329 template<
class ViewType,
class Layout,
class ExecSpace,
typename iType>
330 struct ViewFill<ViewType,Layout,ExecSpace,8,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
332 typename ViewType::const_value_type val;
334 typedef Kokkos::Rank<6,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
335 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
337 ViewFill(
const ViewType& a_,
typename ViewType::const_value_type& val_):a(a_),val(val_) {
340 policy_type({0,0,0,0,0,0},{a.extent(0),a.extent(1),a.extent(3),
341 a.extent(5),a.extent(6),a.extent(7)}),*
this);
345 KOKKOS_INLINE_FUNCTION
346 void operator() (
const iType& i0,
const iType& i1,
const iType& i3,
347 const iType& i5,
const iType& i6,
const iType& i7)
const {
348 for(iType i2=0; i2<iType(a.extent(2));i2++)
349 for(iType i4=0; i4<iType(a.extent(4));i4++)
350 a(i0,i1,i2,i3,i4,i5,i6,i7) = val;
354 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
355 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,1,iType,ETIAvail> {
358 ViewCopy(
const ViewTypeA&,
const ViewTypeB&);
359 KOKKOS_INLINE_FUNCTION
360 void operator() (
const iType& i0)
const;
363 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
364 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,2,iType,ETIAvail> {
367 ViewCopy(
const ViewTypeA&,
const ViewTypeB&);
368 KOKKOS_INLINE_FUNCTION
369 void operator() (
const iType& i0,
const iType& i1)
const;
372 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
373 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,3,iType,ETIAvail> {
376 ViewCopy(
const ViewTypeA&,
const ViewTypeB&);
377 KOKKOS_INLINE_FUNCTION
378 void operator() (
const iType& i0,
const iType& i1,
const iType& i2)
const;
381 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
382 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,4,iType,ETIAvail> {
385 ViewCopy(
const ViewTypeA&,
const ViewTypeB&);
386 KOKKOS_INLINE_FUNCTION
387 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
const iType& i3)
const;
390 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
391 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,5,iType,ETIAvail> {
394 ViewCopy(
const ViewTypeA&,
const ViewTypeB&);
395 KOKKOS_INLINE_FUNCTION
396 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
const iType& i3,
397 const iType& i4)
const;
400 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
401 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,6,iType,ETIAvail> {
404 ViewCopy(
const ViewTypeA&,
const ViewTypeB&);
405 KOKKOS_INLINE_FUNCTION
406 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
const iType& i3,
407 const iType& i4,
const iType& i5)
const;
410 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
411 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,7,iType,ETIAvail> {
414 ViewCopy(
const ViewTypeA&,
const ViewTypeB&);
415 KOKKOS_INLINE_FUNCTION
416 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
const iType& i3,
417 const iType& i4,
const iType& i5,
const iType& i6)
const;
420 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType,
bool ETIAvail>
421 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,8,iType,ETIAvail> {
424 ViewCopy(
const ViewTypeA&,
const ViewTypeB&);
425 KOKKOS_INLINE_FUNCTION
426 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
const iType& i3,
427 const iType& i4,
const iType& i5,
const iType& i6,
const iType& i7)
const;
432 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType>
433 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,1,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
439 ViewCopy(
const ViewTypeA& a_,
const ViewTypeB& b_):a(a_),b(b_) {
442 policy_type(0,a.extent(0)),*
this);
446 KOKKOS_INLINE_FUNCTION
447 void operator() (
const iType& i0)
const {
452 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType>
453 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,2,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
457 typedef Kokkos::Rank<2,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
458 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
460 ViewCopy(
const ViewTypeA& a_,
const ViewTypeB& b_):a(a_),b(b_) {
463 policy_type({0,0},{a.extent(0),a.extent(1)}),*
this);
467 KOKKOS_INLINE_FUNCTION
468 void operator() (
const iType& i0,
const iType& i1)
const {
473 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType>
474 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,3,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
478 typedef Kokkos::Rank<3,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
479 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
481 ViewCopy(
const ViewTypeA& a_,
const ViewTypeB& b_):a(a_),b(b_) {
484 policy_type({0,0,0},{a.extent(0),a.extent(1),a.extent(2)}),*
this);
488 KOKKOS_INLINE_FUNCTION
489 void operator() (
const iType& i0,
const iType& i1,
const iType& i2)
const {
490 a(i0,i1,i2) = b(i0,i1,i2);
494 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType>
495 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,4,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
499 typedef Kokkos::Rank<4,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
500 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
502 ViewCopy(
const ViewTypeA& a_,
const ViewTypeB& b_):a(a_),b(b_) {
505 policy_type({0,0,0,0},{a.extent(0),a.extent(1),a.extent(2),
506 a.extent(3)}),*
this);
510 KOKKOS_INLINE_FUNCTION
511 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
512 const iType& i3)
const {
513 a(i0,i1,i2,i3) = b(i0,i1,i2,i3);
517 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType>
518 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,5,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
522 typedef Kokkos::Rank<5,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
523 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
525 ViewCopy(
const ViewTypeA& a_,
const ViewTypeB& b_):a(a_),b(b_) {
528 policy_type({0,0,0,0,0},{a.extent(0),a.extent(1),a.extent(2),
529 a.extent(3),a.extent(4)}),*
this);
533 KOKKOS_INLINE_FUNCTION
534 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
535 const iType& i3,
const iType& i4)
const {
536 a(i0,i1,i2,i3,i4) = b(i0,i1,i2,i3,i4);
540 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType>
541 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,6,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
545 typedef Kokkos::Rank<6,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
546 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
548 ViewCopy(
const ViewTypeA& a_,
const ViewTypeB& b_):a(a_),b(b_) {
551 policy_type({0,0,0,0,0,0},{a.extent(0),a.extent(1),a.extent(2),
552 a.extent(3),a.extent(4),a.extent(5)}),*
this);
556 KOKKOS_INLINE_FUNCTION
557 void operator() (
const iType& i0,
const iType& i1,
const iType& i2,
558 const iType& i3,
const iType& i4,
const iType& i5)
const {
559 a(i0,i1,i2,i3,i4,i5) = b(i0,i1,i2,i3,i4,i5);
564 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType>
565 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,7,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
569 typedef Kokkos::Rank<6,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
570 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
572 ViewCopy(
const ViewTypeA& a_,
const ViewTypeB& b_):a(a_),b(b_) {
575 policy_type({0,0,0,0,0,0},{a.extent(0),a.extent(1),a.extent(3),
576 a.extent(4),a.extent(5),a.extent(6)}),*
this);
580 KOKKOS_INLINE_FUNCTION
581 void operator() (
const iType& i0,
const iType& i1,
const iType& i3,
582 const iType& i4,
const iType& i5,
const iType& i6)
const {
583 for(iType i2=0; i2<iType(a.extent(2));i2++)
584 a(i0,i1,i2,i3,i4,i5,i6) = b(i0,i1,i2,i3,i4,i5,i6);
588 template<
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
typename iType>
589 struct ViewCopy<ViewTypeA,ViewTypeB,Layout,ExecSpace,8,iType,KOKKOS_IMPL_COMPILING_LIBRARY> {
593 typedef Kokkos::Rank<6,ViewFillLayoutSelector<Layout>::iterate,ViewFillLayoutSelector<Layout>::iterate> iterate_type;
594 typedef Kokkos::MDRangePolicy<ExecSpace,iterate_type,Kokkos::IndexType<iType>> policy_type;
596 ViewCopy(
const ViewTypeA& a_,
const ViewTypeB& b_):a(a_),b(b_) {
599 policy_type({0,0,0,0,0,0},{a.extent(0),a.extent(1),a.extent(3),
600 a.extent(5),a.extent(6),a.extent(7)}),*
this);
604 KOKKOS_INLINE_FUNCTION
605 void operator() (
const iType& i0,
const iType& i1,
const iType& i3,
606 const iType& i5,
const iType& i6,
const iType& i7)
const {
607 for(iType i2=0; i2<iType(a.extent(2));i2++)
608 for(iType i4=0; i4<iType(a.extent(4));i4++)
609 a(i0,i1,i2,i3,i4,i5,i6,i7) = b(i0,i1,i2,i3,i4,i5,i6,i7);
616 #include<impl/Kokkos_ViewFillCopyETIDecl.hpp> 621 template<
class DstType,
class SrcType>
622 void view_copy(
const DstType& dst,
const SrcType& src) {
623 typedef typename DstType::execution_space dst_execution_space;
624 typedef typename SrcType::execution_space src_execution_space;
625 typedef typename DstType::memory_space dst_memory_space;
626 typedef typename SrcType::memory_space src_memory_space;
628 enum { DstExecCanAccessSrc =
631 enum { SrcExecCanAccessDst =
634 if( ! DstExecCanAccessSrc && ! SrcExecCanAccessDst) {
635 std::string message(
"Error: Kokkos::deep_copy with no available copy mechanism: ");
636 message += src.label(); message +=
" to ";
637 message += dst.label();
638 Kokkos::Impl::throw_runtime_exception(message);
642 int64_t strides[DstType::Rank+1];
644 Kokkos::Iterate iterate;
645 if ( std::is_same<typename DstType::array_layout,Kokkos::LayoutRight>::value ) {
646 iterate = Kokkos::Iterate::Right;
647 }
else if ( std::is_same<typename DstType::array_layout,Kokkos::LayoutLeft>::value ) {
648 iterate = Kokkos::Iterate::Left;
649 }
else if ( std::is_same<typename DstType::array_layout,Kokkos::LayoutStride>::value ) {
650 if( strides[0] > strides[DstType::Rank-1] )
651 iterate = Kokkos::Iterate::Right;
653 iterate = Kokkos::Iterate::Left;
655 if( std::is_same<typename DstType::execution_space::array_layout, Kokkos::LayoutRight>::value )
656 iterate = Kokkos::Iterate::Right;
658 iterate = Kokkos::Iterate::Left;
661 if( (dst.span() >= size_t(std::numeric_limits<int>::max())) ||
662 (src.span() >= size_t(std::numeric_limits<int>::max())) ){
663 if(DstExecCanAccessSrc) {
664 if(iterate == Kokkos::Iterate::Right)
665 Kokkos::Impl::ViewCopy<
typename DstType::uniform_runtime_nomemspace_type,
typename SrcType::uniform_runtime_const_nomemspace_type,
Kokkos::LayoutRight, dst_execution_space,
666 DstType::Rank, int64_t >( dst , src );
668 Kokkos::Impl::ViewCopy<
typename DstType::uniform_runtime_nomemspace_type,
typename SrcType::uniform_runtime_const_nomemspace_type,
Kokkos::LayoutLeft, dst_execution_space,
669 DstType::Rank, int64_t >( dst , src );
671 if(iterate == Kokkos::Iterate::Right)
672 Kokkos::Impl::ViewCopy<
typename DstType::uniform_runtime_nomemspace_type,
typename SrcType::uniform_runtime_const_nomemspace_type,
Kokkos::LayoutRight, src_execution_space,
673 DstType::Rank, int64_t >( dst , src );
675 Kokkos::Impl::ViewCopy<
typename DstType::uniform_runtime_nomemspace_type,
typename SrcType::uniform_runtime_const_nomemspace_type,
Kokkos::LayoutLeft, src_execution_space,
676 DstType::Rank, int64_t >( dst , src );
679 if(DstExecCanAccessSrc) {
680 if(iterate == Kokkos::Iterate::Right)
681 Kokkos::Impl::ViewCopy<
typename DstType::uniform_runtime_nomemspace_type,
typename SrcType::uniform_runtime_const_nomemspace_type,
Kokkos::LayoutRight, dst_execution_space,
682 DstType::Rank,
int >( dst , src );
684 Kokkos::Impl::ViewCopy<
typename DstType::uniform_runtime_nomemspace_type,
typename SrcType::uniform_runtime_const_nomemspace_type,
Kokkos::LayoutLeft, dst_execution_space,
685 DstType::Rank,
int >( dst , src );
687 if(iterate == Kokkos::Iterate::Right)
688 Kokkos::Impl::ViewCopy<
typename DstType::uniform_runtime_nomemspace_type,
typename SrcType::uniform_runtime_const_nomemspace_type,
Kokkos::LayoutRight, src_execution_space,
689 DstType::Rank,
int >( dst , src );
691 Kokkos::Impl::ViewCopy<
typename DstType::uniform_runtime_nomemspace_type,
typename SrcType::uniform_runtime_const_nomemspace_type,
Kokkos::LayoutLeft, src_execution_space,
692 DstType::Rank,
int >( dst , src );
698 template<
class DstType,
class SrcType,
int Rank,
class ... Args>
699 struct CommonSubview;
701 template<
class DstType,
class SrcType,
class Arg0,
class ... Args>
702 struct CommonSubview<DstType,SrcType,1,Arg0,Args...> {
703 typedef typename Kokkos::Subview<DstType,Arg0> dst_subview_type;
704 typedef typename Kokkos::Subview<SrcType,Arg0> src_subview_type;
705 dst_subview_type dst_sub;
706 src_subview_type src_sub;
707 CommonSubview(
const DstType& dst,
const SrcType& src,
const Arg0& arg0, Args... ):
708 dst_sub(dst,arg0),src_sub(src,arg0) {}
711 template<
class DstType,
class SrcType,
class Arg0,
class Arg1,
class ... Args>
712 struct CommonSubview<DstType,SrcType,2,Arg0,Arg1,Args...> {
713 typedef typename Kokkos::Subview<DstType,Arg0,Arg1> dst_subview_type;
714 typedef typename Kokkos::Subview<SrcType,Arg0,Arg1> src_subview_type;
715 dst_subview_type dst_sub;
716 src_subview_type src_sub;
717 CommonSubview(
const DstType& dst,
const SrcType& src,
const Arg0& arg0,
const Arg1& arg1, Args... ):
718 dst_sub(dst,arg0,arg1),src_sub(src,arg0,arg1) {}
721 template<
class DstType,
class SrcType,
class Arg0,
class Arg1,
class Arg2,
class ... Args>
722 struct CommonSubview<DstType,SrcType,3,Arg0,Arg1,Arg2,Args...> {
723 typedef typename Kokkos::Subview<DstType,Arg0,Arg1,Arg2> dst_subview_type;
724 typedef typename Kokkos::Subview<SrcType,Arg0,Arg1,Arg2> src_subview_type;
725 dst_subview_type dst_sub;
726 src_subview_type src_sub;
727 CommonSubview(
const DstType& dst,
const SrcType& src,
const Arg0& arg0,
const Arg1& arg1,
728 const Arg2& arg2, Args... ):
729 dst_sub(dst,arg0,arg1,arg2),src_sub(src,arg0,arg1,arg2) {}
732 template<
class DstType,
class SrcType,
class Arg0,
class Arg1,
class Arg2,
class Arg3,
734 struct CommonSubview<DstType,SrcType,4,Arg0,Arg1,Arg2,Arg3,Args...> {
735 typedef typename Kokkos::Subview<DstType,Arg0,Arg1,Arg2,Arg3> dst_subview_type;
736 typedef typename Kokkos::Subview<SrcType,Arg0,Arg1,Arg2,Arg3> src_subview_type;
737 dst_subview_type dst_sub;
738 src_subview_type src_sub;
739 CommonSubview(
const DstType& dst,
const SrcType& src,
const Arg0& arg0,
const Arg1& arg1,
740 const Arg2& arg2,
const Arg3& arg3,
742 dst_sub(dst,arg0,arg1,arg2,arg3),src_sub(src,arg0,arg1,arg2,arg3) {}
745 template<
class DstType,
class SrcType,
class Arg0,
class Arg1,
class Arg2,
class Arg3,
746 class Arg4,
class ... Args>
747 struct CommonSubview<DstType,SrcType,5,Arg0,Arg1,Arg2,Arg3,Arg4,Args...> {
748 typedef typename Kokkos::Subview<DstType,Arg0,Arg1,Arg2,Arg3,Arg4> dst_subview_type;
749 typedef typename Kokkos::Subview<SrcType,Arg0,Arg1,Arg2,Arg3,Arg4> src_subview_type;
750 dst_subview_type dst_sub;
751 src_subview_type src_sub;
752 CommonSubview(
const DstType& dst,
const SrcType& src,
const Arg0& arg0,
const Arg1& arg1,
753 const Arg2& arg2,
const Arg3& arg3,
const Arg4& arg4,
755 dst_sub(dst,arg0,arg1,arg2,arg3,arg4),src_sub(src,arg0,arg1,arg2,arg3,arg4) {}
758 template<
class DstType,
class SrcType,
class Arg0,
class Arg1,
class Arg2,
class Arg3,
759 class Arg4,
class Arg5,
class ... Args>
760 struct CommonSubview<DstType,SrcType,6,Arg0,Arg1,Arg2,Arg3,Arg4,Arg5,Args...> {
761 typedef typename Kokkos::Subview<DstType,Arg0,Arg1,Arg2,Arg3,Arg4,Arg5> dst_subview_type;
762 typedef typename Kokkos::Subview<SrcType,Arg0,Arg1,Arg2,Arg3,Arg4,Arg5> src_subview_type;
763 dst_subview_type dst_sub;
764 src_subview_type src_sub;
765 CommonSubview(
const DstType& dst,
const SrcType& src,
const Arg0& arg0,
const Arg1& arg1,
766 const Arg2& arg2,
const Arg3& arg3,
const Arg4& arg4,
const Arg5& arg5,
768 dst_sub(dst,arg0,arg1,arg2,arg3,arg4,arg5),src_sub(src,arg0,arg1,arg2,arg3,arg4,arg5) {}
771 template<
class DstType,
class SrcType,
class Arg0,
class Arg1,
class Arg2,
class Arg3,
772 class Arg4,
class Arg5,
class Arg6,
class ...Args>
773 struct CommonSubview<DstType,SrcType,7,Arg0,Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Args...> {
774 typedef typename Kokkos::Subview<DstType,Arg0,Arg1,Arg2,Arg3,Arg4,Arg5,Arg6> dst_subview_type;
775 typedef typename Kokkos::Subview<SrcType,Arg0,Arg1,Arg2,Arg3,Arg4,Arg5,Arg6> src_subview_type;
776 dst_subview_type dst_sub;
777 src_subview_type src_sub;
778 CommonSubview(
const DstType& dst,
const SrcType& src,
const Arg0& arg0,
const Arg1& arg1,
779 const Arg2& arg2,
const Arg3& arg3,
const Arg4& arg4,
const Arg5& arg5,
780 const Arg6& arg6, Args...):
781 dst_sub(dst,arg0,arg1,arg2,arg3,arg4,arg5,arg6),src_sub(src,arg0,arg1,arg2,arg3,arg4,arg5,arg6) {}
784 template<
class DstType,
class SrcType,
class Arg0,
class Arg1,
class Arg2,
class Arg3,
785 class Arg4,
class Arg5,
class Arg6,
class Arg7>
786 struct CommonSubview<DstType,SrcType,8,Arg0,Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7> {
787 typedef typename Kokkos::Subview<DstType,Arg0,Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7> dst_subview_type;
788 typedef typename Kokkos::Subview<SrcType,Arg0,Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7> src_subview_type;
789 dst_subview_type dst_sub;
790 src_subview_type src_sub;
791 CommonSubview(
const DstType& dst,
const SrcType& src,
const Arg0& arg0,
const Arg1& arg1,
792 const Arg2& arg2,
const Arg3& arg3,
const Arg4& arg4,
const Arg5& arg5,
793 const Arg6& arg6,
const Arg7& arg7):
794 dst_sub(dst,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7),src_sub(src,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7) {}
798 template<
class DstType,
class SrcType,
class ExecSpace =
typename DstType::execution_space,
int Rank = DstType::Rank>
801 template<
class DstType,
class SrcType,
class ExecSpace>
802 struct ViewRemap<DstType,SrcType,ExecSpace,1> {
805 ViewRemap(
const DstType& dst,
const SrcType& src) {
806 if(dst.extent(0) == src.extent(0)) {
809 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
810 typedef CommonSubview<DstType,SrcType,1,p_type> sv_adapter_type;
811 sv_adapter_type common_subview(dst,src,ext0);
812 view_copy(common_subview.dst_sub,common_subview.src_sub);
817 template<
class DstType,
class SrcType,
class ExecSpace>
818 struct ViewRemap<DstType,SrcType,ExecSpace,2> {
821 ViewRemap(
const DstType& dst,
const SrcType& src) {
822 if(dst.extent(0) == src.extent(0)) {
823 if(dst.extent(1) == src.extent(1)) {
826 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
827 typedef CommonSubview<DstType,SrcType,2,Kokkos::Impl::ALL_t,p_type> sv_adapter_type;
828 sv_adapter_type common_subview(dst,src,Kokkos::ALL,ext1);
829 view_copy(common_subview.dst_sub,common_subview.src_sub);
832 if(dst.extent(1) == src.extent(1)) {
833 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
834 typedef CommonSubview<DstType,SrcType,2,p_type,Kokkos::Impl::ALL_t> sv_adapter_type;
835 sv_adapter_type common_subview(dst,src,ext0,Kokkos::ALL);
836 view_copy(common_subview.dst_sub,common_subview.src_sub);
838 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
839 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
840 typedef CommonSubview<DstType,SrcType,2,p_type,p_type> sv_adapter_type;
841 sv_adapter_type common_subview(dst,src,ext0,ext1);
842 view_copy(common_subview.dst_sub,common_subview.src_sub);
848 template<
class DstType,
class SrcType,
class ExecSpace>
849 struct ViewRemap<DstType,SrcType,ExecSpace,3> {
852 ViewRemap(
const DstType& dst,
const SrcType& src) {
853 if(dst.extent(0) == src.extent(0)) {
854 if(dst.extent(2) == src.extent(2)) {
855 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
856 typedef CommonSubview<DstType,SrcType,3,Kokkos::Impl::ALL_t,p_type,Kokkos::Impl::ALL_t> sv_adapter_type;
857 sv_adapter_type common_subview(dst,src,Kokkos::ALL,ext1,Kokkos::ALL);
858 view_copy(common_subview.dst_sub,common_subview.src_sub);
860 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
861 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
862 typedef CommonSubview<DstType,SrcType,3,Kokkos::Impl::ALL_t,p_type,p_type> sv_adapter_type;
863 sv_adapter_type common_subview(dst,src,Kokkos::ALL,ext1,ext2);
864 view_copy(common_subview.dst_sub,common_subview.src_sub);
867 if(dst.extent(2) == src.extent(2)) {
868 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
869 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
870 typedef CommonSubview<DstType,SrcType,3,p_type,p_type,Kokkos::Impl::ALL_t> sv_adapter_type;
871 sv_adapter_type common_subview(dst,src,ext0,ext1,Kokkos::ALL);
872 view_copy(common_subview.dst_sub,common_subview.src_sub);
874 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
875 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
876 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
877 typedef CommonSubview<DstType,SrcType,3,p_type,p_type,p_type> sv_adapter_type;
878 sv_adapter_type common_subview(dst,src,ext0,ext1,ext2);
879 view_copy(common_subview.dst_sub,common_subview.src_sub);
885 template<
class DstType,
class SrcType,
class ExecSpace>
886 struct ViewRemap<DstType,SrcType,ExecSpace,4> {
889 ViewRemap(
const DstType& dst,
const SrcType& src) {
890 if(dst.extent(0) == src.extent(0)) {
891 if(dst.extent(3) == src.extent(3)) {
892 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
893 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
894 typedef CommonSubview<DstType,SrcType,4,Kokkos::Impl::ALL_t,
896 Kokkos::Impl::ALL_t> sv_adapter_type;
897 sv_adapter_type common_subview(dst,src,Kokkos::ALL,
900 view_copy(common_subview.dst_sub,common_subview.src_sub);
902 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
903 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
904 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
905 typedef CommonSubview<DstType,SrcType,4,Kokkos::Impl::ALL_t,
907 p_type> sv_adapter_type;
908 sv_adapter_type common_subview(dst,src,Kokkos::ALL,
911 view_copy(common_subview.dst_sub,common_subview.src_sub);
914 if(dst.extent(7) == src.extent(7)) {
915 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
916 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
917 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
918 typedef CommonSubview<DstType,SrcType,4,p_type,
920 Kokkos::Impl::ALL_t> sv_adapter_type;
921 sv_adapter_type common_subview(dst,src,ext0,
924 view_copy(common_subview.dst_sub,common_subview.src_sub);
926 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
927 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
928 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
929 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
930 typedef CommonSubview<DstType,SrcType,4,p_type,
932 p_type> sv_adapter_type;
933 sv_adapter_type common_subview(dst,src,ext0,
936 view_copy(common_subview.dst_sub,common_subview.src_sub);
942 template<
class DstType,
class SrcType,
class ExecSpace>
943 struct ViewRemap<DstType,SrcType,ExecSpace,5> {
946 ViewRemap(
const DstType& dst,
const SrcType& src) {
947 if(dst.extent(0) == src.extent(0)) {
948 if(dst.extent(4) == src.extent(4)) {
949 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
950 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
951 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
952 typedef CommonSubview<DstType,SrcType,5,Kokkos::Impl::ALL_t,
953 p_type,p_type,p_type,
954 Kokkos::Impl::ALL_t> sv_adapter_type;
955 sv_adapter_type common_subview(dst,src,Kokkos::ALL,
958 view_copy(common_subview.dst_sub,common_subview.src_sub);
960 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
961 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
962 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
963 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
964 typedef CommonSubview<DstType,SrcType,5,Kokkos::Impl::ALL_t,
965 p_type,p_type,p_type,
966 p_type> sv_adapter_type;
967 sv_adapter_type common_subview(dst,src,Kokkos::ALL,
970 view_copy(common_subview.dst_sub,common_subview.src_sub);
973 if(dst.extent(4) == src.extent(4)) {
974 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
975 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
976 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
977 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
978 typedef CommonSubview<DstType,SrcType,5,p_type,
979 p_type,p_type,p_type,
980 Kokkos::Impl::ALL_t> sv_adapter_type;
981 sv_adapter_type common_subview(dst,src,ext0,
984 view_copy(common_subview.dst_sub,common_subview.src_sub);
986 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
987 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
988 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
989 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
990 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
991 typedef CommonSubview<DstType,SrcType,5,p_type,
992 p_type,p_type,p_type,
993 p_type> sv_adapter_type;
994 sv_adapter_type common_subview(dst,src,ext0,
997 view_copy(common_subview.dst_sub,common_subview.src_sub);
1002 template<
class DstType,
class SrcType,
class ExecSpace>
1003 struct ViewRemap<DstType,SrcType,ExecSpace,6> {
1006 ViewRemap(
const DstType& dst,
const SrcType& src) {
1007 if(dst.extent(0) == src.extent(0)) {
1008 if(dst.extent(5) == src.extent(5)) {
1009 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1010 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1011 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1012 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1013 typedef CommonSubview<DstType,SrcType,6,Kokkos::Impl::ALL_t,
1014 p_type,p_type,p_type,p_type,
1015 Kokkos::Impl::ALL_t> sv_adapter_type;
1016 sv_adapter_type common_subview(dst,src,Kokkos::ALL,
1017 ext1,ext2,ext3,ext4,
1019 view_copy(common_subview.dst_sub,common_subview.src_sub);
1021 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1022 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1023 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1024 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1025 p_type ext5(0,std::min(dst.extent(5),src.extent(5)));
1026 typedef CommonSubview<DstType,SrcType,6,Kokkos::Impl::ALL_t,
1027 p_type,p_type,p_type,p_type,
1028 p_type> sv_adapter_type;
1029 sv_adapter_type common_subview(dst,src,Kokkos::ALL,
1030 ext1,ext2,ext3,ext4,
1032 view_copy(common_subview.dst_sub,common_subview.src_sub);
1035 if(dst.extent(5) == src.extent(5)) {
1036 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
1037 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1038 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1039 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1040 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1042 typedef CommonSubview<DstType,SrcType,6,p_type,
1043 p_type,p_type,p_type,p_type,
1044 Kokkos::Impl::ALL_t> sv_adapter_type;
1045 sv_adapter_type common_subview(dst,src,ext0,
1046 ext1,ext2,ext3,ext4,
1048 view_copy(common_subview.dst_sub,common_subview.src_sub);
1050 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
1051 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1052 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1053 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1054 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1055 p_type ext5(0,std::min(dst.extent(5),src.extent(5)));
1057 typedef CommonSubview<DstType,SrcType,6,p_type,
1058 p_type,p_type,p_type,p_type,
1059 p_type> sv_adapter_type;
1060 sv_adapter_type common_subview(dst,src,ext0,
1061 ext1,ext2,ext3,ext4,
1063 view_copy(common_subview.dst_sub,common_subview.src_sub);
1069 template<
class DstType,
class SrcType,
class ExecSpace>
1070 struct ViewRemap<DstType,SrcType,ExecSpace,7> {
1073 ViewRemap(
const DstType& dst,
const SrcType& src) {
1074 if(dst.extent(0) == src.extent(0)) {
1075 if(dst.extent(6) == src.extent(6)) {
1076 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1077 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1078 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1079 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1080 p_type ext5(0,std::min(dst.extent(5),src.extent(5)));
1081 typedef CommonSubview<DstType,SrcType,7,Kokkos::Impl::ALL_t,
1082 p_type,p_type,p_type,p_type,p_type,
1083 Kokkos::Impl::ALL_t> sv_adapter_type;
1084 sv_adapter_type common_subview(dst,src,Kokkos::ALL,
1085 ext1,ext2,ext3,ext4,ext5,
1087 view_copy(common_subview.dst_sub,common_subview.src_sub);
1089 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1090 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1091 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1092 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1093 p_type ext5(0,std::min(dst.extent(5),src.extent(5)));
1094 p_type ext6(0,std::min(dst.extent(6),src.extent(6)));
1095 typedef CommonSubview<DstType,SrcType,7,Kokkos::Impl::ALL_t,
1096 p_type,p_type,p_type,p_type,p_type,
1097 p_type> sv_adapter_type;
1098 sv_adapter_type common_subview(dst,src,Kokkos::ALL,
1099 ext1,ext2,ext3,ext4,ext5,
1101 view_copy(common_subview.dst_sub,common_subview.src_sub);
1104 if(dst.extent(6) == src.extent(6)) {
1105 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
1106 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1107 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1108 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1109 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1110 p_type ext5(0,std::min(dst.extent(5),src.extent(5)));
1111 typedef CommonSubview<DstType,SrcType,7,p_type,
1112 p_type,p_type,p_type,p_type,p_type,
1113 Kokkos::Impl::ALL_t> sv_adapter_type;
1114 sv_adapter_type common_subview(dst,src,ext0,
1115 ext1,ext2,ext3,ext4,ext5,
1117 view_copy(common_subview.dst_sub,common_subview.src_sub);
1119 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
1120 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1121 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1122 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1123 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1124 p_type ext5(0,std::min(dst.extent(5),src.extent(5)));
1125 p_type ext6(0,std::min(dst.extent(6),src.extent(6)));
1126 typedef CommonSubview<DstType,SrcType,7,p_type,
1127 p_type,p_type,p_type,p_type,p_type,
1128 p_type> sv_adapter_type;
1129 sv_adapter_type common_subview(dst,src,ext0,
1130 ext1,ext2,ext3,ext4,ext5,
1132 view_copy(common_subview.dst_sub,common_subview.src_sub);
1138 template<
class DstType,
class SrcType,
class ExecSpace>
1139 struct ViewRemap<DstType,SrcType,ExecSpace,8> {
1142 ViewRemap(
const DstType& dst,
const SrcType& src) {
1143 if(dst.extent(0) == src.extent(0)) {
1144 if(dst.extent(7) == src.extent(7)) {
1145 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1146 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1147 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1148 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1149 p_type ext5(0,std::min(dst.extent(5),src.extent(5)));
1150 p_type ext6(0,std::min(dst.extent(6),src.extent(6)));
1151 typedef CommonSubview<DstType,SrcType,8,Kokkos::Impl::ALL_t,
1152 p_type,p_type,p_type,p_type,p_type,p_type,
1153 Kokkos::Impl::ALL_t> sv_adapter_type;
1154 sv_adapter_type common_subview(dst,src,Kokkos::ALL,
1155 ext1,ext2,ext3,ext4,ext5,ext6,
1157 view_copy(common_subview.dst_sub,common_subview.src_sub);
1159 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1160 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1161 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1162 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1163 p_type ext5(0,std::min(dst.extent(5),src.extent(5)));
1164 p_type ext6(0,std::min(dst.extent(6),src.extent(6)));
1165 p_type ext7(0,std::min(dst.extent(7),src.extent(7)));
1166 typedef CommonSubview<DstType,SrcType,8,Kokkos::Impl::ALL_t,
1167 p_type,p_type,p_type,p_type,p_type,p_type,
1168 p_type> sv_adapter_type;
1169 sv_adapter_type common_subview(dst,src,Kokkos::ALL,
1170 ext1,ext2,ext3,ext4,ext5,ext6,
1172 view_copy(common_subview.dst_sub,common_subview.src_sub);
1175 if(dst.extent(7) == src.extent(7)) {
1176 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
1177 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1178 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1179 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1180 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1181 p_type ext5(0,std::min(dst.extent(5),src.extent(5)));
1182 p_type ext6(0,std::min(dst.extent(6),src.extent(6)));
1183 typedef CommonSubview<DstType,SrcType,8,p_type,
1184 p_type,p_type,p_type,p_type,p_type,p_type,
1185 Kokkos::Impl::ALL_t> sv_adapter_type;
1186 sv_adapter_type common_subview(dst,src,ext0,
1187 ext1,ext2,ext3,ext4,ext5,ext6,
1189 view_copy(common_subview.dst_sub,common_subview.src_sub);
1191 p_type ext0(0,std::min(dst.extent(0),src.extent(0)));
1192 p_type ext1(0,std::min(dst.extent(1),src.extent(1)));
1193 p_type ext2(0,std::min(dst.extent(2),src.extent(2)));
1194 p_type ext3(0,std::min(dst.extent(3),src.extent(3)));
1195 p_type ext4(0,std::min(dst.extent(4),src.extent(4)));
1196 p_type ext5(0,std::min(dst.extent(5),src.extent(5)));
1197 p_type ext6(0,std::min(dst.extent(6),src.extent(6)));
1198 p_type ext7(0,std::min(dst.extent(7),src.extent(7)));
1199 typedef CommonSubview<DstType,SrcType,8,p_type,
1200 p_type,p_type,p_type,p_type,p_type,p_type,
1201 p_type> sv_adapter_type;
1202 sv_adapter_type common_subview(dst,src,ext0,
1203 ext1,ext2,ext3,ext4,ext5,ext6,
1205 view_copy(common_subview.dst_sub,common_subview.src_sub);
1214 template<
class DT ,
class ... DP >
1218 ,
typename ViewTraits<DT,DP...>::const_value_type & value
1219 ,
typename std::enable_if<
1220 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value
1223 typedef View<DT,DP...> ViewType;
1224 if(dst.data() == NULL ) {
1231 std::is_same<
typename ViewType::non_const_value_type ,
1232 typename ViewType::value_type >::value
1233 ,
"deep_copy requires non-const type" );
1236 if(dst.span_is_contiguous()) {
1238 Kokkos::Device<
typename ViewType::execution_space,
1239 typename std::conditional<ViewType::Rank==0,
1240 typename ViewType::memory_space,Kokkos::AnonymousSpace
1242 Kokkos::MemoryTraits<0> >
1245 ViewTypeFlat dst_flat(dst.data(),dst.size());
1246 if(dst.span() < std::numeric_limits<int>::max())
1247 Kokkos::Impl::ViewFill< ViewTypeFlat , Kokkos::LayoutRight, typename ViewType::execution_space, ViewTypeFlat::Rank, int >( dst_flat , value );
1249 Kokkos::Impl::ViewFill< ViewTypeFlat , Kokkos::LayoutRight, typename ViewType::execution_space, ViewTypeFlat::Rank, int64_t >( dst_flat , value );
1255 int64_t strides[ViewType::Rank+1];
1256 dst.stride(strides);
1257 Kokkos::Iterate iterate;
1258 if ( std::is_same<typename ViewType::array_layout,Kokkos::LayoutRight>::value ) {
1259 iterate = Kokkos::Iterate::Right;
1260 }
else if ( std::is_same<typename ViewType::array_layout,Kokkos::LayoutLeft>::value ) {
1261 iterate = Kokkos::Iterate::Left;
1262 }
else if ( std::is_same<typename ViewType::array_layout,Kokkos::LayoutStride>::value ) {
1263 if( strides[0] > strides[ViewType::Rank>0?ViewType::Rank-1:0] )
1264 iterate = Kokkos::Iterate::Right;
1266 iterate = Kokkos::Iterate::Left;
1268 if( std::is_same<typename ViewType::execution_space::array_layout, Kokkos::LayoutRight>::value )
1269 iterate = Kokkos::Iterate::Right;
1271 iterate = Kokkos::Iterate::Left;
1275 typedef typename std::conditional<ViewType::Rank==0,
1276 typename ViewType::uniform_runtime_type,
1277 typename ViewType::uniform_runtime_nomemspace_type>::type ViewTypeUniform;
1278 if(dst.span() > std::numeric_limits<int>::max()) {
1279 if(iterate == Kokkos::Iterate::Right)
1280 Kokkos::Impl::ViewFill< ViewTypeUniform, Kokkos::LayoutRight, typename ViewType::execution_space, ViewType::Rank, int64_t >( dst , value );
1282 Kokkos::Impl::ViewFill< ViewTypeUniform, Kokkos::LayoutLeft, typename ViewType::execution_space, ViewType::Rank, int64_t >( dst , value );
1284 if(iterate == Kokkos::Iterate::Right)
1285 Kokkos::Impl::ViewFill< ViewTypeUniform, Kokkos::LayoutRight, typename ViewType::execution_space, ViewType::Rank, int >( dst , value );
1287 Kokkos::Impl::ViewFill< ViewTypeUniform, Kokkos::LayoutLeft, typename ViewType::execution_space, ViewType::Rank, int >( dst , value );
1293 template<
class ST ,
class ... SP >
1296 (
typename ViewTraits<ST,SP...>::non_const_value_type & dst
1298 ,
typename std::enable_if<
1299 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value
1303 ,
"ERROR: Non-rank-zero view in deep_copy( value , View )" );
1305 if(src.data() == NULL) {
1311 typedef typename src_traits::memory_space src_memory_space ;
1312 Kokkos::Impl::DeepCopy< HostSpace , src_memory_space >( & dst , src.data() ,
sizeof(ST) );
1317 template<
class DT ,
class ... DP ,
class ST ,
class ... SP >
1322 ,
typename std::enable_if<(
1323 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value &&
1324 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value &&
1330 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
1331 typename ViewTraits<ST,SP...>::non_const_value_type >::value
1332 ,
"deep_copy requires matching non-const destination type" );
1334 if(dst.data() == NULL && src.data() == NULL) {
1339 typedef View<DT,DP...> dst_type ;
1340 typedef View<ST,SP...> src_type ;
1342 typedef typename dst_type::value_type value_type ;
1343 typedef typename dst_type::memory_space dst_memory_space ;
1344 typedef typename src_type::memory_space src_memory_space ;
1347 if ( dst.data() != src.data() ) {
1348 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() ,
sizeof(value_type) );
1357 template<
class DT ,
class ... DP ,
class ST ,
class ... SP >
1362 ,
typename std::enable_if<(
1363 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value &&
1364 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value &&
1369 typedef View<DT,DP...> dst_type ;
1370 typedef View<ST,SP...> src_type ;
1373 std::is_same<
typename dst_type::value_type ,
1374 typename dst_type::non_const_value_type >::value
1375 ,
"deep_copy requires non-const destination type" );
1378 (
unsigned(dst_type::rank) ==
1379 unsigned(src_type::rank) )
1380 ,
"deep_copy requires Views of equal rank" );
1383 typedef typename dst_type::execution_space dst_execution_space ;
1384 typedef typename src_type::execution_space src_execution_space ;
1385 typedef typename dst_type::memory_space dst_memory_space ;
1386 typedef typename src_type::memory_space src_memory_space ;
1387 typedef typename dst_type::value_type dst_value_type ;
1388 typedef typename src_type::value_type src_value_type ;
1389 if(dst.data() == NULL && src.data() == NULL) {
1394 enum { DstExecCanAccessSrc =
1397 enum { SrcExecCanAccessDst =
1402 dst_value_type* dst_start = dst.data();
1403 dst_value_type* dst_end = dst.data() + dst.span();
1404 src_value_type* src_start = src.data();
1405 src_value_type* src_end = src.data() + src.span();
1406 if( ((std::ptrdiff_t)dst_start == (std::ptrdiff_t)src_start) &&
1407 ((std::ptrdiff_t)dst_end == (std::ptrdiff_t)src_end) &&
1408 (dst.span_is_contiguous() && src.span_is_contiguous()) ) {
1413 if( ( ( (std::ptrdiff_t)dst_start < (std::ptrdiff_t)src_end ) && ( (std::ptrdiff_t)dst_end > (std::ptrdiff_t)src_start ) ) &&
1414 ( ( dst.span_is_contiguous() && src.span_is_contiguous() ))) {
1415 std::string message(
"Error: Kokkos::deep_copy of overlapping views: ");
1416 message += dst.label(); message +=
"(";
1417 message += std::to_string((std::ptrdiff_t)dst_start); message +=
",";
1418 message += std::to_string((std::ptrdiff_t)dst_end); message +=
") ";
1419 message += src.label(); message +=
"(";
1420 message += std::to_string((std::ptrdiff_t)src_start); message +=
",";
1421 message += std::to_string((std::ptrdiff_t)src_end); message +=
") ";
1422 Kokkos::Impl::throw_runtime_exception(message);
1435 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 1437 if ( DstExecCanAccessSrc ) {
1439 Kokkos::Impl::ViewRemap< dst_type , src_type >( dst , src );
1441 else if ( SrcExecCanAccessDst ) {
1443 Kokkos::Impl::ViewRemap< dst_type , src_type , src_execution_space >( dst , src );
1446 Kokkos::Impl::throw_runtime_exception(
"deep_copy given views that would require a temporary allocation");
1451 std::string message(
"Deprecation Error: Kokkos::deep_copy extents of views don't match: ");
1452 message += dst.label(); message +=
"(";
1453 for(
int r = 0; r<dst_type::Rank-1; r++)
1454 { message+= std::to_string(dst.
extent(r)); message +=
","; }
1455 message+= std::to_string(dst.
extent(dst_type::Rank-1)); message +=
") ";
1456 message += src.label(); message +=
"(";
1457 for(
int r = 0; r<src_type::Rank-1; r++)
1458 { message+= std::to_string(src.
extent(r)); message +=
","; }
1459 message+= std::to_string(src.
extent(src_type::Rank-1)); message +=
") ";
1461 Kokkos::Impl::throw_runtime_exception(message);
1467 if ( std::is_same<
typename dst_type::value_type ,
1468 typename src_type::non_const_value_type >::value &&
1470 std::is_same<
typename dst_type::array_layout ,
1471 typename src_type::array_layout >::value
1473 ( dst_type::rank == 1 &&
1474 src_type::rank == 1 )
1476 dst.span_is_contiguous() &&
1477 src.span_is_contiguous() &&
1478 ((dst_type::rank < 1) || (dst.stride_0() == src.stride_0())) &&
1479 ((dst_type::rank < 2) || (dst.stride_1() == src.stride_1())) &&
1480 ((dst_type::rank < 3) || (dst.stride_2() == src.stride_2())) &&
1481 ((dst_type::rank < 4) || (dst.stride_3() == src.stride_3())) &&
1482 ((dst_type::rank < 5) || (dst.stride_4() == src.stride_4())) &&
1483 ((dst_type::rank < 6) || (dst.stride_5() == src.stride_5())) &&
1484 ((dst_type::rank < 7) || (dst.stride_6() == src.stride_6())) &&
1485 ((dst_type::rank < 8) || (dst.stride_7() == src.stride_7()))
1487 const size_t nbytes =
sizeof(
typename dst_type::value_type) * dst.span();
1489 if((
void*)dst.data()!=(
void*)src.data()) {
1490 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >
1491 ( dst.data() , src.data() , nbytes );
1496 Impl::view_copy(dst, src);
1509 template<
class ExecSpace ,
class DT ,
class ... DP >
1514 ,
typename ViewTraits<DT,DP...>::const_value_type & value
1515 ,
typename std::enable_if<
1516 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
1517 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value
1521 std::is_same<
typename ViewTraits<DT,DP...>::non_const_value_type ,
1522 typename ViewTraits<DT,DP...>::value_type >::value
1523 ,
"deep_copy requires non-const type" );
1526 typedef typename View<DT,DP...>::uniform_runtime_nomemspace_type ViewTypeUniform;
1527 Kokkos::Impl::ViewFill< ViewTypeUniform >( dst , value );
1532 template<
class ExecSpace ,
class ST ,
class ... SP >
1535 (
const ExecSpace & exec_space
1536 ,
typename ViewTraits<ST,SP...>::non_const_value_type & dst
1538 ,
typename std::enable_if<
1539 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
1540 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value
1544 ,
"ERROR: Non-rank-zero view in deep_copy( value , View )" );
1546 if(src.data() == NULL) {
1552 typedef typename src_traits::memory_space src_memory_space ;
1553 Kokkos::Impl::DeepCopy< HostSpace , src_memory_space , ExecSpace >
1554 ( exec_space , & dst , src.data() ,
sizeof(ST) );
1559 template<
class ExecSpace ,
class DT ,
class ... DP ,
class ST ,
class ... SP >
1562 (
const ExecSpace & exec_space
1565 ,
typename std::enable_if<(
1566 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
1567 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value &&
1568 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value &&
1574 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
1575 typename ViewTraits<ST,SP...>::non_const_value_type >::value
1576 ,
"deep_copy requires matching non-const destination type" );
1578 typedef View<DT,DP...> dst_type ;
1579 typedef View<ST,SP...> src_type ;
1581 typedef typename dst_type::value_type value_type ;
1582 typedef typename dst_type::memory_space dst_memory_space ;
1583 typedef typename src_type::memory_space src_memory_space ;
1584 if(dst.data() == NULL && src.data() == NULL) {
1590 if ( dst.data() != src.data() ) {
1591 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space , ExecSpace >
1592 ( exec_space , dst.data() , src.data() ,
sizeof(value_type) );
1601 template<
class ExecSpace ,
class DT,
class ... DP,
class ST,
class ... SP >
1604 (
const ExecSpace & exec_space
1607 ,
typename std::enable_if<(
1608 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
1609 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value &&
1610 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value &&
1615 typedef View<DT,DP...> dst_type ;
1616 typedef View<ST,SP...> src_type ;
1619 std::is_same<
typename dst_type::value_type ,
1620 typename dst_type::non_const_value_type >::value
1621 ,
"deep_copy requires non-const destination type" );
1624 (
unsigned(dst_type::rank) ==
1625 unsigned(src_type::rank) )
1626 ,
"deep_copy requires Views of equal rank" );
1628 typedef typename dst_type::execution_space dst_execution_space ;
1629 typedef typename src_type::execution_space src_execution_space ;
1630 typedef typename dst_type::memory_space dst_memory_space ;
1631 typedef typename src_type::memory_space src_memory_space ;
1632 typedef typename dst_type::value_type dst_value_type ;
1633 typedef typename src_type::value_type src_value_type ;
1635 if(dst.data() == NULL && src.data() == NULL) {
1640 enum { ExecCanAccessSrcDst =
1644 enum { DstExecCanAccessSrc =
1647 enum { SrcExecCanAccessDst =
1651 dst_value_type* dst_start = dst.data();
1652 dst_value_type* dst_end = dst.data() + dst.span();
1653 src_value_type* src_start = src.data();
1654 src_value_type* src_end = src.data() + src.span();
1655 if( ( ( (std::ptrdiff_t)dst_start < (std::ptrdiff_t)src_end ) && ( (std::ptrdiff_t)dst_end > (std::ptrdiff_t)src_start ) ) &&
1656 ( ( dst.span_is_contiguous() && src.span_is_contiguous() ))) {
1657 std::string message(
"Error: Kokkos::deep_copy of overlapping views: ");
1658 message += dst.label(); message +=
"(";
1659 message += std::to_string((std::ptrdiff_t)dst_start); message +=
",";
1660 message += std::to_string((std::ptrdiff_t)dst_end); message +=
") ";
1661 message += src.label(); message +=
"(";
1662 message += std::to_string((std::ptrdiff_t)src_start); message +=
",";
1663 message += std::to_string((std::ptrdiff_t)src_end); message +=
") ";
1664 Kokkos::Impl::throw_runtime_exception(message);
1677 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 1679 if ( ExecCanAccessSrcDst ) {
1680 Kokkos::Impl::ViewRemap< dst_type , src_type , ExecSpace >( dst , src );
1682 else if ( DstExecCanAccessSrc ) {
1684 Kokkos::Impl::ViewRemap< dst_type , src_type >( dst , src );
1686 else if ( SrcExecCanAccessDst ) {
1688 Kokkos::Impl::ViewRemap< dst_type , src_type , src_execution_space >( dst , src );
1691 Kokkos::Impl::throw_runtime_exception(
"deep_copy given views that would require a temporary allocation");
1696 std::string message(
"Deprecation Error: Kokkos::deep_copy extents of views don't match: ");
1697 message += dst.label(); message +=
"(";
1698 for(
int r = 0; r<dst_type::Rank-1; r++)
1699 { message+= std::to_string(dst.
extent(r)); message +=
","; }
1700 message+= std::to_string(dst.
extent(dst_type::Rank-1)); message +=
") ";
1701 message += src.label(); message +=
"(";
1702 for(
int r = 0; r<src_type::Rank-1; r++)
1703 { message+= std::to_string(src.
extent(r)); message +=
","; }
1704 message+= std::to_string(src.
extent(src_type::Rank-1)); message +=
") ";
1706 Kokkos::Impl::throw_runtime_exception(message);
1712 if ( std::is_same<
typename dst_type::value_type ,
1713 typename src_type::non_const_value_type >::value &&
1715 std::is_same<
typename dst_type::array_layout ,
1716 typename src_type::array_layout >::value
1718 ( dst_type::rank == 1 &&
1719 src_type::rank == 1 )
1721 dst.span_is_contiguous() &&
1722 src.span_is_contiguous() &&
1723 ((dst_type::rank < 1) || (dst.stride_0() == src.stride_0())) &&
1724 ((dst_type::rank < 2) || (dst.stride_1() == src.stride_1())) &&
1725 ((dst_type::rank < 3) || (dst.stride_2() == src.stride_2())) &&
1726 ((dst_type::rank < 4) || (dst.stride_3() == src.stride_3())) &&
1727 ((dst_type::rank < 5) || (dst.stride_4() == src.stride_4())) &&
1728 ((dst_type::rank < 6) || (dst.stride_5() == src.stride_5())) &&
1729 ((dst_type::rank < 7) || (dst.stride_6() == src.stride_6())) &&
1730 ((dst_type::rank < 8) || (dst.stride_7() == src.stride_7()))
1733 const size_t nbytes =
sizeof(
typename dst_type::value_type) * dst.span();
1735 if((
void*)dst.data() != (
void*)src.data()) {
1736 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space , ExecSpace >
1737 ( exec_space , dst.data() , src.data() , nbytes );
1742 Impl::view_copy(dst, src);
1755 template<
class T ,
class ... P >
1757 typename std::enable_if<
1762 const size_t n0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1763 const size_t n1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1764 const size_t n2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1765 const size_t n3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1766 const size_t n4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1767 const size_t n5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1768 const size_t n6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1769 const size_t n7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG )
1780 if (view_type::Rank == 1 &&
1781 n0 == static_cast<size_t> (v.
extent(0))) {
1784 if (view_type::Rank == 2 &&
1785 n0 == static_cast<size_t> (v.
extent(0)) &&
1786 n1 == static_cast<size_t> (v.
extent(1))) {
1789 if (view_type::Rank == 3 &&
1790 n0 == static_cast<size_t> (v.
extent(0)) &&
1791 n1 == static_cast<size_t> (v.
extent(1)) &&
1792 n2 == static_cast<size_t> (v.
extent(2))) {
1795 if (view_type::Rank == 4 &&
1796 n0 == static_cast<size_t> (v.
extent(0)) &&
1797 n1 == static_cast<size_t> (v.
extent(1)) &&
1798 n2 == static_cast<size_t> (v.
extent(2)) &&
1799 n3 == static_cast<size_t> (v.
extent(3))) {
1802 if (view_type::Rank == 5 &&
1803 n0 == static_cast<size_t> (v.
extent(0)) &&
1804 n1 == static_cast<size_t> (v.
extent(1)) &&
1805 n2 == static_cast<size_t> (v.
extent(2)) &&
1806 n3 == static_cast<size_t> (v.
extent(3)) &&
1807 n4 == static_cast<size_t> (v.
extent(4))) {
1810 if (view_type::Rank == 6 &&
1811 n0 == static_cast<size_t> (v.
extent(0)) &&
1812 n1 == static_cast<size_t> (v.
extent(1)) &&
1813 n2 == static_cast<size_t> (v.
extent(2)) &&
1814 n3 == static_cast<size_t> (v.
extent(3)) &&
1815 n4 == static_cast<size_t> (v.
extent(4)) &&
1816 n5 == static_cast<size_t> (v.
extent(5))) {
1819 if (view_type::Rank == 7 &&
1820 n0 == static_cast<size_t> (v.
extent(0)) &&
1821 n1 == static_cast<size_t> (v.
extent(1)) &&
1822 n2 == static_cast<size_t> (v.
extent(2)) &&
1823 n3 == static_cast<size_t> (v.
extent(3)) &&
1824 n4 == static_cast<size_t> (v.
extent(4)) &&
1825 n5 == static_cast<size_t> (v.
extent(5)) &&
1826 n6 == static_cast<size_t> (v.
extent(6))) {
1829 if (view_type::Rank == 8 &&
1830 n0 == static_cast<size_t> (v.
extent(0)) &&
1831 n1 == static_cast<size_t> (v.
extent(1)) &&
1832 n2 == static_cast<size_t> (v.
extent(2)) &&
1833 n3 == static_cast<size_t> (v.
extent(3)) &&
1834 n4 == static_cast<size_t> (v.
extent(4)) &&
1835 n5 == static_cast<size_t> (v.
extent(5)) &&
1836 n6 == static_cast<size_t> (v.
extent(6)) &&
1837 n7 == static_cast<size_t> (v.
extent(7))) {
1851 view_type v_resized( v.label(), n0, n1, n2, n3, n4, n5, n6, n7 );
1853 Kokkos::Impl::ViewRemap< view_type , view_type >( v_resized , v );
1859 template<
class T ,
class ... P >
1862 const typename Kokkos::View<T,P...>::array_layout & layout)
1868 view_type v_resized( v.label(), layout );
1870 Kokkos::Impl::ViewRemap< view_type , view_type >( v_resized , v );
1876 template<
class T ,
class ... P >
1878 typename std::enable_if<
1883 const size_t n0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1884 const size_t n1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1885 const size_t n2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1886 const size_t n3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1887 const size_t n4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1888 const size_t n5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1889 const size_t n6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG ,
1890 const size_t n7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG )
1896 const std::string label = v.label();
1899 v = view_type( label, n0, n1, n2, n3, n4, n5, n6, n7 );
1903 template<
class T ,
class ... P >
1906 const typename Kokkos::View<T,P...>::array_layout & layout)
1912 const std::string label = v.label();
1915 v = view_type( label, layout );
1926 template<
class Space,
class T,
class ... P>
1927 struct MirrorViewType {
1931 typedef typename Space::memory_space memory_space;
1933 enum { is_same_memspace = std::is_same<memory_space,typename src_view_type::memory_space>::value };
1935 typedef typename src_view_type::array_layout array_layout;
1937 typedef typename src_view_type::non_const_data_type data_type;
1942 typedef typename std::conditional<is_same_memspace,src_view_type,dest_view_type>::type view_type;
1945 template<
class Space,
class T,
class ... P>
1950 typedef typename Space::memory_space memory_space;
1952 enum { is_same_memspace = std::is_same<memory_space,typename src_view_type::memory_space>::value };
1954 typedef typename src_view_type::array_layout array_layout;
1956 typedef typename src_view_type::non_const_data_type data_type;
1963 template<
class T ,
class ... P >
1967 ,
typename std::enable_if<
1968 std::is_same<
typename ViewTraits<T,P...>::specialize ,
void >::value &&
1969 ! std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout
1974 typedef View<T,P...> src_type ;
1975 typedef typename src_type::HostMirror dst_type ;
1977 return dst_type( std::string( src.label() ).append(
"_mirror")
1978 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 1988 , src.rank_dynamic > 0 ? src.
extent(0): KOKKOS_IMPL_CTOR_DEFAULT_ARG
1989 , src.rank_dynamic > 1 ? src.
extent(1): KOKKOS_IMPL_CTOR_DEFAULT_ARG
1990 , src.rank_dynamic > 2 ? src.
extent(2): KOKKOS_IMPL_CTOR_DEFAULT_ARG
1991 , src.rank_dynamic > 3 ? src.
extent(3): KOKKOS_IMPL_CTOR_DEFAULT_ARG
1992 , src.rank_dynamic > 4 ? src.
extent(4): KOKKOS_IMPL_CTOR_DEFAULT_ARG
1993 , src.rank_dynamic > 5 ? src.
extent(5): KOKKOS_IMPL_CTOR_DEFAULT_ARG
1994 , src.rank_dynamic > 6 ? src.
extent(6): KOKKOS_IMPL_CTOR_DEFAULT_ARG
1995 , src.rank_dynamic > 7 ? src.
extent(7): KOKKOS_IMPL_CTOR_DEFAULT_ARG );
1999 template<
class T ,
class ... P >
2003 ,
typename std::enable_if<
2004 std::is_same<
typename ViewTraits<T,P...>::specialize ,
void >::value &&
2005 std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout
2010 typedef View<T,P...> src_type ;
2011 typedef typename src_type::HostMirror dst_type ;
2015 layout.dimension[0] = src.
extent(0);
2016 layout.dimension[1] = src.
extent(1);
2017 layout.dimension[2] = src.
extent(2);
2018 layout.dimension[3] = src.
extent(3);
2019 layout.dimension[4] = src.
extent(4);
2020 layout.dimension[5] = src.
extent(5);
2021 layout.dimension[6] = src.
extent(6);
2022 layout.dimension[7] = src.
extent(7);
2024 layout.stride[0] = src.stride_0();
2025 layout.stride[1] = src.stride_1();
2026 layout.stride[2] = src.stride_2();
2027 layout.stride[3] = src.stride_3();
2028 layout.stride[4] = src.stride_4();
2029 layout.stride[5] = src.stride_5();
2030 layout.stride[6] = src.stride_6();
2031 layout.stride[7] = src.stride_7();
2033 return dst_type( std::string( src.label() ).append(
"_mirror") , layout );
2038 template<
class Space,
class T,
class ... P>
2039 typename Impl::MirrorType<Space,T,P ...>::view_type
2041 ,
typename std::enable_if<
2042 std::is_same<
typename ViewTraits<T,P...>::specialize ,
void >::value
2044 return typename Impl::MirrorType<Space,T,P ...>::view_type(src.label(),src.layout());
2047 template<
class T ,
class ... P >
2051 ,
typename std::enable_if<(
2052 std::is_same<
typename Kokkos::View<T,P...>::memory_space
2053 ,
typename Kokkos::View<T,P...>::HostMirror::memory_space
2056 std::is_same<
typename Kokkos::View<T,P...>::data_type
2057 ,
typename Kokkos::View<T,P...>::HostMirror::data_type
2065 template<
class T ,
class ... P >
2069 ,
typename std::enable_if< ! (
2070 std::is_same<
typename Kokkos::View<T,P...>::memory_space
2071 ,
typename Kokkos::View<T,P...>::HostMirror::memory_space
2074 std::is_same<
typename Kokkos::View<T,P...>::data_type
2075 ,
typename Kokkos::View<T,P...>::HostMirror::data_type
2080 return Kokkos::create_mirror( src );
2084 template<
class Space,
class T,
class ... P>
2085 typename Impl::MirrorViewType<Space,T,P ...>::view_type
2087 ,
typename std::enable_if<Impl::MirrorViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
2092 template<
class Space,
class T,
class ... P>
2093 typename Impl::MirrorViewType<Space,T,P ...>::view_type
2095 ,
typename std::enable_if<!Impl::MirrorViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
2096 return typename Impl::MirrorViewType<Space,T,P ...>::view_type(src.label(),src.layout());
2100 template<
class Space,
class T,
class ... P>
2101 typename Impl::MirrorViewType<Space,T,P ...>::view_type
2103 , std::string
const& name =
"" 2104 ,
typename std::enable_if<Impl::MirrorViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
2110 template<
class Space,
class T,
class ... P>
2111 typename Impl::MirrorViewType<Space,T,P ...>::view_type
2113 , std::string
const& name =
"" 2114 ,
typename std::enable_if<!Impl::MirrorViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
2115 using Mirror =
typename Impl::MirrorViewType<Space,T,P ...>::view_type;
2116 std::string label = name.empty() ? src.label() : name;
2117 auto mirror = Mirror(ViewAllocateWithoutInitializing(label), src.layout());
void parallel_for(const ExecPolicy &policy, const FunctorType &functor, const std::string &str="", typename Impl::enable_if< Kokkos::Impl::is_execution_policy< ExecPolicy >::value >::type *=0)
Execute functor in parallel according to the execution policy.
Memory layout tag indicating left-to-right (Fortran scheme) striding of multi-indices.
Can AccessSpace access MemorySpace ?
Replacement for std::pair that works on CUDA devices.
Memory layout tag indicated arbitrarily strided multi-index mapping into contiguous memory...
View to an array of data.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices...
std::enable_if< std::is_same< typename Kokkos::View< T, P... >::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::View< T, P... >::array_layout, Kokkos::LayoutRight >::value >::type resize(Kokkos::View< T, P... > &v, const size_t n0=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n1=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n2=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n3=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n4=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n5=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n6=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n7=KOKKOS_IMPL_CTOR_DEFAULT_ARG)
Resize a view with copying old data to new data at the corresponding indices.
void deep_copy(const View< DT, DP... > &dst, typename ViewTraits< DT, DP... >::const_value_type &value, typename std::enable_if< std::is_same< typename ViewTraits< DT, DP... >::specialize, void >::value >::type *=0)
Deep copy a value from Host memory into a view.
Execution policy for work over a range of an integral type.
Traits class for accessing attributes of a View.
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< std::is_integral< iType >::value, size_t >::type extent(const iType &r) const
rank() to be implemented
std::enable_if< std::is_same< typename Kokkos::View< T, P... >::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::View< T, P... >::array_layout, Kokkos::LayoutRight >::value >::type realloc(Kokkos::View< T, P... > &v, const size_t n0=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n1=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n2=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n3=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n4=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n5=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n6=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n7=KOKKOS_IMPL_CTOR_DEFAULT_ARG)
Resize a view with discarding old data.