1#ifndef KOKKOS_UTILS_CALLBACKS_EVENTS_HPP
2#define KOKKOS_UTILS_CALLBACKS_EVENTS_HPP
6#include "impl/Kokkos_Profiling.hpp"
14bool operator==(
const Kokkos_Profiling_SpaceHandle& fst,
const Kokkos_Profiling_SpaceHandle& snd) {
15 return strcmp(fst.name, snd.name) == 0;
103 Kokkos_Profiling_SpaceHandle
kpsh {};
105 const void*
ptr =
nullptr;
219template <
typename EventType>
222 std::constructible_from<EventType, const char*, uint32_t, uint64_t> &&
223 requires (EventType event) {
224 {
event.name } -> std::same_as<std::string&>;
225 {
event.dev_id } -> std::same_as<uint32_t&>;
226 {
event.event_id } -> std::same_as<uint64_t&>;
230template <
typename EventType>
233 std::constructible_from<EventType, uint64_t> &&
234 requires (EventType event) {
235 {
event.event_id } -> std::same_as<uint64_t&>;
239template <
typename EventType>
242 std::constructible_from<EventType, AllocDescriptor> &&
243 requires (EventType event) {
244 {
event.alloc } -> std::same_as<AllocDescriptor&>;
248template <
typename EventType>
251 std::constructible_from<EventType, uint32_t> &&
252 requires (EventType event) {
253 {
event.section_id } -> std::same_as<uint32_t&>;
257template <
typename EventType>
260 requires (EventType event) {
261 {
event.name } -> std::same_as<std::string&>;
265template <
typename EventType>
267 {
event.event_id } -> std::same_as<uint64_t&>;
271template <
typename EventType>
273 {
event.dev_id } -> std::same_as<uint32_t&>;
277template <
typename T,
typename... EventTypes>
283template <Event EventType>
286#define PAIRED_EVENT_TYPE(__begin_eventtype__, __end_eventtype__) \
288 struct PairedEventType<__begin_eventtype__> { using type = __end_eventtype__; };
300template <
Event EventType>
307template <
Event EventType>
309 return Kokkos::Impl::TypeInfo<EventType>::name().substr(26);
312template <Event EventType>
313std::ostream&
operator<<(std::ostream &out,
const EventType& ) {
314 return out << get_name<EventType>() <<
": "
318template <BeginEvent EventType>
319std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
320 return out << get_name<EventType>() <<
": "
321 <<
"{name = " << std::quoted(event.name) <<
", dev_id = " <<
event.dev_id <<
", event_id = " <<
event.event_id <<
"}";
324template <EndEvent EventType>
325std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
326 return out << get_name<EventType>() <<
": "
327 <<
"{event_id = " <<
event.event_id <<
"}";
330template <DataEvent EventType>
331std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
332 const auto& alloc =
event.alloc;
333 return out << get_name<EventType>() <<
": "
334 <<
"{name = " << std::quoted(alloc.name) <<
", space = " << std::quoted(alloc.kpsh.name) <<
", ptr = " << alloc.ptr <<
", size = " << alloc.size <<
"}";
338 const auto& dst =
event.dst;
339 const auto& src =
event.src;
340 return out << get_name<BeginDeepCopyEvent>() <<
": "
341 <<
"{src = " << std::quoted(src.name) <<
" (" << src.kpsh.name <<
", " << src.ptr <<
") -> "
342 <<
"dst = " << std::quoted(dst.name) <<
" (" << dst.kpsh.name <<
", " << dst.ptr <<
") of size " << src.size <<
"}";
346 return out << get_name<CreateProfileSectionEvent>() <<
": "
347 <<
"{name = " << std::quoted(event.
name) <<
", section_id = " <<
event.section_id <<
"}";
350template <ProfileSectionManipulationEvent EventType>
351std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
352 return out << get_name<EventType>() <<
": "
353 <<
"{section_id = " <<
event.section_id <<
"}";
357 return out << get_name<PushRegionEvent>() <<
": "
358 <<
"{name = " << std::quoted(event.
name) <<
"}";
362 return out << get_name<ProfileEvent>() <<
": "
363 <<
"{name = " << std::quoted(event.
name) <<
"}";
370template <Event EventType>
374#define GET_CALLBACK_FROM_EVENTSET(__eventtype__, __callback__) \
376 inline auto get_callback_from_eventset<__eventtype__>(const Kokkos::Tools::Experimental::EventSet& event_set) { return event_set.__callback__; }
399template <
Event EventType>
403#define GET_CALLBACK_SETTER(__eventtype__, __callback_setter__) \
405 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 &)
constexpr auto get_name()
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.
bool operator==(const BeginFenceEvent &) const =default
bool operator==(const BeginParallelForEvent &) const =default
Begin-parallel-reduce event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_red...
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
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.
bool operator==(const EndFenceEvent &) const =default
End-parallel-for event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_for.
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
End-parallel-scan event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_scan.
bool operator==(const EndParallelScanEvent &) const =default
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