https://mooseframework.inl.gov
Public Member Functions | Private Attributes | List of all members
Moose::Kokkos::Dispatcher< Operation, Object > Class Template Reference

Class that dispatches an operation of a Kokkos functor. More...

#include <KokkosDispatcher.h>

Inheritance diagram for Moose::Kokkos::Dispatcher< Operation, Object >:
[legend]

Public Member Functions

 Dispatcher (const void *object)
 Constructor. More...
 
 Dispatcher (const Dispatcher &functor)
 Copy constructor for parallel dispatch. More...
 
void parallelFor (const Policy &policy) override final
 Dispatch this functor with Kokkos parallel_for() given a Kokkos execution policy. More...
 
KOKKOS_FUNCTION void operator() (const ThreadID tid) const
 The parallel computation entry function called by Kokkos. More...
 

Private Attributes

const Object & _functor_host
 Reference of the functor on host. More...
 
const Object _functor_device
 Copy of the functor on device. More...
 

Detailed Description

template<typename Operation, typename Object>
class Moose::Kokkos::Dispatcher< Operation, Object >

Class that dispatches an operation of a Kokkos functor.

Calls operator() of the functor with a specified function tag.

Template Parameters
OperationThe function tag of operator() to be dispatched
ObjectThe functor class type

Definition at line 47 of file KokkosDispatcher.h.

Constructor & Destructor Documentation

◆ Dispatcher() [1/2]

template<typename Operation , typename Object >
Moose::Kokkos::Dispatcher< Operation, Object >::Dispatcher ( const void object)
inline

Constructor.

Parameters
objectThe pointer to the functor. This dispatcher is constructed by the base class of functors, and the actual type of functors is unknown by the base class. Therefore, it is passed as a void pointer and cast to the actual type here.

Definition at line 56 of file KokkosDispatcher.h.

57  : _functor_host(*static_cast<const Object *>(object)), _functor_device(_functor_host)
58  {
59  }
const Object _functor_device
Copy of the functor on device.
const Object & _functor_host
Reference of the functor on host.

◆ Dispatcher() [2/2]

template<typename Operation , typename Object >
Moose::Kokkos::Dispatcher< Operation, Object >::Dispatcher ( const Dispatcher< Operation, Object > &  functor)
inline

Copy constructor for parallel dispatch.

Definition at line 63 of file KokkosDispatcher.h.

64  : _functor_host(functor._functor_host), _functor_device(functor._functor_host)
65  {
66  }
const Object _functor_device
Copy of the functor on device.
const Object & _functor_host
Reference of the functor on host.

Member Function Documentation

◆ operator()()

template<typename Operation , typename Object >
KOKKOS_FUNCTION void Moose::Kokkos::Dispatcher< Operation, Object >::operator() ( const ThreadID  tid) const
inline

The parallel computation entry function called by Kokkos.

Definition at line 77 of file KokkosDispatcher.h.

78  {
79  _functor_device(Operation{}, tid, _functor_device);
80  }
const Object _functor_device
Copy of the functor on device.

◆ parallelFor()

template<typename Operation , typename Object >
void Moose::Kokkos::Dispatcher< Operation, Object >::parallelFor ( const Policy policy)
inlinefinaloverridevirtual

Dispatch this functor with Kokkos parallel_for() given a Kokkos execution policy.

Parameters
policyThe Kokkos execution policy

Implements Moose::Kokkos::DispatcherBase.

Definition at line 68 of file KokkosDispatcher.h.

69  {
70  ::Kokkos::parallel_for(policy, *this);
71  ::Kokkos::fence();
72  }

Member Data Documentation

◆ _functor_device

template<typename Operation , typename Object >
const Object Moose::Kokkos::Dispatcher< Operation, Object >::_functor_device
private

Copy of the functor on device.

Definition at line 90 of file KokkosDispatcher.h.

Referenced by Moose::Kokkos::Dispatcher< Operation, Object >::operator()().

◆ _functor_host

template<typename Operation , typename Object >
const Object& Moose::Kokkos::Dispatcher< Operation, Object >::_functor_host
private

Reference of the functor on host.

Definition at line 86 of file KokkosDispatcher.h.


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