https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Moose::Kokkos::DispatcherRegistry Class Reference

Class that registers dispatchers of all Kokkos functors. More...

#include <KokkosDispatcher.h>

Public Member Functions

 DispatcherRegistry ()=default
 
 DispatcherRegistry (DispatcherRegistry const &)=delete
 
DispatcherRegistryoperator= (DispatcherRegistry const &)=delete
 
 DispatcherRegistry (DispatcherRegistry &&)=delete
 
DispatcherRegistryoperator= (DispatcherRegistry &&)=delete
 

Static Public Member Functions

template<typename Operation , typename Object >
static void addDispatcher (const std::string &name)
 Register a dispatcher of an operation of a functor.
 
template<typename Operation , typename Object >
static void addReducer (const std::string &name)
 Register a reducer of an operation of a functor.
 
template<typename Operation >
static void hasUserMethod (const std::string &name, const bool flag)
 Set whether the user has overriden the hook method associated with an operation of a functor.
 
template<typename Operation >
static bool hasUserMethod (const std::string &name)
 Get whether the user has overriden the hook method associated with an operation of a functor.
 
template<typename Operation >
static std::unique_ptr< DispatcherBasebuild (const void *object, const std::string &name)
 Build and get a dispatcher of an operation of a functor.
 

Static Private Member Functions

static DispatcherRegistrygetRegistry ()
 Get the registry singleton.
 
template<typename Operation >
static auto & getDispatcher (const std::string &name)
 Get the dispatcher shell of an operation of a functor.
 

Private Attributes

std::map< std::pair< std::type_index, std::string >, std::unique_ptr< DispatcherRegistryEntryBase > > _dispatchers
 Map containing the dispatcher shells with the key being the pair of function tag type index and registered object type name.
 

Detailed Description

Class that registers dispatchers of all Kokkos functors.

Definition at line 251 of file KokkosDispatcher.h.

Constructor & Destructor Documentation

◆ DispatcherRegistry() [1/3]

Moose::Kokkos::DispatcherRegistry::DispatcherRegistry ( )
default

◆ DispatcherRegistry() [2/3]

Moose::Kokkos::DispatcherRegistry::DispatcherRegistry ( DispatcherRegistry const &  )
delete

◆ DispatcherRegistry() [3/3]

Moose::Kokkos::DispatcherRegistry::DispatcherRegistry ( DispatcherRegistry &&  )
delete

Member Function Documentation

◆ addDispatcher()

template<typename Operation , typename Object >
static void Moose::Kokkos::DispatcherRegistry::addDispatcher ( const std::string &  name)
inlinestatic

Register a dispatcher of an operation of a functor.

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

Definition at line 269 of file KokkosDispatcher.h.

270 {
271 auto operation = std::type_index(typeid(Operation));
272
273 getRegistry()._dispatchers[std::make_pair(operation, name)] =
274 std::make_unique<DispatcherRegistryEntry<Operation, Object>>();
275 }
std::map< std::pair< std::type_index, std::string >, std::unique_ptr< DispatcherRegistryEntryBase > > _dispatchers
Map containing the dispatcher shells with the key being the pair of function tag type index and regis...
static DispatcherRegistry & getRegistry()
Get the registry singleton.

◆ addReducer()

template<typename Operation , typename Object >
static void Moose::Kokkos::DispatcherRegistry::addReducer ( const std::string &  name)
inlinestatic

Register a reducer of an operation of a functor.

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

Definition at line 284 of file KokkosDispatcher.h.

285 {
286 auto operation = std::type_index(typeid(Operation));
287
288 getRegistry()._dispatchers[std::make_pair(operation, name)] =
289 std::make_unique<ReducerRegistryEntry<Operation, Object>>();
290 }

◆ build()

template<typename Operation >
static std::unique_ptr< DispatcherBase > Moose::Kokkos::DispatcherRegistry::build ( const void *  object,
const std::string &  name 
)
inlinestatic

Build and get a dispatcher of an operation of a functor.

Template Parameters
OperationThe function tag of operator()
Parameters
objectThe pointer to the functor
nameThe registered object type name
Returns
The dispatcher

Definition at line 324 of file KokkosDispatcher.h.

325 {
326 return getDispatcher<Operation>(name)->build(object);
327 }

◆ getDispatcher()

template<typename Operation >
static auto & Moose::Kokkos::DispatcherRegistry::getDispatcher ( const std::string &  name)
inlinestaticprivate

Get the dispatcher shell of an operation of a functor.

Template Parameters
OperationThe function tag of operator()
Parameters
nameThe registered object type name
Returns
The dispatcher shell

Definition at line 343 of file KokkosDispatcher.h.

344 {
345 auto operation = std::type_index(typeid(Operation));
346
347 auto it = getRegistry()._dispatchers.find(std::make_pair(operation, name));
348 if (it == getRegistry()._dispatchers.end())
349 mooseError("Kokkos functor dispatcher not registered for object type '",
350 name,
351 "'. Double check that you used Kokkos-specific registration macro.");
352
353 return it->second;
354 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311

◆ getRegistry()

static DispatcherRegistry & Moose::Kokkos::DispatcherRegistry::getRegistry ( )
staticprivate

Get the registry singleton.

Returns
The registry singleton

Referenced by addDispatcher(), addReducer(), and getDispatcher().

◆ hasUserMethod() [1/2]

template<typename Operation >
static bool Moose::Kokkos::DispatcherRegistry::hasUserMethod ( const std::string &  name)
inlinestatic

Get whether the user has overriden the hook method associated with an operation of a functor.

Template Parameters
OperationThe function tag of operator()
Parameters
nameThe registered object type name
Returns
Whether the user has overriden the hook method

Definition at line 311 of file KokkosDispatcher.h.

312 {
313 return getDispatcher<Operation>(name)->hasUserMethod();
314 }

◆ hasUserMethod() [2/2]

template<typename Operation >
static void Moose::Kokkos::DispatcherRegistry::hasUserMethod ( const std::string &  name,
const bool  flag 
)
inlinestatic

Set whether the user has overriden the hook method associated with an operation of a functor.

Template Parameters
OperationThe function tag of operator()
Parameters
nameThe registered object type name
flagWhether the user has overriden the hook method

Definition at line 299 of file KokkosDispatcher.h.

300 {
301 getDispatcher<Operation>(name)->hasUserMethod(flag);
302 }

◆ operator=() [1/2]

DispatcherRegistry & Moose::Kokkos::DispatcherRegistry::operator= ( DispatcherRegistry &&  )
delete

◆ operator=() [2/2]

DispatcherRegistry & Moose::Kokkos::DispatcherRegistry::operator= ( DispatcherRegistry const &  )
delete

Member Data Documentation

◆ _dispatchers

std::map<std::pair<std::type_index, std::string>, std::unique_ptr<DispatcherRegistryEntryBase> > Moose::Kokkos::DispatcherRegistry::_dispatchers
private

Map containing the dispatcher shells with the key being the pair of function tag type index and registered object type name.

Definition at line 361 of file KokkosDispatcher.h.

Referenced by addDispatcher(), addReducer(), and getDispatcher().


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