Mundy: Multibody Nonlocal Dynamics Version of the Day
Loading...
Searching...
No Matches
mundy::NgpViewT< DataType, Properties > Class Template Reference

NgpViewT is an enhanced DualView with a slightly expanded interface. More...

#include <NgpView.hpp>

Inheritance diagram for mundy::NgpViewT< DataType, Properties >:
[legend]

Public Types

using t_dv = Kokkos::DualView<DataType, Properties...>
using t_dev = typename t_dv::t_dev
using t_host = typename t_dv::t_host

Public Member Functions

Constructors
 NgpViewT ()=default
 Default constructor.
 NgpViewT (const std::string &label, 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)
 Allocates device and host views with the specified dimensions.
template<class... P>
 NgpViewT (const Kokkos::Impl::ViewCtorProp< P... > &arg_prop, std::enable_if_t<!Kokkos::Impl::ViewCtorProp< P... >::has_pointer, size_t > const 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)
 Allocates device and host views using a property object.
template<typename DT, typename... DP>
 NgpViewT (const NgpViewT< DT, DP... > &src)
 Shallow copy constructor.
template<class DT, class... DP, class Arg0, class... Args>
 NgpViewT (const NgpViewT< DT, DP... > &src, const Arg0 &arg0, Args... args)
 Constructs a subview of an existing NgpViewT.
 NgpViewT (const t_dev &d_view_, const t_host &h_view_)
 Constructs an NgpViewT from existing device and host views.
void modify_on_host ()
 Mark the host view as modified.
void modify_on_device ()
 Mark the device view as modified.
template<typename Space>
void modify_on ()
 Abstract method for marking the view as modified.
void sync_to_host ()
 Synchronize the host view to the device view if needed.
void sync_to_device ()
 Synchronize the device view to the host view if needed.
template<typename Space>
void sync_to ()
 Abstract method for synchronizing the view.
bool need_sync_to_host () const
 Return if we need to sync to the host.
bool need_sync_to_device () const
 Return if we need to sync to the device.
template<typename Space>
bool need_sync_to () const
 Abstract method for checking if we need to sync.

Detailed Description

template<class DataType, class... Properties>
class mundy::NgpViewT< DataType, Properties >

NgpViewT inherits from Kokkos::DualView, exposing all its functionality while adding convenience methods for marking and synchronizing modifications between host and device. This class replicates the constructors of DualView and provides detailed documentation for users who may be new to Kokkos views.

Member Typedef Documentation

◆ t_dv

template<class DataType, class... Properties>
using mundy::NgpViewT< DataType, Properties >::t_dv = Kokkos::DualView<DataType, Properties...>

◆ t_dev

template<class DataType, class... Properties>
using mundy::NgpViewT< DataType, Properties >::t_dev = typename t_dv::t_dev

◆ t_host

template<class DataType, class... Properties>
using mundy::NgpViewT< DataType, Properties >::t_host = typename t_dv::t_host

Constructor & Destructor Documentation

◆ NgpViewT() [1/6]

template<class DataType, class... Properties>
mundy::NgpViewT< DataType, Properties >::NgpViewT ( )
default

Constructs an empty NgpViewT object. Both the device and host views are constructed using their default constructors, meaning no memory is allocated until you assign or allocate data later. The internal "modified" flags are initialized to indicate that neither view is marked as modified.

◆ NgpViewT() [2/6]

template<class DataType, class... Properties>
mundy::NgpViewT< DataType, Properties >::NgpViewT ( const std::string & label,
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 )
inline

This constructor behaves similarly to the corresponding constructor of Kokkos::DualView. The first argument is a user-defined label that can help with debugging or profiling. The remaining arguments specify the dimensions of the view. For a multi-dimensional view, only specify the dimensions that are nonzero; additional dimensions default to an implementation-defined value.

Parameters
labelA string used to label the view.
n0The size of the first dimension.
n1(Optional) The size of the second dimension.
n2(Optional) The size of the third dimension.
n3(Optional) The size of the fourth dimension.
n4(Optional) The size of the fifth dimension.
n5(Optional) The size of the sixth dimension.
n6(Optional) The size of the seventh dimension.
n7(Optional) The size of the eighth dimension.

◆ NgpViewT() [3/6]

template<class DataType, class... Properties>
template<class... P>
mundy::NgpViewT< DataType, Properties >::NgpViewT ( const Kokkos::Impl::ViewCtorProp< P... > & arg_prop,
std::enable_if_t<!Kokkos::Impl::ViewCtorProp< P... >::has_pointer, size_t > const 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 )
inline

This constructor lets you wrap up various construction properties (such as memory space, label, or initialization behavior) in a ViewCtorProp object. The subsequent integer arguments specify the dimensions of the view, similar to the previous constructor.

Template Parameters
PA parameter pack representing properties wrapped in the ViewCtorProp.
Parameters
arg_propA ViewCtorProp object encapsulating construction properties.
n0The size of the first dimension.
n1(Optional) The size of the second dimension.
n2(Optional) The size of the third dimension.
n3(Optional) The size of the fourth dimension.
n4(Optional) The size of the fifth dimension.
n5(Optional) The size of the sixth dimension.
n6(Optional) The size of the seventh dimension.
n7(Optional) The size of the eighth dimension.

◆ NgpViewT() [4/6]

template<class DataType, class... Properties>
template<typename DT, typename... DP>
mundy::NgpViewT< DataType, Properties >::NgpViewT ( const NgpViewT< DT, DP... > & src)
inline

Constructs a new NgpViewT as a shallow copy of the source view. The underlying host and device views will refer to the same memory as those in the source. Both the data pointers and the "modified" flags are copied.

Template Parameters
DTThe data type of the source view.
DPThe properties of the source view.
Parameters
srcThe NgpViewT from which to create a copy.

◆ NgpViewT() [5/6]

template<class DataType, class... Properties>
template<class DT, class... DP, class Arg0, class... Args>
mundy::NgpViewT< DataType, Properties >::NgpViewT ( const NgpViewT< DT, DP... > & src,
const Arg0 & arg0,
Args... args )
inline

This constructor allows you to create a new NgpViewT that is a subview of an existing one. This is especially useful for extracting lower-dimensional slices from higher-dimensional views. The additional arguments specify the indices or ranges to select.

Template Parameters
DTThe data type of the source view.
DPThe properties of the source view.
Arg0The type of the first argument for slicing.
ArgsThe types of additional slicing arguments.
Parameters
srcThe source NgpViewT from which the subview is created.
arg0The first argument for defining the subview.
argsAdditional arguments for defining the subview.

◆ NgpViewT() [6/6]

template<class DataType, class... Properties>
mundy::NgpViewT< DataType, Properties >::NgpViewT ( const t_dev & d_view_,
const t_host & h_view_ )
inline

This constructor creates an NgpViewT using already allocated device and host views. It assumes that the two views are synchronized (i.e., contain identical data) at the time of construction. After constructing the NgpViewT, you can use the sync() and modify() methods to manage synchronization.

Parameters
d_view_A pre-existing device view.
h_view_A pre-existing host view. This must be the host mirror of the device view.

Member Function Documentation

◆ modify_on_host()

template<class DataType, class... Properties>
void mundy::NgpViewT< DataType, Properties >::modify_on_host ( )
inline

Call this method after updating the host view so that the DualView is aware that the device view may now be out of date.

◆ modify_on_device()

template<class DataType, class... Properties>
void mundy::NgpViewT< DataType, Properties >::modify_on_device ( )
inline

Call this method after updating the device view so that the DualView is aware that the host view may now be out of date.

◆ modify_on()

template<class DataType, class... Properties>
template<typename Space>
void mundy::NgpViewT< DataType, Properties >::modify_on ( )
inline

◆ sync_to_host()

template<class DataType, class... Properties>
void mundy::NgpViewT< DataType, Properties >::sync_to_host ( )
inline

If the device view has been modified more recently than the host view, this function performs a deep copy from the device view to the host view.

◆ sync_to_device()

template<class DataType, class... Properties>
void mundy::NgpViewT< DataType, Properties >::sync_to_device ( )
inline

If the host view has been modified more recently than the device view, this function performs a deep copy from the host view to the device view.

◆ sync_to()

template<class DataType, class... Properties>
template<typename Space>
void mundy::NgpViewT< DataType, Properties >::sync_to ( )
inline

◆ need_sync_to_host()

template<class DataType, class... Properties>
bool mundy::NgpViewT< DataType, Properties >::need_sync_to_host ( ) const
inline

◆ need_sync_to_device()

template<class DataType, class... Properties>
bool mundy::NgpViewT< DataType, Properties >::need_sync_to_device ( ) const
inline

◆ need_sync_to()

template<class DataType, class... Properties>
template<typename Space>
bool mundy::NgpViewT< DataType, Properties >::need_sync_to ( ) const
inline