Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "TimelineUtilityMethods.hpp" |
Matteo Martincigh | 102cdbd | 2019-10-28 11:42:50 +0000 | [diff] [blame] | 7 | #include "LabelsAndEventClasses.hpp" |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 8 | |
| 9 | namespace armnn |
| 10 | { |
| 11 | |
| 12 | namespace profiling |
| 13 | { |
| 14 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 15 | std::unique_ptr<TimelineUtilityMethods> TimelineUtilityMethods::GetTimelineUtils(ProfilingService& profilingService) |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 16 | { |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 17 | if (profilingService.IsProfilingEnabled()) |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 18 | { |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 19 | std::unique_ptr<ISendTimelinePacket> sendTimelinepacket = profilingService.GetSendTimelinePacket(); |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 20 | return std::make_unique<TimelineUtilityMethods>(sendTimelinepacket); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 21 | } |
| 22 | else |
| 23 | { |
| 24 | std::unique_ptr<TimelineUtilityMethods> empty; |
| 25 | return empty; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 30 | void TimelineUtilityMethods::SendWellKnownLabelsAndEventClasses(ISendTimelinePacket& timelinePacket) |
Matteo Martincigh | 102cdbd | 2019-10-28 11:42:50 +0000 | [diff] [blame] | 31 | { |
| 32 | // Send the "name" label, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 33 | timelinePacket.SendTimelineLabelBinaryPacket(LabelsAndEventClasses::NAME_GUID, |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 34 | LabelsAndEventClasses::NAME_LABEL); |
Matteo Martincigh | 102cdbd | 2019-10-28 11:42:50 +0000 | [diff] [blame] | 35 | |
| 36 | // Send the "type" label, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 37 | timelinePacket.SendTimelineLabelBinaryPacket(LabelsAndEventClasses::TYPE_GUID, |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 38 | LabelsAndEventClasses::TYPE_LABEL); |
Matteo Martincigh | 102cdbd | 2019-10-28 11:42:50 +0000 | [diff] [blame] | 39 | |
| 40 | // Send the "index" label, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 41 | timelinePacket.SendTimelineLabelBinaryPacket(LabelsAndEventClasses::INDEX_GUID, |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 42 | LabelsAndEventClasses::INDEX_LABEL); |
| 43 | |
| 44 | // Send the "backendId" label, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 45 | timelinePacket.SendTimelineLabelBinaryPacket(LabelsAndEventClasses::BACKENDID_GUID, |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 46 | LabelsAndEventClasses::BACKENDID_LABEL); |
| 47 | |
| 48 | // Send the "layer" label, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 49 | timelinePacket.SendTimelineLabelBinaryPacket(LabelsAndEventClasses::LAYER_GUID, |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 50 | LabelsAndEventClasses::LAYER); |
| 51 | |
| 52 | // Send the "workload" label, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 53 | timelinePacket.SendTimelineLabelBinaryPacket(LabelsAndEventClasses::WORKLOAD_GUID, |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 54 | LabelsAndEventClasses::WORKLOAD); |
| 55 | |
| 56 | // Send the "network" label, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 57 | timelinePacket.SendTimelineLabelBinaryPacket(LabelsAndEventClasses::NETWORK_GUID, |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 58 | LabelsAndEventClasses::NETWORK); |
| 59 | |
| 60 | // Send the "connection" label, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 61 | timelinePacket.SendTimelineLabelBinaryPacket(LabelsAndEventClasses::CONNECTION_GUID, |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 62 | LabelsAndEventClasses::CONNECTION); |
Matteo Martincigh | 102cdbd | 2019-10-28 11:42:50 +0000 | [diff] [blame] | 63 | |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 64 | // Send the "inference" label, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 65 | timelinePacket.SendTimelineLabelBinaryPacket(LabelsAndEventClasses::INFERENCE_GUID, |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 66 | LabelsAndEventClasses::INFERENCE); |
| 67 | |
| 68 | // Send the "workload_execution" label, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 69 | timelinePacket.SendTimelineLabelBinaryPacket(LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 70 | LabelsAndEventClasses::WORKLOAD_EXECUTION); |
| 71 | |
Matteo Martincigh | 102cdbd | 2019-10-28 11:42:50 +0000 | [diff] [blame] | 72 | // Send the "start of life" event class, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 73 | timelinePacket.SendTimelineEventClassBinaryPacket(LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS); |
Matteo Martincigh | 102cdbd | 2019-10-28 11:42:50 +0000 | [diff] [blame] | 74 | |
| 75 | // Send the "end of life" event class, this call throws in case of error |
Finn Williams | cf2ad55 | 2020-03-20 15:10:59 +0000 | [diff] [blame] | 76 | timelinePacket.SendTimelineEventClassBinaryPacket(LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS); |
| 77 | |
| 78 | timelinePacket.Commit(); |
Matteo Martincigh | 102cdbd | 2019-10-28 11:42:50 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Narumol Prangnawarat | d034e08 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 81 | ProfilingDynamicGuid TimelineUtilityMethods::CreateNamedTypedEntity(const std::string& name, const std::string& type) |
| 82 | { |
| 83 | // Check that the entity name is valid |
| 84 | if (name.empty()) |
| 85 | { |
| 86 | throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); |
| 87 | } |
| 88 | |
| 89 | // Check that the entity type is valid |
| 90 | if (type.empty()) |
| 91 | { |
| 92 | throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); |
| 93 | } |
| 94 | |
| 95 | // Generate dynamic GUID of the entity |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 96 | ProfilingDynamicGuid entityGuid = profiling::ProfilingService::GetNextGuid(); |
Narumol Prangnawarat | d034e08 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 97 | |
Narumol Prangnawarat | 234d525 | 2019-11-19 15:49:18 +0000 | [diff] [blame] | 98 | CreateNamedTypedEntity(entityGuid, name, type); |
| 99 | |
| 100 | return entityGuid; |
| 101 | } |
| 102 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 103 | void TimelineUtilityMethods::CreateNamedTypedEntity(ProfilingGuid entityGuid, |
Narumol Prangnawarat | 234d525 | 2019-11-19 15:49:18 +0000 | [diff] [blame] | 104 | const std::string& name, |
| 105 | const std::string& type) |
| 106 | { |
| 107 | // Check that the entity name is valid |
| 108 | if (name.empty()) |
| 109 | { |
| 110 | throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); |
| 111 | } |
| 112 | |
| 113 | // Check that the entity type is valid |
| 114 | if (type.empty()) |
| 115 | { |
| 116 | throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); |
| 117 | } |
| 118 | |
Narumol Prangnawarat | d034e08 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 119 | // Send Entity Binary Packet of the entity to the external profiling service |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 120 | m_SendTimelinePacket->SendTimelineEntityBinaryPacket(entityGuid); |
Narumol Prangnawarat | d034e08 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 121 | |
| 122 | // Create name entity and send the relationship of the entity with the given name |
| 123 | NameEntity(entityGuid, name); |
| 124 | |
| 125 | // Create type entity and send the relationship of the entity with the given type |
| 126 | TypeEntity(entityGuid, type); |
Narumol Prangnawarat | d034e08 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 129 | void TimelineUtilityMethods::CreateNamedTypedEntity(ProfilingGuid entityGuid, |
| 130 | const std::string& name, |
| 131 | ProfilingStaticGuid typeGuid) |
| 132 | { |
| 133 | // Check that the entity name is valid |
| 134 | if (name.empty()) |
| 135 | { |
| 136 | throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); |
| 137 | } |
| 138 | |
| 139 | // Send Entity Binary Packet of the entity to the external profiling service |
| 140 | m_SendTimelinePacket->SendTimelineEntityBinaryPacket(entityGuid); |
| 141 | |
| 142 | // Create name entity and send the relationship of the entity with the given name |
| 143 | NameEntity(entityGuid, name); |
| 144 | |
| 145 | // Create type entity and send the relationship of the entity with the given type |
| 146 | MarkEntityWithType(entityGuid, typeGuid); |
| 147 | } |
| 148 | |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 149 | ProfilingStaticGuid TimelineUtilityMethods::DeclareLabel(const std::string& labelName) |
| 150 | { |
| 151 | // Check that the label name is valid |
| 152 | if (labelName.empty()) |
| 153 | { |
| 154 | // The label name is invalid |
| 155 | throw InvalidArgumentException("Invalid label name, the label name cannot be empty"); |
| 156 | } |
| 157 | |
| 158 | // Generate a static GUID for the given label name |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 159 | ProfilingStaticGuid labelGuid = profiling::ProfilingService::GetStaticId(labelName); |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 160 | |
| 161 | // Send the new label to the external profiling service, this call throws in case of error |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 162 | m_SendTimelinePacket->SendTimelineLabelBinaryPacket(labelGuid, labelName); |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 163 | |
| 164 | return labelGuid; |
| 165 | } |
| 166 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 167 | void TimelineUtilityMethods::MarkEntityWithLabel(ProfilingGuid entityGuid, |
| 168 | const std::string& labelName, |
| 169 | ProfilingStaticGuid labelTypeGuid) |
Matteo Martincigh | c040199 | 2019-10-28 15:24:34 +0000 | [diff] [blame] | 170 | { |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 171 | // Check that the label name is valid |
| 172 | if (labelName.empty()) |
Matteo Martincigh | c040199 | 2019-10-28 15:24:34 +0000 | [diff] [blame] | 173 | { |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 174 | // The label name is invalid |
Matteo Martincigh | c040199 | 2019-10-28 15:24:34 +0000 | [diff] [blame] | 175 | throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); |
| 176 | } |
| 177 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 178 | // Declare a label with the label's name, this call throws in case of error |
| 179 | ProfilingStaticGuid labelGuid = DeclareLabel(labelName); |
Matteo Martincigh | c040199 | 2019-10-28 15:24:34 +0000 | [diff] [blame] | 180 | |
| 181 | // Generate a GUID for the label relationship |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 182 | ProfilingDynamicGuid relationshipGuid = profiling::ProfilingService::GetNextGuid(); |
Matteo Martincigh | c040199 | 2019-10-28 15:24:34 +0000 | [diff] [blame] | 183 | |
| 184 | // Send the new label link to the external profiling service, this call throws in case of error |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 185 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 186 | relationshipGuid, |
| 187 | entityGuid, |
| 188 | labelGuid); |
Matteo Martincigh | c040199 | 2019-10-28 15:24:34 +0000 | [diff] [blame] | 189 | |
| 190 | // Generate a GUID for the label relationship |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 191 | ProfilingDynamicGuid relationshipLabelGuid = profiling::ProfilingService::GetNextGuid(); |
Matteo Martincigh | c040199 | 2019-10-28 15:24:34 +0000 | [diff] [blame] | 192 | |
| 193 | // Send the new label link to the external profiling service, this call throws in case of error |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 194 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 195 | relationshipLabelGuid, |
| 196 | relationshipGuid, |
| 197 | labelTypeGuid); |
| 198 | } |
| 199 | |
| 200 | void TimelineUtilityMethods::MarkEntityWithType(ProfilingGuid entityGuid, |
| 201 | ProfilingStaticGuid typeNameGuid) |
| 202 | { |
| 203 | // Generate a GUID for the label relationship |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 204 | ProfilingDynamicGuid relationshipGuid = profiling::ProfilingService::GetNextGuid(); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 205 | |
| 206 | // Send the new label link to the external profiling service, this call throws in case of error |
| 207 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 208 | relationshipGuid, |
| 209 | entityGuid, |
| 210 | typeNameGuid); |
| 211 | |
| 212 | // Generate a GUID for the label relationship |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 213 | ProfilingDynamicGuid relationshipLabelGuid = profiling::ProfilingService::GetNextGuid(); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 214 | |
| 215 | // Send the new label link to the external profiling service, this call throws in case of error |
| 216 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 217 | relationshipLabelGuid, |
| 218 | relationshipGuid, |
| 219 | LabelsAndEventClasses::TYPE_GUID); |
Matteo Martincigh | c040199 | 2019-10-28 15:24:34 +0000 | [diff] [blame] | 220 | } |
| 221 | |
Narumol Prangnawarat | d034e08 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 222 | void TimelineUtilityMethods::NameEntity(ProfilingGuid entityGuid, const std::string& name) |
| 223 | { |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 224 | MarkEntityWithLabel(entityGuid, name, LabelsAndEventClasses::NAME_GUID); |
Narumol Prangnawarat | d034e08 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | void TimelineUtilityMethods::TypeEntity(ProfilingGuid entityGuid, const std::string& type) |
| 228 | { |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 229 | MarkEntityWithLabel(entityGuid, type, LabelsAndEventClasses::TYPE_GUID); |
Narumol Prangnawarat | d034e08 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 230 | } |
| 231 | |
Narumol Prangnawarat | 94a3088 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 232 | ProfilingDynamicGuid TimelineUtilityMethods::CreateNamedTypedChildEntity(ProfilingGuid parentEntityGuid, |
| 233 | const std::string& entityName, |
| 234 | const std::string& entityType) |
| 235 | { |
| 236 | // Check that the entity name is valid |
| 237 | if (entityName.empty()) |
| 238 | { |
| 239 | // The entity name is invalid |
| 240 | throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); |
| 241 | } |
| 242 | |
| 243 | // Check that the entity type is valid |
| 244 | if (entityType.empty()) |
| 245 | { |
| 246 | // The entity type is invalid |
| 247 | throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); |
| 248 | } |
| 249 | |
| 250 | // Create a named type entity from the given name and type, this call throws in case of error |
| 251 | ProfilingDynamicGuid childEntityGuid = CreateNamedTypedEntity(entityName, entityType); |
| 252 | |
| 253 | // Generate a GUID for the retention link relationship |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 254 | ProfilingDynamicGuid retentionLinkGuid = profiling::ProfilingService::GetNextGuid(); |
Narumol Prangnawarat | 94a3088 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 255 | |
| 256 | // Send the new retention link to the external profiling service, this call throws in case of error |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 257 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 258 | retentionLinkGuid, |
| 259 | parentEntityGuid, |
| 260 | childEntityGuid); |
Narumol Prangnawarat | 94a3088 | 2019-10-30 12:48:31 +0000 | [diff] [blame] | 261 | |
| 262 | return childEntityGuid; |
| 263 | } |
| 264 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 265 | void TimelineUtilityMethods::CreateNamedTypedChildEntity(ProfilingGuid childEntityGuid, |
Narumol Prangnawarat | 234d525 | 2019-11-19 15:49:18 +0000 | [diff] [blame] | 266 | ProfilingGuid parentEntityGuid, |
| 267 | const std::string& entityName, |
| 268 | const std::string& entityType) |
| 269 | { |
| 270 | // Check that the entity name is valid |
| 271 | if (entityName.empty()) |
| 272 | { |
| 273 | // The entity name is invalid |
| 274 | throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); |
| 275 | } |
| 276 | |
| 277 | // Check that the entity type is valid |
| 278 | if (entityType.empty()) |
| 279 | { |
| 280 | // The entity type is invalid |
| 281 | throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); |
| 282 | } |
| 283 | |
| 284 | // Create a named type entity from the given guid, name and type, this call throws in case of error |
| 285 | CreateNamedTypedEntity(childEntityGuid, entityName, entityType); |
| 286 | |
| 287 | // Generate a GUID for the retention link relationship |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 288 | ProfilingDynamicGuid retentionLinkGuid = profiling::ProfilingService::GetNextGuid(); |
Narumol Prangnawarat | 234d525 | 2019-11-19 15:49:18 +0000 | [diff] [blame] | 289 | |
| 290 | // Send the new retention link to the external profiling service, this call throws in case of error |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 291 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 292 | retentionLinkGuid, |
| 293 | parentEntityGuid, |
| 294 | childEntityGuid); |
| 295 | } |
| 296 | |
| 297 | void TimelineUtilityMethods::CreateNamedTypedChildEntity(ProfilingGuid childEntityGuid, |
| 298 | ProfilingGuid parentEntityGuid, |
| 299 | const std::string& entityName, |
| 300 | ProfilingStaticGuid typeGuid) |
| 301 | { |
| 302 | // Check that the entity name is valid |
| 303 | if (entityName.empty()) |
| 304 | { |
| 305 | // The entity name is invalid |
| 306 | throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); |
| 307 | } |
| 308 | |
| 309 | // Create a named type entity from the given guid, name and type, this call throws in case of error |
| 310 | CreateNamedTypedEntity(childEntityGuid, entityName, typeGuid); |
| 311 | |
| 312 | // Generate a GUID for the retention link relationship |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 313 | ProfilingDynamicGuid retentionLinkGuid = profiling::ProfilingService::GetNextGuid(); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 314 | |
| 315 | // Send the new retention link to the external profiling service, this call throws in case of error |
| 316 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 317 | retentionLinkGuid, |
| 318 | parentEntityGuid, |
| 319 | childEntityGuid); |
| 320 | } |
| 321 | |
| 322 | ProfilingDynamicGuid TimelineUtilityMethods::CreateRelationship(ProfilingRelationshipType relationshipType, |
| 323 | ProfilingGuid headGuid, |
| 324 | ProfilingGuid tailGuid) |
| 325 | { |
| 326 | // Generate a GUID for the relationship |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 327 | ProfilingDynamicGuid relationshipGuid = profiling::ProfilingService::GetNextGuid(); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 328 | |
| 329 | // Send the new retention link to the external profiling service, this call throws in case of error |
| 330 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(relationshipType, |
| 331 | relationshipGuid, |
| 332 | headGuid, |
| 333 | tailGuid); |
| 334 | return relationshipGuid; |
| 335 | } |
| 336 | |
| 337 | ProfilingDynamicGuid TimelineUtilityMethods::CreateConnectionRelationship(ProfilingRelationshipType relationshipType, |
| 338 | ProfilingGuid headGuid, |
| 339 | ProfilingGuid tailGuid) |
| 340 | { |
| 341 | // Generate a GUID for the relationship |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 342 | ProfilingDynamicGuid relationshipGuid = profiling::ProfilingService::GetNextGuid(); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 343 | |
| 344 | // Send the new retention link to the external profiling service, this call throws in case of error |
| 345 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(relationshipType, |
| 346 | relationshipGuid, |
| 347 | headGuid, |
| 348 | tailGuid); |
| 349 | |
| 350 | MarkEntityWithType(relationshipGuid, LabelsAndEventClasses::CONNECTION_GUID); |
| 351 | return relationshipGuid; |
| 352 | } |
| 353 | |
| 354 | void TimelineUtilityMethods::CreateTypedEntity(ProfilingGuid entityGuid, ProfilingStaticGuid entityTypeGuid) |
| 355 | { |
| 356 | // Send Entity Binary Packet of the entity to the external profiling service |
| 357 | m_SendTimelinePacket->SendTimelineEntityBinaryPacket(entityGuid); |
| 358 | |
| 359 | // Create type entity and send the relationship of the entity with the given type |
| 360 | MarkEntityWithType(entityGuid, entityTypeGuid); |
Narumol Prangnawarat | 234d525 | 2019-11-19 15:49:18 +0000 | [diff] [blame] | 361 | } |
| 362 | |
Matteo Martincigh | 5dc816e | 2019-11-04 14:05:28 +0000 | [diff] [blame] | 363 | ProfilingDynamicGuid TimelineUtilityMethods::RecordEvent(ProfilingGuid entityGuid, ProfilingStaticGuid eventClassGuid) |
| 364 | { |
| 365 | // Take a timestamp |
| 366 | uint64_t timestamp = GetTimestamp(); |
| 367 | |
| 368 | // Get the thread id |
| 369 | std::thread::id threadId = std::this_thread::get_id(); |
| 370 | |
| 371 | // Generate a GUID for the event |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 372 | ProfilingDynamicGuid eventGuid = profiling::ProfilingService::GetNextGuid(); |
Matteo Martincigh | 5dc816e | 2019-11-04 14:05:28 +0000 | [diff] [blame] | 373 | |
| 374 | // Send the new timeline event to the external profiling service, this call throws in case of error |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 375 | m_SendTimelinePacket->SendTimelineEventBinaryPacket(timestamp, threadId, eventGuid); |
Matteo Martincigh | 5dc816e | 2019-11-04 14:05:28 +0000 | [diff] [blame] | 376 | |
| 377 | // Generate a GUID for the execution link |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 378 | ProfilingDynamicGuid executionLinkId = profiling::ProfilingService::GetNextGuid(); |
Matteo Martincigh | 5dc816e | 2019-11-04 14:05:28 +0000 | [diff] [blame] | 379 | |
| 380 | // Send the new execution link to the external profiling service, this call throws in case of error |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 381 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, |
| 382 | executionLinkId, |
| 383 | entityGuid, |
| 384 | eventGuid); |
Matteo Martincigh | 5dc816e | 2019-11-04 14:05:28 +0000 | [diff] [blame] | 385 | |
| 386 | // Generate a GUID for the data relationship link |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 387 | ProfilingDynamicGuid eventClassLinkId = profiling::ProfilingService::GetNextGuid(); |
Matteo Martincigh | 5dc816e | 2019-11-04 14:05:28 +0000 | [diff] [blame] | 388 | |
| 389 | // Send the new data relationship link to the external profiling service, this call throws in case of error |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 390 | m_SendTimelinePacket->SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, |
| 391 | eventClassLinkId, |
| 392 | eventGuid, |
| 393 | eventClassGuid); |
Matteo Martincigh | 5dc816e | 2019-11-04 14:05:28 +0000 | [diff] [blame] | 394 | |
| 395 | return eventGuid; |
| 396 | } |
| 397 | |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 398 | ProfilingDynamicGuid TimelineUtilityMethods::RecordWorkloadInferenceAndStartOfLifeEvent(ProfilingGuid workloadGuid, |
| 399 | ProfilingGuid inferenceGuid) |
| 400 | { |
Sadik Armagan | 0a35667 | 2020-03-20 11:11:01 +0000 | [diff] [blame] | 401 | ProfilingDynamicGuid workloadInferenceGuid = profiling::ProfilingService::GetNextGuid(); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 402 | CreateTypedEntity(workloadInferenceGuid, LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID); |
| 403 | CreateRelationship(ProfilingRelationshipType::RetentionLink, inferenceGuid, workloadInferenceGuid); |
| 404 | CreateRelationship(ProfilingRelationshipType::RetentionLink, workloadGuid, workloadInferenceGuid); |
| 405 | RecordEvent(workloadInferenceGuid, LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS); |
| 406 | return workloadInferenceGuid; |
| 407 | } |
| 408 | |
| 409 | void TimelineUtilityMethods::RecordEndOfLifeEvent(ProfilingGuid entityGuid) |
| 410 | { |
| 411 | RecordEvent(entityGuid, LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS); |
| 412 | } |
| 413 | |
Matteo Martincigh | 830101c | 2019-10-22 11:07:45 +0100 | [diff] [blame] | 414 | } // namespace profiling |
| 415 | |
| 416 | } // namespace armnn |