https://mooseframework.inl.gov
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. More...
 
template<typename Operation , typename Object >
static void addReducer (const std::string &name)
 Register a reducer of an operation of a functor. More...
 
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. More...
 
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. More...
 
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. More...
 

Static Private Member Functions

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

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. More...
 

Detailed Description

Class that registers dispatchers of all Kokkos functors.

Definition at line 250 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 268 of file KokkosDispatcher.h.

269  {
270  auto operation = std::type_index(typeid(Operation));
271 
272  getRegistry()._dispatchers[std::make_pair(operation, name)] =
273  std::make_unique<DispatcherRegistryEntry<Operation, Object>>();
274  }
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 283 of file KokkosDispatcher.h.

284  {
285  auto operation = std::type_index(typeid(Operation));
286 
287  getRegistry()._dispatchers[std::make_pair(operation, name)] =
288  std::make_unique<ReducerRegistryEntry<Operation, Object>>();
289  }
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.

◆ 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 323 of file KokkosDispatcher.h.

324  {
325  return getDispatcher<Operation>(name)->build(object);
326  }
std::string name(const ElemQuality q)
static std::unique_ptr< DispatcherBase > build(const void *object, const std::string &name)
Build and get a dispatcher of an operation of a functor.

◆ 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 342 of file KokkosDispatcher.h.

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

◆ 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 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 298 of file KokkosDispatcher.h.

Referenced by hasUserMethod().

299  {
300  getDispatcher<Operation>(name)->hasUserMethod(flag);
301  }
std::string name(const ElemQuality q)
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...

◆ hasUserMethod() [2/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 310 of file KokkosDispatcher.h.

311  {
312  return getDispatcher<Operation>(name)->hasUserMethod();
313  }
std::string name(const ElemQuality q)
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...

◆ operator=() [1/2]

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

◆ operator=() [2/2]

DispatcherRegistry& Moose::Kokkos::DispatcherRegistry::operator= ( DispatcherRegistry &&  )
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 360 of file KokkosDispatcher.h.

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


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