Intrepid2
Public Member Functions | Private Attributes | List of all members
Intrepid2::ViewIterator< ViewType, ScalarType > Class Template Reference

A helper class that allows iteration over some part of a Kokkos View, while allowing the calling code to remain agnostic as to the rank of the view. More...

#include <Intrepid2_ViewIterator.hpp>

Public Member Functions

KOKKOS_INLINE_FUNCTION ViewIterator (ViewType view)
 
KOKKOS_INLINE_FUNCTION ScalarType get ()
 
KOKKOS_INLINE_FUNCTION void set (ScalarType &value)
 
KOKKOS_INLINE_FUNCTION int nextIncrementRank ()
 
KOKKOS_INLINE_FUNCTION int increment ()
 
KOKKOS_INLINE_FUNCTION bool decrement ()
 
KOKKOS_INLINE_FUNCTION int getEnumerationIndex ()
 
KOKKOS_INLINE_FUNCTION int getIndex (int dimension)
 
KOKKOS_INLINE_FUNCTION int getExtent (int dimension)
 
KOKKOS_INLINE_FUNCTION void reset (int from_rank_number=0)
 
KOKKOS_INLINE_FUNCTION void setLocation (const Kokkos::Array< int, 7 > &location)
 
KOKKOS_INLINE_FUNCTION
Kokkos::Array< int, 7 > & 
getLocation ()
 

Private Attributes

ViewType view_
 
Kokkos::Array< int, 7 > dims_
 
Kokkos::Array< int, 7 > index_
 

Detailed Description

template<class ViewType, typename ScalarType>
class Intrepid2::ViewIterator< ViewType, ScalarType >

A helper class that allows iteration over some part of a Kokkos View, while allowing the calling code to remain agnostic as to the rank of the view.

Usage is as follows:

  1. Construct ViewIterator from View.
  2. Use the setLocation() method to set the location appropriate to each thread.
  3. Use get() to access the current value, set() to set it, and increment() to move to the next entry.
  4. Stop condition: if only part of the View is traversed on a thread, nextIncrementRank(), or the returned rank value from increment(), may be used to determine when the View locations for a given dimension have been traversed.

For example, if a rank-4 View has dimensions (D1,D2,D3,D4) = (10,15,20,25), and logical threads are assigned to each (D1,D2) pair, then each thread would call setLocation({D1,D2,0,0,0,0,0}), and would stop traversal when increment() returned 1, indicating that the D2 rank had been incremented, which in turn would imply that all (D3,D4) pairs had been visited.

See Also
Intrepid2::TensorViewIterator
Remarks
This class is under active development; its interface should be understood to be in flux. Furthermore, this may eventually move to another Trilinos package.

Definition at line 74 of file Intrepid2_ViewIterator.hpp.

Constructor & Destructor Documentation

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION Intrepid2::ViewIterator< ViewType, ScalarType >::ViewIterator ( ViewType  view)
inline

Constructor

Parameters
[in]view- the View to iterate over

Definition at line 83 of file Intrepid2_ViewIterator.hpp.

Member Function Documentation

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION bool Intrepid2::ViewIterator< ViewType, ScalarType >::decrement ( )
inline

move to the previous location

Returns
the rank of the leftmost index that was changed

Definition at line 160 of file Intrepid2_ViewIterator.hpp.

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION ScalarType Intrepid2::ViewIterator< ViewType, ScalarType >::get ( )
inline
template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION int Intrepid2::ViewIterator< ViewType, ScalarType >::getEnumerationIndex ( )
inline

Enumeration index refers to a 1D enumeration of the entries in the View, with dimensions in order of their significance (dimension 0 is the slowest-moving).

Returns
the enumeration index at current location.

Definition at line 186 of file Intrepid2_ViewIterator.hpp.

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION int Intrepid2::ViewIterator< ViewType, ScalarType >::getExtent ( int  dimension)
inline

The extent of the View in the specified dimension. (Extents in dimensions beyond the rank of the View, but less than 7, are defined to be 1.)

Parameters
[in]dimension- the dimension for which the extent should be returned.
Returns
extent of the View in the specified dimension.

Definition at line 211 of file Intrepid2_ViewIterator.hpp.

Referenced by Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::setLocation().

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION int Intrepid2::ViewIterator< ViewType, ScalarType >::getIndex ( int  dimension)
inline

The index of the current location in the specified dimension. (Indices in dimensions beyond the rank of the View, but less than 7, are defined to be 0.)

Parameters
[in]dimension- the dimension for which the current index should be returned.
Returns
index in the specified dimension.

Definition at line 202 of file Intrepid2_ViewIterator.hpp.

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION Kokkos::Array<int,7>& Intrepid2::ViewIterator< ViewType, ScalarType >::getLocation ( )
inline

Sets the current location.

Parameters
[in]location- the location as a 7-element array value.

Definition at line 238 of file Intrepid2_ViewIterator.hpp.

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION int Intrepid2::ViewIterator< ViewType, ScalarType >::increment ( )
inline

move to the next location

Returns
the rank of the leftmost index that was changed; -1 if increment reached the end of the view

Definition at line 135 of file Intrepid2_ViewIterator.hpp.

Referenced by Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::increment().

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION int Intrepid2::ViewIterator< ViewType, ScalarType >::nextIncrementRank ( )
inline
Returns
the leftmost rank ordinal whose index will change on next increment (-1 if next increment will go out of bounds)

Definition at line 118 of file Intrepid2_ViewIterator.hpp.

Referenced by Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::increment(), and Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::nextIncrementRank().

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION void Intrepid2::ViewIterator< ViewType, ScalarType >::reset ( int  from_rank_number = 0)
inline

Resets the location to index 0 in each dimension, starting from the specified dimension.

Parameters
[in]from_rank_number- the first dimension in which to set the index to 0.

Definition at line 219 of file Intrepid2_ViewIterator.hpp.

Referenced by Intrepid2::ViewIterator< TensorViewType, ScalarType >::decrement(), and Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::increment().

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION void Intrepid2::ViewIterator< ViewType, ScalarType >::set ( ScalarType &  value)
inline

Setter

Parameters
[in]value- the value to set at the current location

Definition at line 110 of file Intrepid2_ViewIterator.hpp.

Referenced by Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::set().

template<class ViewType, typename ScalarType>
KOKKOS_INLINE_FUNCTION void Intrepid2::ViewIterator< ViewType, ScalarType >::setLocation ( const Kokkos::Array< int, 7 > &  location)
inline

Sets the current location.

Parameters
[in]location- the location as a 7-element array value.

Definition at line 230 of file Intrepid2_ViewIterator.hpp.

Referenced by Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::setLocation().


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