Class to manage Kokkos profiling callback calls. More...
#include <Manager.hpp>
Public Types | |
using | listener_list_t = std::list<std::unique_ptr<impl::ListenerConceptBase>> |
using | listener_list_const_iter_t = typename listener_list_t::const_iterator |
using | listener_call_opr_list_tuple_t = impl::listener_call_opr_list_tuple_t |
Public Member Functions | |
Manager (const Manager &)=delete | |
Manager & | operator= (const Manager &)=delete |
~Manager () | |
Static Public Member Functions | |
static void | initialize () |
static void | finalize () |
static Manager & | get_instance () |
template<Listener Callable> | |
static listener_list_const_iter_t | register_listener (std::shared_ptr< Callable > callable) |
Register a callable object, passed as a shared pointer, as a listener. | |
template<typename T> requires Listener<std::remove_cvref_t<T>> | |
static listener_list_const_iter_t | register_listener (T &&callable) |
template<Listener Callable> | |
static void | unregister_listener (const Callable *const callable) |
Unregister a callable object as a listener. | |
static void | unregister_listener (const listener_list_const_iter_t &iter) |
Protected Member Functions | |
Manager () | |
Constructor. Retrieves and stores the Kokkos::Tools::Experimental::EventSet containing the Kokkos callback function pointers. | |
Private Member Functions | |
void | reset_context_callbacks () const |
Uses Kokkos::Tools::Experimental::set_callbacks to restore the Kokkos callback function pointers to those retrieved on this class's initialization. | |
void | set_dispatching_callbacks () const |
Uses the setters Kokkos::Tools::Experimental::set_<event_type_name>_callback to set the Kokkos callback function pointers to this class's dispatching functions for the event types for which there are registered callbacks. | |
template<Event EventType> | |
void | set_dispatching_callback_impl () const |
template<Event EventType> | |
void | dispatch (EventType &event) |
Dispatch first the context callback, if any is set in Kokkos, and then sequentially the registered callbacks for the event type. | |
template<Event EventType> | |
void | dispatch_context_callback (EventType &event) |
Dispatch the event to the context callback, if any is set in Kokkos. | |
template<Event EventType> | |
void | increment_id_if_needed_for_event_type_impl (EventType &) |
template<BeginEvent EventType> | |
void | increment_id_if_needed_for_event_type_impl (EventType &event) |
void | increment_id_if_needed_for_event_type_impl (CreateProfileSectionEvent &event) |
template<Event EventType> | |
void | dispatch_registered_callbacks (const EventType &event) const |
Static Private Member Functions | |
template<typename ListenerModelType, typename CallableType> | |
static listener_list_const_iter_t | register_listener_impl (CallableType &&callable) |
template<Event EventType> | |
static auto | create_dispatching_callback_for_event_type_impl () |
template<BeginEvent EventType> | |
static auto | create_dispatching_callback_for_event_type_impl () |
template<DataEvent EventType> | |
static auto | create_dispatching_callback_for_event_type_impl () |
template<Event EventType> requires std::same_as<EventType, BeginDeepCopyEvent> | |
static auto | create_dispatching_callback_for_event_type_impl () |
template<Event EventType> requires std::same_as<EventType, CreateProfileSectionEvent> | |
static auto | create_dispatching_callback_for_event_type_impl () |
template<typename ContextCallbackType, BeginEvent EventType> | |
static void | dispatch_context_callback_for_event_type_impl (ContextCallbackType *context_callback, EventType &event) |
template<typename ContextCallbackType, EndEvent EventType> | |
static void | dispatch_context_callback_for_event_type_impl (ContextCallbackType *context_callback, const EventType &event) |
template<typename ContextCallbackType, DataEvent EventType> | |
static void | dispatch_context_callback_for_event_type_impl (ContextCallbackType *context_callback, const EventType &event) |
template<typename ContextCallbackType> | |
static void | dispatch_context_callback_for_event_type_impl (ContextCallbackType *context_callback, const BeginDeepCopyEvent &event) |
template<typename ContextCallbackType> | |
static void | dispatch_context_callback_for_event_type_impl (ContextCallbackType *context_callback, const EndDeepCopyEvent &) |
template<typename ContextCallbackType> | |
static void | dispatch_context_callback_for_event_type_impl (ContextCallbackType *context_callback, CreateProfileSectionEvent &event) |
template<typename ContextCallbackType, ProfileSectionManipulationEvent EventType> | |
static void | dispatch_context_callback_for_event_type_impl (ContextCallbackType *context_callback, const EventType &event) |
template<typename ContextCallbackType> | |
static void | dispatch_context_callback_for_event_type_impl (ContextCallbackType *context_callback, const PushRegionEvent &event) |
template<typename ContextCallbackType> | |
static void | dispatch_context_callback_for_event_type_impl (ContextCallbackType *context_callback, const PopRegionEvent &) |
template<typename ContextCallbackType> | |
static void | dispatch_context_callback_for_event_type_impl (ContextCallbackType *context_callback, const ProfileEvent &event) |
Private Attributes | |
listener_call_opr_list_tuple_t | registered_callbacks {} |
listener_list_t | listeners {} |
Kokkos::Tools::Experimental::EventSet | context_callbacks {} |
uint64_t | next_event_id = 0 |
uint32_t | next_section_id = 0 |
Static Private Attributes | |
static std::unique_ptr< Manager > | singleton = nullptr |
Class to manage Kokkos profiling callback calls.
This class allows the registration of callable objects as listeners for events representing Kokkos profiling callback calls.
On initialization, this class uses Kokkos::Tools::Experimental::get_callbacks
to retrieve the callback function pointers already set within Kokkos. Note that this class refers to these callback functions as the "context callbacks".
On registering one or more callable objects as listeners for events, this class stores these callable objects by using a type-erasure pattern. Thus, on registering a callable object, this callable object is wrapped into a impl::ListenerModel that implements the abstract interface composed of impl::ListenerConceptBase and one or more impl::ListenerConceptCallOperator instances. The wrapped callable object is then stored in a list of unique pointers to the abstract base class.
In order to efficiently dispatch events to the corresponding call operators of the callable objects, this class stores for each event type a list of pointers to the listener models wrapping the callable objects that are registered as listeners for this event type. Note that this class refers to the call operators of these registered callable objects as the "registered callbacks".
This class uses the setters Kokkos::Tools::Experimental::set_<event_type_name>_callback
to set the Kokkos callback function pointers to this class's dispatching functions for the event types for which there are registered callbacks. When a Kokkos callback call is made, these dispatching functions call the context callback first and then sequentially the registered callbacks for the event type.
On finalization, this class clears the list of registered callable objects and restores the Kokkos callback function pointers to the values they had prior to initializing this class.
Definition at line 139 of file Manager.hpp.
using Kokkos::utils::callbacks::Manager::listener_call_opr_list_tuple_t = impl::listener_call_opr_list_tuple_t |
Definition at line 144 of file Manager.hpp.
using Kokkos::utils::callbacks::Manager::listener_list_const_iter_t = typename listener_list_t::const_iterator |
Definition at line 143 of file Manager.hpp.
using Kokkos::utils::callbacks::Manager::listener_list_t = std::list<std::unique_ptr<impl::ListenerConceptBase>> |
Definition at line 142 of file Manager.hpp.
|
delete |
|
inline |
Definition at line 150 of file Manager.hpp.
|
inlineprotected |
Constructor. Retrieves and stores the Kokkos::Tools::Experimental::EventSet
containing the Kokkos callback function pointers.
Definition at line 157 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 294 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 303 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 314 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 324 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 338 of file Manager.hpp.
|
inlineprivate |
Dispatch first the context callback, if any is set in Kokkos, and then sequentially the registered callbacks for the event type.
Definition at line 353 of file Manager.hpp.
|
inlineprivate |
Dispatch the event to the context callback, if any is set in Kokkos.
Definition at line 362 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 389 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 395 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 379 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 384 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 405 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 415 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 420 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 410 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 400 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 374 of file Manager.hpp.
|
inlineprivate |
Definition at line 437 of file Manager.hpp.
|
inlinestatic |
Definition at line 161 of file Manager.hpp.
|
inlinestatic |
Definition at line 163 of file Manager.hpp.
|
inlineprivate |
Definition at line 432 of file Manager.hpp.
|
inlineprivate |
Definition at line 425 of file Manager.hpp.
|
inlineprivate |
Definition at line 428 of file Manager.hpp.
|
inlinestatic |
Definition at line 160 of file Manager.hpp.
|
inlinestatic |
Register a callable object, passed as a shared pointer, as a listener.
Definition at line 171 of file Manager.hpp.
|
inlinestatic |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This overload registers a new callable object that is copy or move constructed from the passed callable
. This overload can be useful for instance to register a lambda as a listener.
Definition at line 185 of file Manager.hpp.
|
inlinestaticprivate |
Wrap the callable object into a impl::ListenerModel and store it in the list of listeners.
For each event type that the callable object can be invoked with, store the raw pointer to the listener model in the list of listeners for this event type.
Definition at line 245 of file Manager.hpp.
|
inlineprivate |
Uses Kokkos::Tools::Experimental::set_callbacks
to restore the Kokkos callback function pointers to those retrieved on this class's initialization.
Definition at line 240 of file Manager.hpp.
|
inlineprivate |
Definition at line 282 of file Manager.hpp.
|
inlineprivate |
Uses the setters Kokkos::Tools::Experimental::set_<event_type_name>_callback
to set the Kokkos callback function pointers to this class's dispatching functions for the event types for which there are registered callbacks.
Definition at line 274 of file Manager.hpp.
|
inlinestatic |
Unregister a callable object as a listener.
Definition at line 194 of file Manager.hpp.
|
inlinestatic |
Definition at line 222 of file Manager.hpp.
|
private |
Definition at line 451 of file Manager.hpp.
|
private |
Definition at line 447 of file Manager.hpp.
|
private |
Definition at line 453 of file Manager.hpp.
|
private |
Definition at line 454 of file Manager.hpp.
|
private |
Definition at line 445 of file Manager.hpp.
|
inlinestaticprivate |
Definition at line 447 of file Manager.hpp.