diff options
author | Finn Williams <Finn.Williams@arm.com> | 2019-12-19 17:05:18 +0000 |
---|---|---|
committer | Finn Williams <Finn.Williams@arm.com> | 2020-01-14 12:39:05 +0000 |
commit | 09ad6f909f25aef02b7f53bba320b534b9260786 (patch) | |
tree | e69f6d9d4b15b0c7e106c5f6749dd77586247a75 /src/profiling/test/SendCounterPacketTests.hpp | |
parent | f90c56d72de4848a2dc5844a97458aaf09df07c2 (diff) | |
download | armnn-09ad6f909f25aef02b7f53bba320b534b9260786.tar.gz |
IVGCVSW-4229 Fix Intermittent failures in ExternalProfiling
* Added a BufferManager.Reset() method to prevent packets being retained after a test
* Fixed a bug causing the send thread to wait needlessly before moving to active state
* Refactored SendCoundPacketTests and ProfilingTests test helper classes
* Fixed issue where WaitForPacketSent could miss a notification and timeout
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: I353a652260c2f7dd465baa9e979e22f50f3ca6a7
Diffstat (limited to 'src/profiling/test/SendCounterPacketTests.hpp')
-rw-r--r-- | src/profiling/test/SendCounterPacketTests.hpp | 67 |
1 files changed, 55 insertions, 12 deletions
diff --git a/src/profiling/test/SendCounterPacketTests.hpp b/src/profiling/test/SendCounterPacketTests.hpp index 6b244be0b4..4d517e5829 100644 --- a/src/profiling/test/SendCounterPacketTests.hpp +++ b/src/profiling/test/SendCounterPacketTests.hpp @@ -32,6 +32,19 @@ public: , m_Packet() {} + enum class PacketType + { + StreamMetaData, + ConnectionAcknowledge, + CounterDirectory, + ReqCounterDirectory, + PeriodicCounterSelection, + PerJobCounterSelection, + TimelineMessageDirectory, + PeriodicCounterCapture, + Unknown + }; + bool IsOpen() const override { std::lock_guard<std::mutex> lock(m_Mutex); @@ -53,11 +66,49 @@ public: return false; } + uint32_t header = ReadUint32(buffer, 0); + + uint32_t packetFamily = (header >> 26); + uint32_t packetId = ((header >> 16) & 1023); + + PacketType packetType; + + switch (packetFamily) + { + case 0: + packetType = packetId < 6 ? PacketType(packetId) : PacketType::Unknown; + break; + case 1: + packetType = packetId == 0 ? PacketType::TimelineMessageDirectory : PacketType::Unknown; + break; + case 3: + packetType = packetId == 0 ? PacketType::PeriodicCounterCapture : PacketType::Unknown; + break; + default: + packetType = PacketType::Unknown; + } + std::lock_guard<std::mutex> lock(m_Mutex); - m_WrittenData.push_back(length); + m_WrittenData.push_back({ packetType, length }); return true; } + + long CheckForPacket(const std::pair<PacketType, uint32_t> packetInfo) + { + std::lock_guard<std::mutex> lock(m_Mutex); + + if(packetInfo.second != 0) + { + return std::count(m_WrittenData.begin(), m_WrittenData.end(), packetInfo); + } + else + { + return std::count_if(m_WrittenData.begin(), m_WrittenData.end(), + [&packetInfo](const std::pair<PacketType, uint32_t> pair) { return packetInfo.first == pair.first; }); + } + } + bool WritePacket(Packet&& packet) { std::lock_guard<std::mutex> lock(m_Mutex); @@ -76,19 +127,11 @@ public: return std::move(m_Packet); } - std::vector<uint32_t> GetWrittenData() + unsigned long GetWrittenDataSize() { std::lock_guard<std::mutex> lock(m_Mutex); - std::vector<uint32_t> writtenData = m_WrittenData; - m_WrittenData.clear(); - return writtenData; - } - - bool HasWrittenData() const - { - std::lock_guard<std::mutex> lock(m_Mutex); - return !m_WrittenData.empty(); + return m_WrittenData.size(); } void Clear() @@ -100,7 +143,7 @@ public: private: bool m_IsOpen; - std::vector<uint32_t> m_WrittenData; + std::vector<std::pair<PacketType, uint32_t>> m_WrittenData; Packet m_Packet; mutable std::mutex m_Mutex; }; |