1#ifndef KOKKOS_UTILS_CALLBACKS_EVENTS_HPP
2#define KOKKOS_UTILS_CALLBACKS_EVENTS_HPP
6#include "impl/Kokkos_Profiling.hpp"
21bool operator==(
const Kokkos_Profiling_SpaceHandle& fst,
const Kokkos_Profiling_SpaceHandle& snd) {
22 return strcmp(fst.name, snd.name) == 0;
110 Kokkos_Profiling_SpaceHandle
kpsh {};
112 const void*
ptr =
nullptr;
223concept Event = std::default_initializable<T>
226 && std::equality_comparable<T>;
229template <
typename EventType>
232 std::constructible_from<EventType, const char*, uint32_t, EventTraits::event_id_t> &&
233 requires (EventType event) {
234 {
event.name } -> std::same_as<std::string&>;
235 {
event.dev_id } -> std::same_as<uint32_t&>;
236 {
event.event_id } -> std::same_as<EventTraits::event_id_t&>;
240template <
typename EventType>
243 std::constructible_from<EventType, EventTraits::event_id_t> &&
244 requires (EventType event) {
245 {
event.event_id } -> std::same_as<EventTraits::event_id_t&>;
249template <
typename EventType>
252 std::constructible_from<EventType, AllocDescriptor> &&
253 requires (EventType event) {
254 {
event.alloc } -> std::same_as<AllocDescriptor&>;
258template <
typename EventType>
261 std::constructible_from<EventType, uint32_t> &&
262 requires (EventType event) {
263 {
event.section_id } -> std::same_as<uint32_t&>;
267template <
typename EventType>
270 requires (EventType event) {
271 {
event.name } -> std::same_as<std::string&>;
275template <
typename EventType>
277 {
event.event_id } -> std::same_as<EventTraits::event_id_t&>;
281template <
typename EventType>
283 {
event.dev_id } -> std::same_as<uint32_t&>;
287template <
typename T,
typename... EventTypes>
293template <Event EventType>
296#define PAIRED_EVENT_TYPE(__begin_eventtype__, __end_eventtype__) \
298 struct PairedEventType<__begin_eventtype__> { using type = __end_eventtype__; };
310template <
Event EventType>
323 return Kokkos::Impl::TypeInfo<T>::name().substr(26);
326template <BeginEvent EventType>
327std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
328 return out << get_name<EventType>() <<
": "
329 <<
"{name = " << std::quoted(event.name) <<
", dev_id = " <<
event.dev_id <<
", event_id = " <<
event.event_id <<
"}";
332template <EndEvent EventType>
333std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
334 return out << get_name<EventType>() <<
": "
335 <<
"{event_id = " <<
event.event_id <<
"}";
338template <DataEvent EventType>
339std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
340 const auto& alloc =
event.alloc;
341 return out << get_name<EventType>() <<
": "
342 <<
"{name = " << std::quoted(alloc.name) <<
", space = " << std::quoted(alloc.kpsh.name) <<
", ptr = " << alloc.ptr <<
", size = " << alloc.size <<
"}";
346 const auto& dst =
event.dst;
347 const auto& src =
event.src;
348 return out << get_name<BeginDeepCopyEvent>() <<
": "
349 <<
"{src = " << std::quoted(src.name) <<
" (" << src.kpsh.name <<
", " << src.ptr <<
") -> "
350 <<
"dst = " << std::quoted(dst.name) <<
" (" << dst.kpsh.name <<
", " << dst.ptr <<
") of size " << src.size <<
"}";
354 return out << get_name<EndDeepCopyEvent>() <<
": "
359 return out << get_name<CreateProfileSectionEvent>() <<
": "
360 <<
"{name = " << std::quoted(event.
name) <<
", section_id = " <<
event.section_id <<
"}";
363template <ProfileSectionManipulationEvent EventType>
364std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
365 return out << get_name<EventType>() <<
": "
366 <<
"{section_id = " <<
event.section_id <<
"}";
370 return out << get_name<PushRegionEvent>() <<
": "
371 <<
"{name = " << std::quoted(event.
name) <<
"}";
375 return out << get_name<PopRegionEvent>() <<
": "
380 return out << get_name<ProfileEvent>() <<
": "
381 <<
"{name = " << std::quoted(event.
name) <<
"}";
385 return out << get_name<AllocDescriptor>() <<
": "
386 <<
"{name = " << std::quoted(descr.
name) <<
" (" << descr.
kpsh.name <<
", " << descr.
ptr <<
") of size " << descr.
size <<
'}';
393template <Event EventType>
397#define GET_CALLBACK_FROM_EVENTSET(__eventtype__, __callback__) \
399 inline auto get_callback_from_eventset<__eventtype__>(const Kokkos::Tools::Experimental::EventSet& event_set) { return event_set.__callback__; }
422template <
Event EventType>
426#define GET_CALLBACK_SETTER(__eventtype__, __callback_setter__) \
428 inline auto get_callback_setter<__eventtype__>() { return &Kokkos::Tools::Experimental::__callback_setter__; }
#define PAIRED_EVENT_TYPE(__begin_eventtype__, __end_eventtype__)
#define GET_CALLBACK_SETTER(__eventtype__, __callback_setter__)
Helper macro related to the implementation of Kokkos::utils::callbacks::get_callback_setter.
#define GET_CALLBACK_FROM_EVENTSET(__eventtype__, __callback__)
Helper macro related to the implementation of Kokkos::utils::callbacks::get_callback_from_eventset.
Concept to constrain any begin event type.
Concept to constrain any data event type.
Concept to constrain any end event type.
Concept to constrain any event type that has a member variable dev_id.
Concept to constrain any event type that is one of the given event types.
Concept to constrain any event type that has a member variable event_id.
Concept to constrain any event type that has a name field.
Concept to constrain any profile section manipulation event type.
bool operator==(const Kokkos_Profiling_SpaceHandle &fst, const Kokkos_Profiling_SpaceHandle &snd)
Equality comparison for Kokkos_Profiling_SpaceHandle.
std::ostream & operator<<(std::ostream &out, const EventType &event)
constexpr auto get_name()
Helper function to remove the Kokkos::utils::callbacks:: prefix.
typename PairedEventType< EventType >::type paired_event_t
Kokkos::Impl::type_list< BeginParallelForEvent, EndParallelForEvent, BeginParallelReduceEvent, EndParallelReduceEvent, BeginParallelScanEvent, EndParallelScanEvent, BeginFenceEvent, EndFenceEvent, AllocateDataEvent, DeallocateDataEvent, BeginDeepCopyEvent, EndDeepCopyEvent, CreateProfileSectionEvent, DestroyProfileSectionEvent, StartProfileSectionEvent, StopProfileSectionEvent, PushRegionEvent, PopRegionEvent, ProfileEvent > EventTypeList
Type list holding all event types.
auto get_callback_from_eventset(const Kokkos::Tools::Experimental::EventSet &event_set)
auto get_callback_setter()
Get the setter function of a Kokkos profiling callback corresponding to EventType.
constexpr bool type_list_contains_v
Helper struct to hold descriptors of a data allocation.
Kokkos_Profiling_SpaceHandle kpsh
bool operator==(const AllocDescriptor &) const =default
Allocate-data event associated with Kokkos::Tools::Experimental::EventSet::allocate_data.
bool operator==(const AllocateDataEvent &) const =default
Begin-deep-copy event associated with Kokkos::Tools::Experimental::EventSet::begin_deep_copy.
bool operator==(const BeginDeepCopyEvent &) const =default
Begin-fence event associated with Kokkos::Tools::Experimental::EventSet::begin_fence.
EventTraits::event_id_t event_id
bool operator==(const BeginFenceEvent &) const =default
bool operator==(const BeginParallelForEvent &) const =default
EventTraits::event_id_t event_id
Begin-parallel-reduce event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_red...
EventTraits::event_id_t event_id
bool operator==(const BeginParallelReduceEvent &) const =default
Begin-parallel-scan event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_scan.
bool operator==(const BeginParallelScanEvent &) const =default
EventTraits::event_id_t event_id
Create-profile-section event associated with Kokkos::Tools::Experimental::EventSet::create_profile_se...
bool operator==(const CreateProfileSectionEvent &) const =default
Deallocate-data event associated with Kokkos::Tools::Experimental::EventSet::deallocate_data.
bool operator==(const DeallocateDataEvent &) const =default
Destroy-profile-section event associated with Kokkos::Tools::Experimental::EventSet::destroy_profile_...
bool operator==(const DestroyProfileSectionEvent &) const =default
End-deep-copy event associated with Kokkos::Tools::Experimental::EventSet::end_deep_copy.
bool operator==(const EndDeepCopyEvent &) const =default
End-fence event associated with Kokkos::Tools::Experimental::EventSet::end_fence.
EventTraits::event_id_t event_id
bool operator==(const EndFenceEvent &) const =default
End-parallel-for event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_for.
EventTraits::event_id_t event_id
bool operator==(const EndParallelForEvent &) const =default
End-parallel-reduce event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_reduce.
bool operator==(const EndParallelReduceEvent &) const =default
EventTraits::event_id_t event_id
End-parallel-scan event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_scan.
EventTraits::event_id_t event_id
bool operator==(const EndParallelScanEvent &) const =default
static constexpr event_id_t invalid_event_id
Pop-region event associated with Kokkos::Tools::Experimental::EventSet::pop_region.
bool operator==(const PopRegionEvent &) const =default
Profile event associated with Kokkos::Tools::Experimental::EventSet::profile_event.
bool operator==(const ProfileEvent &) const =default
Push-region event associated with Kokkos::Tools::Experimental::EventSet::push_region.
bool operator==(const PushRegionEvent &) const =default
Start-profile-section event associated with Kokkos::Tools::Experimental::EventSet::start_profile_sect...
bool operator==(const StartProfileSectionEvent &) const =default
Stop-profile-section event associated with Kokkos::Tools::Experimental::EventSet::stop_profile_sectio...
bool operator==(const StopProfileSectionEvent &) const =default