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

#include <Phalanx_KokkosViewOfViews.hpp>

Public Types

using OuterDataType = typename PHX::v_of_v_utils::add_pointer< InnerViewType, OuterViewRank >::type
 
using OuterViewType = Kokkos::View< OuterDataType, MemorySpace >
 
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>
 ViewOfViews (const std::string name, Extents...extents)
 
template<typename... Indices>
void addView (InnerViewType v, Indices...i)
 
void syncHostToDevice ()
 
auto getViewHost ()
 
auto getViewDevice ()
 
template<typename... Extents>
 ViewOfViews (const std::string name, Extents...extents)
 Ctor that uses the default execution space instance.
 
template<typename ExecSpace , typename... Extents>
 ViewOfViews (const ExecSpace &e_space, const std::string name, Extents...extents)
 
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 () const
 
auto getViewDevice () const
 Returns device view of views.
 

Detailed Description

template<int OuterViewRank, typename InnerViewType, typename MemorySpace>
class PHX::ViewOfViews< OuterViewRank, InnerViewType, MemorySpace >

Wrapper class that correctly handles ViewOfViews construction and object lifetime. Can be used for more than just Views as the inner object. 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 VofV on host and copy to device to set up the inner views correctly.
  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.

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 MemorySpace>
template<typename ExecSpace , typename... Extents>
PHX::ViewOfViews< OuterViewRank, InnerViewType, MemorySpace >::ViewOfViews ( 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 MemorySpace>
auto PHX::ViewOfViews< OuterViewRank, InnerViewType, MemorySpace >::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 MemorySpace>
template<typename ExecSpace , typename... Extents>
void PHX::ViewOfViews< OuterViewRank, InnerViewType, MemorySpace >::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 MemorySpace>
void PHX::ViewOfViews< OuterViewRank, InnerViewType, MemorySpace >::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 MemorySpace>
template<typename ExecSpace >
void PHX::ViewOfViews< OuterViewRank, InnerViewType, MemorySpace >::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 files: