Phalanx  Development
 All Classes Functions Variables Typedefs Enumerations Friends Pages
Public Types | Public Member Functions | List of all members
PHX::ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps > Class Template Reference

#include <Phalanx_KokkosViewOfViews.hpp>

Inheritance diagram for PHX::ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps >:
Inheritance graph
[legend]

Public Types

using OuterDataType = typename PHX::v_of_v_utils::add_pointer< InnerViewType, OuterViewRank >::type
 
using OuterViewType = Kokkos::View< OuterDataType, OuterViewProps...>
 

Public Member Functions

template<typename... Extents>
 ViewOfViews3 (const std::string name, Extents...extents)
 Ctor that uses the default execution space instance.
 
template<typename ExecSpace , typename... Extents>
 ViewOfViews3 (const ExecSpace &e_space, const std::string name, Extents...extents)
 
 ViewOfViews3 (const ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps...> &)=default
 
ViewOfViews3operator= (const ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps...> &)=default
 
 ViewOfViews3 (ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps...> &&src)=default
 
ViewOfViews3operator= (ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps...> &&)=default
 
void enableSafetyCheck ()
 Enable safety check in dtor for external references.
 
void disableSafetyCheck ()
 Disable safety check in dtor for external references.
 
template<typename... Extents>
void initialize (const std::string name, Extents...extents)
 Allocate the out view objects. Extents are for the outer view. Uses the default execution space.
 
template<typename ExecSpace , typename... Extents>
void initialize (const ExecSpace &e_space, const std::string name, Extents...extents)
 
bool isInitialized () const
 
bool deviceViewIsSynced () const
 
bool safetyCheck () const
 
template<typename... Indices>
void addView (InnerViewType v, Indices...i)
 
void syncHostToDevice ()
 
template<typename ExecSpace >
void syncHostToDevice (const ExecSpace &e_space)
 
auto getViewHost ()
 
auto getViewHost () const
 
auto getViewDevice ()
 Returns device view of views.
 
auto getViewDevice () const
 Returns device view of views.
 

Detailed Description

template<int OuterViewRank, typename InnerViewType, typename... OuterViewProps>
class PHX::ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps >

Wrapper class that correctly handles ViewOfViews construction and object lifetime. This class makes sure the host view stays in scope for the life of the device view and makes sure that the device is synced to host before use.

Main restrictions:

  1. When UVM is not used in the outer view, we need to allocate the outer VofV on host and copy to device to initialize the inner views correctly (tracking object).
  2. Step 1 means that the host view must exist as long as the device view is being used, otherwise the views may go out of scope. This object exists to pair up the host and device view to make sure the inner views are not deleted early.
  3. Normally we use an unmanaged view (constructed with the Unmanaged template parameter) for the inner views to prevent double deletion. However, there are use cases where it's painful to pass around views built with the unmanaged template parameter (libraries with functions that block the unmanaged argument). We can generate an unmanged view without the template parameter by constructing the view with a raw pointer. This thrid implementation does that here.

Constructor & Destructor Documentation

template<int OuterViewRank, typename InnerViewType, typename... OuterViewProps>
template<typename ExecSpace , typename... Extents>
PHX::ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps >::ViewOfViews3 ( const ExecSpace &  e_space,
const std::string  name,
Extents...  extents 
)
inline

Ctor that uses a user specified execution space instance. NOTE: Consistent with Kokkos, when a user supplies the execution space instance, the function does not internally fence. Be sure to manually fence as needed.

Member Function Documentation

template<int OuterViewRank, typename InnerViewType, typename... OuterViewProps>
auto PHX::ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps >::getViewHost ( )
inline

Returns a host mirror view for the outer view, where the inner views are still on device.

template<int OuterViewRank, typename InnerViewType, typename... OuterViewProps>
auto PHX::ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps >::getViewHost ( ) const
inline

Returns a host mirror view for the outer view, where the inner views are still on device.

template<int OuterViewRank, typename InnerViewType, typename... OuterViewProps>
template<typename ExecSpace , typename... Extents>
void PHX::ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps >::initialize ( const ExecSpace &  e_space,
const std::string  name,
Extents...  extents 
)
inline

Allocate the out view objects. Extents are for the outer view. Uses a user supplied execution space. NOTE: Consistent with Kokkos, when a user supplies the execution space instance, the function does not internally fence. Be sure to manually fence as needed.

template<int OuterViewRank, typename InnerViewType, typename... OuterViewProps>
void PHX::ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps >::syncHostToDevice ( )
inline

deep_copy the outer view to device. Uses default execution space. Note this only syncs the outer view. The inner views are assumed to be on device for both host and device outer views.

template<int OuterViewRank, typename InnerViewType, typename... OuterViewProps>
template<typename ExecSpace >
void PHX::ViewOfViews3< OuterViewRank, InnerViewType, OuterViewProps >::syncHostToDevice ( const ExecSpace &  e_space)
inline

deep_copy the outer view to device. Uses a user supplied execution space. Note this only syncs the outer view. The inner views are assumed to be on device for both host and device outer views. NOTE: Consistent with Kokkos, when a user supplies the execution space instance, the function does not internally fence. Be sure to manually fence as needed.


The documentation for this class was generated from the following file: