Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 1 | // |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 8 | #include "ProfilingService.hpp" |
Colm Donelan | 5ccb33d | 2020-01-24 16:27:02 +0000 | [diff] [blame] | 9 | #include "armnn/profiling/ISendTimelinePacket.hpp" |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 10 | |
janeil01 | c4946c7 | 2019-11-07 09:32:28 +0000 | [diff] [blame] | 11 | #include <armnn/Types.hpp> |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | namespace profiling |
| 17 | { |
| 18 | |
| 19 | class TimelineUtilityMethods |
| 20 | { |
| 21 | public: |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 22 | |
| 23 | // static factory method which will return a pointer to a timelie utility methods |
| 24 | // object if profiling is enabled. Otherwise will return a null unique_ptr |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 25 | static std::unique_ptr<TimelineUtilityMethods> GetTimelineUtils(ProfilingService& profilingService); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 26 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 27 | TimelineUtilityMethods( |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 28 | std::unique_ptr<ISendTimelinePacket>& sendTimelinePacket) |
| 29 | : m_SendTimelinePacket(std::move(sendTimelinePacket)) {} |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 30 | |
| 31 | TimelineUtilityMethods(TimelineUtilityMethods&& other) |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 32 | : m_SendTimelinePacket(std::move(other.m_SendTimelinePacket)) {} |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 33 | |
| 34 | TimelineUtilityMethods(const TimelineUtilityMethods& other) = delete; |
| 35 | |
| 36 | TimelineUtilityMethods& operator=(const TimelineUtilityMethods& other) = delete; |
| 37 | |
| 38 | TimelineUtilityMethods& operator=(TimelineUtilityMethods&& other) = default; |
| 39 | |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 40 | ~TimelineUtilityMethods() = default; |
| 41 | |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 42 | static void SendWellKnownLabelsAndEventClasses(ISendTimelinePacket& timelinePacket); |
Matteo Martincigh | 102cdbd | 2019-10-28 11:42:50 +0000 | [diff] [blame] | 43 | |
Narumol Prangnawarat | d034e08 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 44 | ProfilingDynamicGuid CreateNamedTypedEntity(const std::string& name, const std::string& type); |
| 45 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 46 | void CreateNamedTypedEntity(ProfilingGuid entityGuid, const std::string& name, const std::string& type); |
Narumol Prangnawarat | 234d525 | 2019-11-19 15:49:18 +0000 | [diff] [blame] | 47 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 48 | void CreateNamedTypedEntity(ProfilingGuid entityGuid, const std::string& name, ProfilingStaticGuid typeGuid); |
| 49 | |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 50 | void MarkEntityWithLabel(ProfilingGuid entityGuid, const std::string& labelName, ProfilingStaticGuid labelLinkGuid); |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 51 | |
Narumol Prangnawarat | d034e08 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 52 | ProfilingStaticGuid DeclareLabel(const std::string& labelName); |
| 53 | |
| 54 | void NameEntity(ProfilingGuid entityGuid, const std::string& name); |
| 55 | |
| 56 | void TypeEntity(ProfilingGuid entityGuid, const std::string& type); |
| 57 | |
Narumol Prangnawarat | 94a3088 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 58 | ProfilingDynamicGuid CreateNamedTypedChildEntity(ProfilingGuid parentEntityGuid, |
| 59 | const std::string& entityName, |
| 60 | const std::string& entityType); |
| 61 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 62 | void CreateNamedTypedChildEntity(ProfilingGuid entityGuid, |
Narumol Prangnawarat | 234d525 | 2019-11-19 15:49:18 +0000 | [diff] [blame] | 63 | ProfilingGuid parentEntityGuid, |
| 64 | const std::string& entityName, |
| 65 | const std::string& entityType); |
| 66 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 67 | void CreateNamedTypedChildEntity(ProfilingGuid entityGuid, |
| 68 | ProfilingGuid parentEntityGuid, |
| 69 | const std::string& entityName, |
| 70 | ProfilingStaticGuid typeGuid); |
| 71 | |
| 72 | ProfilingDynamicGuid CreateRelationship(ProfilingRelationshipType relationshipType, |
| 73 | ProfilingGuid headGuid, |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 74 | ProfilingGuid tailGuid, |
| 75 | ProfilingGuid relationshipCategory); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 76 | |
| 77 | ProfilingDynamicGuid CreateConnectionRelationship(ProfilingRelationshipType relationshipType, |
| 78 | ProfilingGuid headGuid, |
| 79 | ProfilingGuid tailGuid); |
| 80 | |
| 81 | void CreateTypedEntity(ProfilingGuid entityGuid, ProfilingStaticGuid typeGuid); |
| 82 | |
| 83 | void MarkEntityWithType(ProfilingGuid entityGuid, ProfilingStaticGuid typeNameGuid); |
| 84 | |
Matteo Martincigh | 5dc816e | 2019-11-04 14:05:28 +0000 | [diff] [blame] | 85 | ProfilingDynamicGuid RecordEvent(ProfilingGuid entityGuid, ProfilingStaticGuid eventClassGuid); |
| 86 | |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 87 | ProfilingDynamicGuid RecordWorkloadInferenceAndStartOfLifeEvent(ProfilingGuid workloadGuid, |
| 88 | ProfilingGuid inferenceGuid); |
| 89 | |
| 90 | void RecordEndOfLifeEvent(ProfilingGuid entityGuid); |
| 91 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 92 | void Commit() { m_SendTimelinePacket->Commit(); } |
| 93 | |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 94 | private: |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 95 | std::unique_ptr<ISendTimelinePacket> m_SendTimelinePacket; |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | } // namespace profiling |
| 99 | |
| 100 | } // namespace armnn |