/* * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once #include "shared/source/utilities/iflist.h" #include "opencl/source/event/event.h" #include #include namespace NEO { class CommandQueue; struct TrackedEvent : IFNode { TrackedEvent(Event *ev, int64_t eventId) : ev(ev), eventId(eventId) { } Event *ev = nullptr; int64_t eventId = 1; }; class EventsTracker { using EventIdMap = std::unordered_map; using CmdqSet = std::set; protected: std::atomic eventId{0}; static std::unique_ptr globalEvTracker; IFList trackedEvents; EventsTracker() = default; public: void dump(); void notifyCreation(Event *eventToTrack); void notifyDestruction(Event *eventToDestroy); void notifyTransitionedExecutionStatus(); MOCKABLE_VIRTUAL ~EventsTracker() = default; MOCKABLE_VIRTUAL TrackedEvent *getNodes(); MOCKABLE_VIRTUAL std::unique_ptr createDumpStream(const std::string &filename); static EventsTracker &getEventsTracker(); static std::string label(Event *node, const EventIdMap &eventsIdMapping); static std::string label(CommandQueue *cmdQ); static void dumpQueue(CommandQueue *cmdQ, std::ostream &out, CmdqSet &dumpedCmdQs); static void dumpEdge(Event *leftNode, Event *rightNode, std::ostream &out, const EventIdMap &eventsIdMapping); static void dumpNode(Event *node, std::ostream &out, const EventIdMap &eventsIdMapping); static void dumpGraph(Event *node, std::ostream &out, CmdqSet &dumpedCmdQs, std::set &dumpedEvents, const EventIdMap &eventsIdMapping); }; } // namespace NEO