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 add (const std::string &name)
 Register a dispatcher of an operation of a functor. More...
 
template<typename Operation >
static void hasUserMethod (const std::string &name, 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 148 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

◆ add()

template<typename Operation , typename Object >
static void Moose::Kokkos::DispatcherRegistry::add ( 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 166 of file KokkosDispatcher.h.

167  {
168  auto operation = std::type_index(typeid(Operation));
169 
170  getRegistry()._dispatchers[std::make_pair(operation, name)] =
171  std::make_unique<DispatcherRegistryEntry<Operation, Object>>();
172  }
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 206 of file KokkosDispatcher.h.

207  {
208  return getDispatcher<Operation>(name)->build(object);
209  }
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 225 of file KokkosDispatcher.h.

226  {
227  auto operation = std::type_index(typeid(Operation));
228 
229  auto it = getRegistry()._dispatchers.find(std::make_pair(operation, name));
230  if (it == getRegistry()._dispatchers.end())
231  mooseError("Kokkos functor dispatcher not registered for object type '",
232  name,
233  "'. Double check that you used Kokkos-specific registration macro.");
234 
235  return it->second;
236  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
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 add(), and getDispatcher().

◆ hasUserMethod() [1/2]

template<typename Operation >
static void Moose::Kokkos::DispatcherRegistry::hasUserMethod ( const std::string &  name,
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 181 of file KokkosDispatcher.h.

Referenced by hasUserMethod().

182  {
183  getDispatcher<Operation>(name)->hasUserMethod(flag);
184  }
std::string name(const ElemQuality q)
static void hasUserMethod(const std::string &name, 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 193 of file KokkosDispatcher.h.

194  {
195  return getDispatcher<Operation>(name)->hasUserMethod();
196  }
std::string name(const ElemQuality q)
static void hasUserMethod(const std::string &name, 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 243 of file KokkosDispatcher.h.

Referenced by add(), and getDispatcher().


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