51 #ifndef KOKKOS_DUALVIEW_HPP 
   52 #define KOKKOS_DUALVIEW_HPP 
   54 #include <Kokkos_Core.hpp> 
   55 #include <impl/Kokkos_Error.hpp> 
   94 template <
class DataType, 
class Arg1Type = void, 
class Arg2Type = void,
 
   95           class Arg3Type = 
void>
 
   96 class DualView : 
public ViewTraits<DataType, Arg1Type, Arg2Type, Arg3Type> {
 
   97   template <
class, 
class, 
class, 
class>
 
   98   friend class DualView;
 
  103   typedef ViewTraits<DataType, Arg1Type, Arg2Type, Arg3Type> traits;
 
  106   typedef typename traits::host_mirror_space host_mirror_space;
 
  109   typedef View<typename traits::data_type, Arg1Type, Arg2Type, Arg3Type> t_dev;
 
  117   typedef View<typename traits::const_data_type, Arg1Type, Arg2Type, Arg3Type>
 
  125   typedef View<
typename traits::const_data_type, 
typename traits::array_layout,
 
  126                typename traits::device_type,
 
  127                Kokkos::MemoryTraits<Kokkos::RandomAccess> >
 
  128       t_dev_const_randomread;
 
  136   typedef View<
typename traits::data_type, 
typename traits::array_layout,
 
  137                typename traits::device_type, MemoryUnmanaged>
 
  141   typedef View<
typename t_host::data_type, 
typename t_host::array_layout,
 
  142                typename t_host::device_type, MemoryUnmanaged>
 
  146   typedef View<
typename traits::const_data_type, 
typename traits::array_layout,
 
  147                typename traits::device_type, MemoryUnmanaged>
 
  151   typedef View<
typename t_host::const_data_type, 
typename t_host::array_layout,
 
  152                typename t_host::device_type, MemoryUnmanaged>
 
  156   typedef View<
typename t_host::const_data_type, 
typename t_host::array_layout,
 
  157                typename t_host::device_type,
 
  158                Kokkos::MemoryTraits<Kokkos::Unmanaged | Kokkos::RandomAccess> >
 
  159       t_dev_const_randomread_um;
 
  178 #ifndef KOKKOS_ENABLE_DEPRECATED_CODE 
  182   typedef View<unsigned int[2], LayoutLeft, Kokkos::HostSpace> t_modified_flags;
 
  183   t_modified_flags modified_flags;
 
  187   typedef View<unsigned int[2], LayoutLeft, typename t_host::execution_space>
 
  189   typedef View<unsigned int, LayoutLeft, typename t_host::execution_space>
 
  191   t_modified_flags modified_flags;
 
  192   t_modified_flag modified_host, modified_device;
 
  204 #ifndef KOKKOS_ENABLE_DEPRECATED_CODE 
  205   DualView() = 
default;
 
  207   DualView() : modified_flags(t_modified_flags(
"DualView::modified_flags")) {
 
  208     modified_host   = t_modified_flag(modified_flags, 0);
 
  209     modified_device = t_modified_flag(modified_flags, 1);
 
  222   DualView(
const std::string& label,
 
  223            const size_t n0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  224            const size_t n1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  225            const size_t n2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  226            const size_t n3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  227            const size_t n4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  228            const size_t n5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  229            const size_t n6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  230            const size_t n7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG)
 
  231       : d_view(label, n0, n1, n2, n3, n4, n5, n6, n7),
 
  232         h_view(create_mirror_view(d_view))  
 
  234         modified_flags(t_modified_flags(
"DualView::modified_flags")) {
 
  235 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 
  236     modified_host   = t_modified_flag(modified_flags, 0);
 
  237     modified_device = t_modified_flag(modified_flags, 1);
 
  251   template <
class... P>
 
  252   DualView(
const Impl::ViewCtorProp<P...>& arg_prop,
 
  253            typename std::enable_if<!Impl::ViewCtorProp<P...>::has_pointer,
 
  254                                    size_t>::type 
const n0 =
 
  255                KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  256            const size_t n1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  257            const size_t n2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  258            const size_t n3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  259            const size_t n4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  260            const size_t n5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  261            const size_t n6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  262            const size_t n7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG)
 
  263       : d_view(arg_prop, n0, n1, n2, n3, n4, n5, n6, n7),
 
  264         h_view(create_mirror_view(d_view))  
 
  266         modified_flags(t_modified_flags(
"DualView::modified_flags")) {
 
  267 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 
  268     modified_host   = t_modified_flag(modified_flags, 0);
 
  269     modified_device = t_modified_flag(modified_flags, 1);
 
  273   explicit inline DualView(
const ViewAllocateWithoutInitializing& arg_prop,
 
  274                            const size_t arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  275                            const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  276                            const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  277                            const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  278                            const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  279                            const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  280                            const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  281                            const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG)
 
  282       : DualView(Impl::ViewCtorProp<std::string,
 
  283                                     Kokkos::Impl::WithoutInitializing_t>(
 
  284                      arg_prop.label, Kokkos::WithoutInitializing),
 
  285                  arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6,
 
  289   template <
class SS, 
class LS, 
class DS, 
class MS>
 
  290   DualView(
const DualView<SS, LS, DS, MS>& src)
 
  291       : d_view(src.d_view),
 
  293         modified_flags(src.modified_flags)
 
  294 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
 
  296         modified_host(src.modified_host),
 
  297         modified_device(src.modified_device)
 
  303   template <
class SD, 
class S1, 
class S2, 
class S3, 
class Arg0, 
class... Args>
 
  304   DualView(
const DualView<SD, S1, S2, S3>& src, 
const Arg0& arg0, Args... args)
 
  305       : d_view(Kokkos::subview(src.d_view, arg0, args...)),
 
  306         h_view(Kokkos::subview(src.h_view, arg0, args...)),
 
  307         modified_flags(src.modified_flags)
 
  308 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
 
  310         modified_host(src.modified_host),
 
  311         modified_device(src.modified_device)
 
  326   DualView(
const t_dev& d_view_, 
const t_host& h_view_)
 
  329         modified_flags(t_modified_flags(
"DualView::modified_flags")) {
 
  330     if (
int(d_view.rank) != 
int(h_view.rank) ||
 
  331         d_view.extent(0) != h_view.extent(0) ||
 
  332         d_view.extent(1) != h_view.extent(1) ||
 
  333         d_view.extent(2) != h_view.extent(2) ||
 
  334         d_view.extent(3) != h_view.extent(3) ||
 
  335         d_view.extent(4) != h_view.extent(4) ||
 
  336         d_view.extent(5) != h_view.extent(5) ||
 
  337         d_view.extent(6) != h_view.extent(6) ||
 
  338         d_view.extent(7) != h_view.extent(7) ||
 
  339         d_view.stride_0() != h_view.stride_0() ||
 
  340         d_view.stride_1() != h_view.stride_1() ||
 
  341         d_view.stride_2() != h_view.stride_2() ||
 
  342         d_view.stride_3() != h_view.stride_3() ||
 
  343         d_view.stride_4() != h_view.stride_4() ||
 
  344         d_view.stride_5() != h_view.stride_5() ||
 
  345         d_view.stride_6() != h_view.stride_6() ||
 
  346         d_view.stride_7() != h_view.stride_7() ||
 
  347         d_view.span() != h_view.span()) {
 
  348       Kokkos::Impl::throw_runtime_exception(
 
  349           "DualView constructed with incompatible views");
 
  351 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 
  352     modified_host   = t_modified_flag(modified_flags, 0);
 
  353     modified_device = t_modified_flag(modified_flags, 1);
 
  377   template <
class Device>
 
  378   KOKKOS_INLINE_FUNCTION 
const typename Impl::if_c<
 
  379       std::is_same<
typename t_dev::memory_space,
 
  380                    typename Device::memory_space>::value,
 
  381       t_dev, t_host>::type&
 
  383 #ifndef KOKKOS_ENABLE_DEPRECATED_CODE 
  384     constexpr 
bool device_is_memspace =
 
  385         std::is_same<Device, typename Device::memory_space>::value;
 
  386     constexpr 
bool device_is_execspace =
 
  387         std::is_same<Device, typename Device::execution_space>::value;
 
  388     constexpr 
bool device_exec_is_t_dev_exec =
 
  389         std::is_same<
typename Device::execution_space,
 
  390                      typename t_dev::execution_space>::value;
 
  391     constexpr 
bool device_mem_is_t_dev_mem =
 
  392         std::is_same<
typename Device::memory_space,
 
  393                      typename t_dev::memory_space>::value;
 
  394     constexpr 
bool device_exec_is_t_host_exec =
 
  395         std::is_same<
typename Device::execution_space,
 
  396                      typename t_host::execution_space>::value;
 
  397     constexpr 
bool device_mem_is_t_host_mem =
 
  398         std::is_same<
typename Device::memory_space,
 
  399                      typename t_host::memory_space>::value;
 
  400     constexpr 
bool device_is_t_host_device =
 
  401         std::is_same<
typename Device::execution_space,
 
  402                      typename t_host::device_type>::value;
 
  403     constexpr 
bool device_is_t_dev_device =
 
  404         std::is_same<
typename Device::memory_space,
 
  405                      typename t_host::device_type>::value;
 
  408         device_is_t_dev_device || device_is_t_host_device ||
 
  409             (device_is_memspace &&
 
  410              (device_mem_is_t_dev_mem || device_mem_is_t_host_mem)) ||
 
  411             (device_is_execspace &&
 
  412              (device_exec_is_t_dev_exec || device_exec_is_t_host_exec)) ||
 
  413             ((!device_is_execspace && !device_is_memspace) &&
 
  414              ((device_mem_is_t_dev_mem || device_mem_is_t_host_mem) ||
 
  415               (device_exec_is_t_dev_exec || device_exec_is_t_host_exec))),
 
  416         "Template parameter to .view() must exactly match one of the " 
  417         "DualView's device types or one of the execution or memory spaces");
 
  420     return Impl::if_c<std::is_same<
typename t_dev::memory_space,
 
  421                                    typename Device::memory_space>::value,
 
  422                       t_dev, t_host>::select(d_view, h_view);
 
  425   KOKKOS_INLINE_FUNCTION
 
  426   t_host view_host()
 const { 
return h_view; }
 
  428   KOKKOS_INLINE_FUNCTION
 
  429   t_dev view_device()
 const { 
return d_view; }
 
  431   template <
class Device>
 
  432   static int get_device_side() {
 
  433     constexpr 
bool device_is_memspace =
 
  434         std::is_same<Device, typename Device::memory_space>::value;
 
  435     constexpr 
bool device_is_execspace =
 
  436         std::is_same<Device, typename Device::execution_space>::value;
 
  437     constexpr 
bool device_exec_is_t_dev_exec =
 
  438         std::is_same<
typename Device::execution_space,
 
  439                      typename t_dev::execution_space>::value;
 
  440     constexpr 
bool device_mem_is_t_dev_mem =
 
  441         std::is_same<
typename Device::memory_space,
 
  442                      typename t_dev::memory_space>::value;
 
  443     constexpr 
bool device_exec_is_t_host_exec =
 
  444         std::is_same<
typename Device::execution_space,
 
  445                      typename t_host::execution_space>::value;
 
  446     constexpr 
bool device_mem_is_t_host_mem =
 
  447         std::is_same<
typename Device::memory_space,
 
  448                      typename t_host::memory_space>::value;
 
  449     constexpr 
bool device_is_t_host_device =
 
  450         std::is_same<
typename Device::execution_space,
 
  451                      typename t_host::device_type>::value;
 
  452     constexpr 
bool device_is_t_dev_device =
 
  453         std::is_same<
typename Device::memory_space,
 
  454                      typename t_host::device_type>::value;
 
  456 #ifndef KOKKOS_ENABLE_DEPRECATED_CODE 
  458         device_is_t_dev_device || device_is_t_host_device ||
 
  459             (device_is_memspace &&
 
  460              (device_mem_is_t_dev_mem || device_mem_is_t_host_mem)) ||
 
  461             (device_is_execspace &&
 
  462              (device_exec_is_t_dev_exec || device_exec_is_t_host_exec)) ||
 
  463             ((!device_is_execspace && !device_is_memspace) &&
 
  464              ((device_mem_is_t_dev_mem || device_mem_is_t_host_mem) ||
 
  465               (device_exec_is_t_dev_exec || device_exec_is_t_host_exec))),
 
  466         "Template parameter to .sync() must exactly match one of the " 
  467         "DualView's device types or one of the execution or memory spaces");
 
  470 #ifndef KOKKOS_ENABLE_DEPRECATED_CODE 
  475     if (device_is_t_dev_device)
 
  477     else if (device_is_t_host_device)
 
  480       if (device_is_memspace) {
 
  481         if (device_mem_is_t_dev_mem) dev = 1;
 
  482         if (device_mem_is_t_host_mem) dev = 0;
 
  483         if (device_mem_is_t_host_mem && device_mem_is_t_dev_mem) dev = -1;
 
  485       if (device_is_execspace) {
 
  486         if (device_exec_is_t_dev_exec) dev = 1;
 
  487         if (device_exec_is_t_host_exec) dev = 0;
 
  488         if (device_exec_is_t_host_exec && device_exec_is_t_dev_exec) dev = -1;
 
  490       if (!device_is_execspace && !device_is_memspace) {
 
  491         if (device_mem_is_t_dev_mem) dev = 1;
 
  492         if (device_mem_is_t_host_mem) dev = 0;
 
  493         if (device_mem_is_t_host_mem && device_mem_is_t_dev_mem) dev = -1;
 
  494         if (device_exec_is_t_dev_exec) dev = 1;
 
  495         if (device_exec_is_t_host_exec) dev = 0;
 
  496         if (device_exec_is_t_host_exec && device_exec_is_t_dev_exec) dev = -1;
 
  519   template <
class Device>
 
  520   void sync(
const typename std::enable_if<
 
  521                 (std::is_same<
typename traits::data_type,
 
  522                               typename traits::non_const_data_type>::value) ||
 
  523                     (std::is_same<Device, int>::value),
 
  525     if (modified_flags.data() == 
nullptr) 
return;
 
  527     int dev = get_device_side<Device>();
 
  530       if ((modified_flags(0) > 0) && (modified_flags(0) >= modified_flags(1))) {
 
  531 #ifdef KOKKOS_ENABLE_CUDA 
  532         if (std::is_same<
typename t_dev::memory_space,
 
  533                          Kokkos::CudaUVMSpace>::value) {
 
  534           if (d_view.data() == h_view.data())
 
  535             Kokkos::Impl::cuda_prefetch_pointer(
 
  536                 Kokkos::Cuda(), d_view.data(),
 
  537                 sizeof(
typename t_dev::value_type) * d_view.span(), 
true);
 
  542         modified_flags(0) = modified_flags(1) = 0;
 
  546       if ((modified_flags(1) > 0) && (modified_flags(1) >= modified_flags(0))) {
 
  547 #ifdef KOKKOS_ENABLE_CUDA 
  548         if (std::is_same<
typename t_dev::memory_space,
 
  549                          Kokkos::CudaUVMSpace>::value) {
 
  550           if (d_view.data() == h_view.data())
 
  551             Kokkos::Impl::cuda_prefetch_pointer(
 
  552                 Kokkos::Cuda(), d_view.data(),
 
  553                 sizeof(
typename t_dev::value_type) * d_view.span(), 
false);
 
  558         modified_flags(0) = modified_flags(1) = 0;
 
  561     if (std::is_same<
typename t_host::memory_space,
 
  562                      typename t_dev::memory_space>::value) {
 
  563       typename t_dev::execution_space().fence();
 
  564       typename t_host::execution_space().fence();
 
  568   template <
class Device>
 
  569   void sync(
const typename std::enable_if<
 
  570                 (!std::is_same<
typename traits::data_type,
 
  571                                typename traits::non_const_data_type>::value) ||
 
  572                     (std::is_same<Device, int>::value),
 
  574     if (modified_flags.data() == 
nullptr) 
return;
 
  576     int dev = get_device_side<Device>();
 
  579       if ((modified_flags(0) > 0) && (modified_flags(0) >= modified_flags(1))) {
 
  580         Impl::throw_runtime_exception(
 
  581             "Calling sync on a DualView with a const datatype.");
 
  585       if ((modified_flags(1) > 0) && (modified_flags(1) >= modified_flags(0))) {
 
  586         Impl::throw_runtime_exception(
 
  587             "Calling sync on a DualView with a const datatype.");
 
  593     if (!std::is_same<
typename traits::data_type,
 
  594                       typename traits::non_const_data_type>::value)
 
  595       Impl::throw_runtime_exception(
 
  596           "Calling sync_host on a DualView with a const datatype.");
 
  597     if (modified_flags.data() == 
nullptr) 
return;
 
  598     if (modified_flags(1) > modified_flags(0)) {
 
  599 #ifdef KOKKOS_ENABLE_CUDA 
  600       if (std::is_same<
typename t_dev::memory_space,
 
  601                        Kokkos::CudaUVMSpace>::value) {
 
  602         if (d_view.data() == h_view.data())
 
  603           Kokkos::Impl::cuda_prefetch_pointer(
 
  604               Kokkos::Cuda(), d_view.data(),
 
  605               sizeof(
typename t_dev::value_type) * d_view.span(), 
false);
 
  610       modified_flags(1) = modified_flags(0) = 0;
 
  615     if (!std::is_same<
typename traits::data_type,
 
  616                       typename traits::non_const_data_type>::value)
 
  617       Impl::throw_runtime_exception(
 
  618           "Calling sync_device on a DualView with a const datatype.");
 
  619     if (modified_flags.data() == 
nullptr) 
return;
 
  620     if (modified_flags(0) > modified_flags(1)) {
 
  621 #ifdef KOKKOS_ENABLE_CUDA 
  622       if (std::is_same<
typename t_dev::memory_space,
 
  623                        Kokkos::CudaUVMSpace>::value) {
 
  624         if (d_view.data() == h_view.data())
 
  625           Kokkos::Impl::cuda_prefetch_pointer(
 
  626               Kokkos::Cuda(), d_view.data(),
 
  627               sizeof(
typename t_dev::value_type) * d_view.span(), 
true);
 
  632       modified_flags(1) = modified_flags(0) = 0;
 
  636   template <
class Device>
 
  637   bool need_sync()
 const {
 
  638     if (modified_flags.data() == 
nullptr) 
return false;
 
  639     int dev = get_device_side<Device>();
 
  642       if ((modified_flags(0) > 0) && (modified_flags(0) >= modified_flags(1))) {
 
  647       if ((modified_flags(1) > 0) && (modified_flags(1) >= modified_flags(0))) {
 
  654   inline bool need_sync_host()
 const {
 
  655     if (modified_flags.data() == 
nullptr) 
return false;
 
  656     return modified_flags(0) < modified_flags(1);
 
  659   inline bool need_sync_device()
 const {
 
  660     if (modified_flags.data() == 
nullptr) 
return false;
 
  661     return modified_flags(1) < modified_flags(0);
 
  669   template <
class Device>
 
  671     if (modified_flags.data() == 
nullptr) 
return;
 
  672     int dev = get_device_side<Device>();
 
  677           (modified_flags(1) > modified_flags(0) ? modified_flags(1)
 
  678                                                  : modified_flags(0)) +
 
  684           (modified_flags(1) > modified_flags(0) ? modified_flags(1)
 
  685                                                  : modified_flags(0)) +
 
  689 #ifdef KOKKOS_ENABLE_DEBUG_DUALVIEW_MODIFY_CHECK 
  690     if (modified_flags(0) && modified_flags(1)) {
 
  691       std::string msg = 
"Kokkos::DualView::modify ERROR: ";
 
  692       msg += 
"Concurrent modification of host and device views ";
 
  693       msg += 
"in DualView \"";
 
  694       msg += d_view.label();
 
  696       Kokkos::abort(msg.c_str());
 
  701   inline void modify_host() {
 
  702     if (modified_flags.data() != 
nullptr) {
 
  704           (modified_flags(1) > modified_flags(0) ? modified_flags(1)
 
  705                                                  : modified_flags(0)) +
 
  707 #ifdef KOKKOS_ENABLE_DEBUG_DUALVIEW_MODIFY_CHECK 
  708       if (modified_flags(0) && modified_flags(1)) {
 
  709         std::string msg = 
"Kokkos::DualView::modify_host ERROR: ";
 
  710         msg += 
"Concurrent modification of host and device views ";
 
  711         msg += 
"in DualView \"";
 
  712         msg += d_view.label();
 
  714         Kokkos::abort(msg.c_str());
 
  720   inline void modify_device() {
 
  721     if (modified_flags.data() != 
nullptr) {
 
  723           (modified_flags(1) > modified_flags(0) ? modified_flags(1)
 
  724                                                  : modified_flags(0)) +
 
  726 #ifdef KOKKOS_ENABLE_DEBUG_DUALVIEW_MODIFY_CHECK 
  727       if (modified_flags(0) && modified_flags(1)) {
 
  728         std::string msg = 
"Kokkos::DualView::modify_device ERROR: ";
 
  729         msg += 
"Concurrent modification of host and device views ";
 
  730         msg += 
"in DualView \"";
 
  731         msg += d_view.label();
 
  733         Kokkos::abort(msg.c_str());
 
  739   inline void clear_sync_state() {
 
  740     if (modified_flags.data() != 
nullptr)
 
  741       modified_flags(1) = modified_flags(0) = 0;
 
  753   void realloc(
const size_t n0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  754                const size_t n1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  755                const size_t n2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  756                const size_t n3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  757                const size_t n4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  758                const size_t n5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  759                const size_t n6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  760                const size_t n7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG) {
 
  761     ::Kokkos::realloc(d_view, n0, n1, n2, n3, n4, n5, n6, n7);
 
  762     h_view = create_mirror_view(d_view);
 
  765     if (modified_flags.data() == 
nullptr) {
 
  766       modified_flags = t_modified_flags(
"DualView::modified_flags");
 
  768       modified_flags(1) = modified_flags(0) = 0;
 
  775   void resize(
const size_t n0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  776               const size_t n1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  777               const size_t n2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  778               const size_t n3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  779               const size_t n4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  780               const size_t n5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  781               const size_t n6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
 
  782               const size_t n7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG) {
 
  783     if (modified_flags.data() == 
nullptr) {
 
  784       modified_flags = t_modified_flags(
"DualView::modified_flags");
 
  786     if (modified_flags(1) >= modified_flags(0)) {
 
  788       ::Kokkos::resize(d_view, n0, n1, n2, n3, n4, n5, n6, n7);
 
  789       h_view = create_mirror_view(d_view);
 
  792       modified_flags(1) = modified_flags(1) + 1;
 
  797       ::Kokkos::realloc(d_view, n0, n1, n2, n3, n4, n5, n6, n7);
 
  799       const bool sizeMismatch =
 
  800           (h_view.extent(0) != n0) || (h_view.extent(1) != n1) ||
 
  801           (h_view.extent(2) != n2) || (h_view.extent(3) != n3) ||
 
  802           (h_view.extent(4) != n4) || (h_view.extent(5) != n5) ||
 
  803           (h_view.extent(6) != n6) || (h_view.extent(7) != n7);
 
  805         ::Kokkos::resize(h_view, n0, n1, n2, n3, n4, n5, n6, n7);
 
  807       t_host temp_view = create_mirror_view(d_view);
 
  814       d_view = create_mirror_view(
typename t_dev::execution_space(), h_view);
 
  817       modified_flags(0) = modified_flags(0) + 1;
 
  825 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 
  826   size_t capacity()
 const { 
return d_view.span(); }
 
  831   KOKKOS_INLINE_FUNCTION constexpr 
size_t span()
 const { 
return d_view.span(); }
 
  833   KOKKOS_INLINE_FUNCTION 
bool span_is_contiguous()
 const {
 
  834     return d_view.span_is_contiguous();
 
  838   template <
typename iType>
 
  839   void stride(iType* stride_)
 const {
 
  840     d_view.stride(stride_);
 
  843   template <
typename iType>
 
  844   KOKKOS_INLINE_FUNCTION constexpr
 
  845       typename std::enable_if<std::is_integral<iType>::value, 
size_t>::type
 
  846       extent(
const iType& r)
 const {
 
  847     return d_view.extent(r);
 
  850   template <
typename iType>
 
  851   KOKKOS_INLINE_FUNCTION constexpr
 
  852       typename std::enable_if<std::is_integral<iType>::value, 
int>::type
 
  853       extent_int(
const iType& r)
 const {
 
  854     return static_cast<int>(d_view.extent(r));
 
  857 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 
  863   size_t dimension_0()
 const { 
return d_view.extent(0); }
 
  865   size_t dimension_1()
 const { 
return d_view.extent(1); }
 
  867   size_t dimension_2()
 const { 
return d_view.extent(2); }
 
  869   size_t dimension_3()
 const { 
return d_view.extent(3); }
 
  871   size_t dimension_4()
 const { 
return d_view.extent(4); }
 
  873   size_t dimension_5()
 const { 
return d_view.extent(5); }
 
  875   size_t dimension_6()
 const { 
return d_view.extent(6); }
 
  877   size_t dimension_7()
 const { 
return d_view.extent(7); }
 
  894 template <
class D, 
class A1, 
class A2, 
class A3, 
class... Args>
 
  895 struct DualViewSubview {
 
  896   typedef typename Kokkos::Impl::ViewMapping<
 
  899   typedef Kokkos::DualView<
 
  900       typename dst_traits::data_type, 
typename dst_traits::array_layout,
 
  901       typename dst_traits::device_type, 
typename dst_traits::memory_traits>
 
  907 template <
class D, 
class A1, 
class A2, 
class A3, 
class... Args>
 
  908 typename Impl::DualViewSubview<D, A1, A2, A3, Args...>::type subview(
 
  909     const DualView<D, A1, A2, A3>& src, Args... args) {
 
  910   return typename Impl::DualViewSubview<D, A1, A2, A3, Args...>::type(src,
 
  925 template <
class DT, 
class DL, 
class DD, 
class DM, 
class ST, 
class SL, 
class SD,
 
  928     DualView<DT, DL, DD, DM> dst,  
 
  929     const DualView<ST, SL, SD, SM>& src) {
 
  930   if (src.need_sync_device()) {
 
  939 template <
class ExecutionSpace, 
class DT, 
class DL, 
class DD, 
class DM,
 
  940           class ST, 
class SL, 
class SD, 
class SM>
 
  942     const ExecutionSpace& exec,
 
  943     DualView<DT, DL, DD, DM> dst,  
 
  944     const DualView<ST, SL, SD, SM>& src) {
 
  945   if (src.need_sync_device()) {
 
  965 template <
class... Properties, 
class... Args>
 
  966 void resize(DualView<Properties...>& dv, Args&&... args) noexcept(
 
  967     noexcept(dv.
resize(std::forward<Args>(args)...))) {
 
  968   dv.resize(std::forward<Args>(args)...);
 
  971 template <
class... Properties, 
class... Args>
 
  972 void realloc(DualView<Properties...>& dv, Args&&... args) noexcept(
 
  973     noexcept(dv.
realloc(std::forward<Args>(args)...))) {
 
  974   dv.realloc(std::forward<Args>(args)...);
 
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 *=nullptr)
Deep copy a value from Host memory into a view. 
 
View< typename traits::non_const_data_type, typename traits::array_layout, Device< DefaultHostExecutionSpace, typename traits::host_mirror_space::memory_space > > HostMirror
Compatible HostMirror view. 
 
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. 
 
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. 
 
Traits class for accessing attributes of a View.