https://mooseframework.inl.gov
Public Member Functions | Protected Attributes | List of all members
Moose::Kokkos::Scalar< T, typename > Class Template Reference

The Kokkos wrapper class that can hold the reference of an arithmetic scalar variable. More...

#include <KokkosScalar.h>

Inheritance diagram for Moose::Kokkos::Scalar< T, typename >:
[legend]

Public Member Functions

 Scalar (T &value)
 Constructor. More...
 
auto & operator= (T value)
 Assign a scalar value to the underlying host reference. More...
 
KOKKOS_FUNCTION operator const T & () const
 Get the const reference of the stored variable. More...
 
 operator const T & () const
 Get the const reference of the stored host reference. More...
 
KOKKOS_FUNCTION const T & operator* () const
 Get the const reference of the stored variable. More...
 
const T & operator* () const
 Get the const reference of the stored host reference. More...
 
T & operator* ()
 Get the writeable reference of the stored host reference. More...
 
KOKKOS_FUNCTION const T * operator-> () const
 Get the const pointer to the stored variable. More...
 
const T * operator-> () const
 Get the const pointer of the stored host reference. More...
 
T * operator-> ()
 Get the writeable pointer of the stored host reference. More...
 
template<typename... Args>
KOKKOS_FUNCTION auto operator() (Args &&... args) const -> decltype(auto)
 Forward arguments to the stored variable's const operator() depending on the architecture this function is being called on. More...
 
template<typename... Args>
auto operator() (Args &&... args) const -> decltype(auto)
 Forward arguments to the stored host reference's const operator() More...
 
template<typename... Args>
auto operator() (Args &&... args) -> decltype(auto)
 Forward arguments to the stored host reference's operator() More...
 
 operator T& ()
 Get the writeable reference of the stored host reference. More...
 

Protected Attributes

T & _reference
 Writeable host reference of the variable. More...
 
const T _copy
 Device copy of the variable. More...
 

Detailed Description

template<typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
class Moose::Kokkos::Scalar< T, typename >

The Kokkos wrapper class that can hold the reference of an arithmetic scalar variable.

Definition at line 24 of file KokkosScalar.h.

Constructor & Destructor Documentation

◆ Scalar()

template<typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
Moose::Kokkos::Scalar< T, typename >::Scalar ( T &  value)
inline

Constructor.

Parameters
valueThe writeable reference of the arithmetic scalar variable to store

Definition at line 31 of file KokkosScalar.h.

31 : ReferenceWrapper<T>(value) {}
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

Member Function Documentation

◆ operator const T &() [1/2]

template<typename T>
KOKKOS_FUNCTION Moose::Kokkos::ReferenceWrapper< T >::operator const T & ( ) const
inlineinherited

Get the const reference of the stored variable.

Returns
The const reference of the stored variable depending on the architecture this function is being called on

Definition at line 57 of file KokkosReferenceWrapper.h.

58  {
59  KOKKOS_IF_ON_HOST(return _reference;)
60 
61  return _copy;
62  }
T & _reference
Writeable host reference of the variable.
const T _copy
Device copy of the variable.

◆ operator const T &() [2/2]

template<typename T>
Moose::Kokkos::ReferenceWrapper< T >::operator const T & ( ) const
inlineinherited

Get the const reference of the stored host reference.

Returns
The const reference of the stored host reference

Definition at line 102 of file KokkosReferenceWrapper.h.

102 { return _reference; }
T & _reference
Writeable host reference of the variable.

◆ operator T&()

template<typename T>
Moose::Kokkos::ReferenceWrapper< T >::operator T & ( )
inlineinherited

Get the writeable reference of the stored host reference.

Returns
The writeable reference of the stored host reference

Definition at line 127 of file KokkosReferenceWrapper.h.

127 { return _reference; }
T & _reference
Writeable host reference of the variable.

◆ operator()() [1/3]

template<typename T>
template<typename... Args>
KOKKOS_FUNCTION auto Moose::Kokkos::ReferenceWrapper< T >::operator() ( Args &&...  args) const -> decltype(auto)
inlineinherited

Forward arguments to the stored variable's const operator() depending on the architecture this function is being called on.

Parameters
argsThe variadic arguments to be forwarded

Definition at line 91 of file KokkosReferenceWrapper.h.

92  {
93  KOKKOS_IF_ON_HOST(return _reference(std::forward<Args>(args)...);)
94 
95  return _copy(std::forward<Args>(args)...);
96  }
T & _reference
Writeable host reference of the variable.
const T _copy
Device copy of the variable.

◆ operator()() [2/3]

template<typename T>
template<typename... Args>
auto Moose::Kokkos::ReferenceWrapper< T >::operator() ( Args &&...  args) const -> decltype(auto)
inlineinherited

Forward arguments to the stored host reference's const operator()

Parameters
argsThe variadic arguments to be forwarded

Definition at line 118 of file KokkosReferenceWrapper.h.

119  {
120  return _reference(std::forward<Args>(args)...);
121  }
T & _reference
Writeable host reference of the variable.

◆ operator()() [3/3]

template<typename T>
template<typename... Args>
auto Moose::Kokkos::ReferenceWrapper< T >::operator() ( Args &&...  args) -> decltype(auto)
inlineinherited

Forward arguments to the stored host reference's operator()

Parameters
argsThe variadic arguments to be forwarded

Definition at line 143 of file KokkosReferenceWrapper.h.

144  {
145  return _reference(std::forward<Args>(args)...);
146  }
T & _reference
Writeable host reference of the variable.

◆ operator*() [1/3]

template<typename T>
KOKKOS_FUNCTION const T& Moose::Kokkos::ReferenceWrapper< T >::operator* ( ) const
inlineinherited

Get the const reference of the stored variable.

Returns
The const reference of the stored variable depending on the architecture this function is being called on

Definition at line 68 of file KokkosReferenceWrapper.h.

69  {
70  KOKKOS_IF_ON_HOST(return _reference;)
71 
72  return _copy;
73  }
T & _reference
Writeable host reference of the variable.
const T _copy
Device copy of the variable.

◆ operator*() [2/3]

template<typename T>
const T& Moose::Kokkos::ReferenceWrapper< T >::operator* ( ) const
inlineinherited

Get the const reference of the stored host reference.

Returns
The const reference of the stored host reference

Definition at line 107 of file KokkosReferenceWrapper.h.

107 { return _reference; }
T & _reference
Writeable host reference of the variable.

◆ operator*() [3/3]

template<typename T>
T& Moose::Kokkos::ReferenceWrapper< T >::operator* ( )
inlineinherited

Get the writeable reference of the stored host reference.

Returns
The writeable reference of the stored host reference

Definition at line 132 of file KokkosReferenceWrapper.h.

132 { return _reference; }
T & _reference
Writeable host reference of the variable.

◆ operator->() [1/3]

template<typename T>
KOKKOS_FUNCTION const T* Moose::Kokkos::ReferenceWrapper< T >::operator-> ( ) const
inlineinherited

Get the const pointer to the stored variable.

Returns
The const pointer to the stored variable depending on the architecture this function is being called on

Definition at line 79 of file KokkosReferenceWrapper.h.

80  {
81  KOKKOS_IF_ON_HOST(return &_reference;)
82 
83  return &_copy;
84  }
T & _reference
Writeable host reference of the variable.
const T _copy
Device copy of the variable.

◆ operator->() [2/3]

template<typename T>
const T* Moose::Kokkos::ReferenceWrapper< T >::operator-> ( ) const
inlineinherited

Get the const pointer of the stored host reference.

Returns
The const pointer to the stored host reference

Definition at line 112 of file KokkosReferenceWrapper.h.

112 { return &_reference; }
T & _reference
Writeable host reference of the variable.

◆ operator->() [3/3]

template<typename T>
T* Moose::Kokkos::ReferenceWrapper< T >::operator-> ( )
inlineinherited

Get the writeable pointer of the stored host reference.

Returns
The writeable pointer to the stored host reference

Definition at line 137 of file KokkosReferenceWrapper.h.

137 { return &_reference; }
T & _reference
Writeable host reference of the variable.

◆ operator=()

template<typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
auto& Moose::Kokkos::Scalar< T, typename >::operator= ( value)
inline

Assign a scalar value to the underlying host reference.

Parameters
valueThe scalar value to be assigned

Definition at line 37 of file KokkosScalar.h.

38  {
39  this->_reference = value;
40 
41  return *this;
42  }
T & _reference
Writeable host reference of the variable.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

Member Data Documentation

◆ _copy

template<typename T>
const T Moose::Kokkos::ReferenceWrapper< T >::_copy
protectedinherited

◆ _reference

template<typename T>
T& Moose::Kokkos::ReferenceWrapper< T >::_reference
protectedinherited

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