8 #include <client/src/IProfilingConnection.hpp> 10 #include <common/include/LabelsAndEventClasses.hpp> 23 std::vector<uint32_t> headers;
24 headers.push_back(m_DirectoryHeader);
25 headers.push_back(m_MessageHeader);
31 if (packet.GetHeader() == m_DirectoryHeader)
33 ProcessDirectoryPacket(packet);
35 else if (packet.GetHeader() == m_MessageHeader)
37 ProcessMessagePacket(packet);
42 ss <<
"Received a packet with unknown header [" << packet.GetHeader() <<
"]";
43 throw arm::pipe::ProfilingException(ss.str());
49 m_Connection->Close();
54 std::unique_lock<std::mutex> lck(m_InferenceCompletedMutex);
56 auto start = std::chrono::high_resolution_clock::now();
59 if (!m_InferenceCompletedConditionVariable.wait_for(lck,
60 std::chrono::milliseconds(timeout),
61 [&]{return m_InferenceCompleted == true;}))
63 auto finish = std::chrono::high_resolution_clock::now();
64 std::chrono::duration<double, std::milli> elapsed = finish - start;
66 ss <<
"Timed out waiting on inference completion for " << elapsed.count() <<
" ms";
67 throw arm::pipe::TimeoutException(ss.str());
75 std::unique_lock<std::mutex> lck(m_InferenceCompletedMutex);
76 m_InferenceCompleted =
true;
78 m_InferenceCompletedConditionVariable.notify_one();
81 void TestTimelinePacketHandler::ProcessDirectoryPacket(
const arm::pipe::Packet& packet)
83 m_DirectoryDecoder(packet);
86 void TestTimelinePacketHandler::ProcessMessagePacket(
const arm::pipe::Packet& packet)
95 return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
99 const arm::pipe::ITimelineDecoder::EventClass& eventClass)
102 return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
106 const arm::pipe::ITimelineDecoder::Event& event)
109 return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
113 const arm::pipe::ITimelineDecoder::Label& label)
116 return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
120 const arm::pipe::ITimelineDecoder::Relationship& relationship)
125 if (relationship.m_RelationshipType == RelationshipType::ExecutionLink &&
128 ProfilingStaticGuid attributeGuid(relationship.m_AttributeGuid);
129 if (attributeGuid == LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS)
131 if (m_PacketHandler !=
nullptr)
133 m_PacketHandler->SetInferenceComplete();
137 return arm::pipe::ITimelineDecoder::TimelineStatus::TimelineStatus_Success;
void AddRelationship(const arm::pipe::ITimelineDecoder::Relationship &relationship)
void AddLabel(const arm::pipe::ITimelineDecoder::Label &label)
virtual TimelineStatus CreateRelationship(const Relationship &) override
void SetInferenceComplete()
void AddEventClass(const arm::pipe::ITimelineDecoder::EventClass &eventClass)
virtual void HandlePacket(const arm::pipe::Packet &packet) override
virtual TimelineStatus CreateEventClass(const EventClass &) override
virtual TimelineStatus CreateEntity(const Entity &) override
void AddEvent(const arm::pipe::ITimelineDecoder::Event &event)
bool IsInferenceGuid(uint64_t guid) const
void AddEntity(uint64_t guid)
virtual TimelineStatus CreateLabel(const Label &) override
virtual TimelineStatus CreateEvent(const Event &) override
virtual std::vector< uint32_t > GetHeadersAccepted() override
void WaitOnInferenceCompletion(unsigned int timeout)