1#ifndef KOKKOS_UTILS_CALLBACKS_EVENTS_HPP
2#define KOKKOS_UTILS_CALLBACKS_EVENTS_HPP
6#include "impl/Kokkos_Profiling.hpp"
82 Kokkos_Profiling_SpaceHandle
kpsh {};
84 const void*
ptr =
nullptr;
172template <
typename EventType>
175 std::constructible_from<EventType, const char*, uint32_t, uint64_t> &&
176 requires (EventType event) {
177 {
event.name } -> std::same_as<std::string&>;
178 {
event.dev_id } -> std::same_as<uint32_t&>;
179 {
event.event_id } -> std::same_as<uint64_t&>;
183template <
typename EventType>
186 std::constructible_from<EventType, uint64_t> &&
187 requires (EventType event) {
188 {
event.event_id } -> std::same_as<uint64_t&>;
192template <
typename EventType>
195 std::constructible_from<EventType, AllocDescriptor> &&
196 requires (EventType event) {
197 {
event.alloc } -> std::same_as<AllocDescriptor&>;
201template <
typename EventType>
204 std::constructible_from<EventType, uint32_t> &&
205 requires (EventType event) {
206 {
event.section_id } -> std::same_as<uint32_t&>;
210template <
typename EventType>
213 requires (EventType event) {
214 {
event.name } -> std::same_as<std::string&>;
218template <
typename T,
typename EventTypeListType>
225template <Event EventType>
227 return Kokkos::Impl::TypeInfo<EventType>::name().substr(26);
230template <Event EventType>
231std::ostream&
operator<<(std::ostream &out,
const EventType& ) {
232 return out << get_name<EventType>() <<
": "
236template <BeginEvent EventType>
237std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
238 return out << get_name<EventType>() <<
": "
239 <<
"{name = " << std::quoted(event.name) <<
", dev_id = " <<
event.dev_id <<
", event_id = " <<
event.event_id <<
"}";
242template <EndEvent EventType>
243std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
244 return out << get_name<EventType>() <<
": "
245 <<
"{event_id = " <<
event.event_id <<
"}";
248template <DataEvent EventType>
249std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
250 const auto& alloc =
event.alloc;
251 return out << get_name<EventType>() <<
": "
252 <<
"{name = " << std::quoted(alloc.name) <<
", space = " << std::quoted(alloc.kpsh.name) <<
", ptr = " << alloc.ptr <<
", size = " << alloc.size <<
"}";
256 const auto& dst =
event.dst;
257 const auto& src =
event.src;
258 return out << get_name<BeginDeepCopyEvent>() <<
": "
259 <<
"{src = " << std::quoted(src.name) <<
" (" << src.kpsh.name <<
", " << src.ptr <<
") -> "
260 <<
"dst = " << std::quoted(dst.name) <<
" (" << dst.kpsh.name <<
", " << dst.ptr <<
") of size " << src.size <<
"}";
264 return out << get_name<CreateProfileSectionEvent>() <<
": "
265 <<
"{name = " << std::quoted(event.
name) <<
", section_id = " <<
event.section_id <<
"}";
268template <ProfileSectionManipulationEvent EventType>
269std::ostream&
operator<<(std::ostream &out,
const EventType& event) {
270 return out << get_name<EventType>() <<
": "
271 <<
"{section_id = " <<
event.section_id <<
"}";
275 return out << get_name<PushRegionEvent>() <<
": "
276 <<
"{name = " << std::quoted(event.
name) <<
"}";
280 return out << get_name<ProfileEvent>() <<
": "
281 <<
"{name = " << std::quoted(event.
name) <<
"}";
288template <Event EventType>
292#define GET_CALLBACK_FROM_EVENTSET(__eventtype__, __callback__) \
294 inline auto get_callback_from_eventset<__eventtype__>(const Kokkos::Tools::Experimental::EventSet& event_set) { return event_set.__callback__; }
317template <
Event EventType>
321#define GET_CALLBACK_SETTER(__eventtype__, __callback_setter__) \
323 inline auto get_callback_setter<__eventtype__>() { return &Kokkos::Tools::Experimental::__callback_setter__; }
#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 is one of the given event types.
Concept to constrain any event type that has a name field.
Concept to constrain any profile section manipulation event type.
std::ostream & operator<<(std::ostream &out, const EventType &)
constexpr auto get_name()
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
Allocate-data event associated with Kokkos::Tools::Experimental::EventSet::allocate_data.
Begin-deep-copy event associated with Kokkos::Tools::Experimental::EventSet::begin_deep_copy.
Begin-fence event associated with Kokkos::Tools::Experimental::EventSet::begin_fence.
Begin-parallel-reduce event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_red...
Begin-parallel-scan event associated with Kokkos::Tools::Experimental::EventSet::begin_parallel_scan.
Create-profile-section event associated with Kokkos::Tools::Experimental::EventSet::create_profile_se...
Deallocate-data event associated with Kokkos::Tools::Experimental::EventSet::deallocate_data.
Destroy-profile-section event associated with Kokkos::Tools::Experimental::EventSet::destroy_profile_...
End-deep-copy event associated with Kokkos::Tools::Experimental::EventSet::end_deep_copy.
End-fence event associated with Kokkos::Tools::Experimental::EventSet::end_fence.
End-parallel-for event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_for.
End-parallel-reduce event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_reduce.
End-parallel-scan event associated with Kokkos::Tools::Experimental::EventSet::end_parallel_scan.
Pop-region event associated with Kokkos::Tools::Experimental::EventSet::pop_region.
Profile event associated with Kokkos::Tools::Experimental::EventSet::profile_event.
Push-region event associated with Kokkos::Tools::Experimental::EventSet::push_region.
Start-profile-section event associated with Kokkos::Tools::Experimental::EventSet::start_profile_sect...
Stop-profile-section event associated with Kokkos::Tools::Experimental::EventSet::stop_profile_sectio...