diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-11-06 15:30:54 +0000 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-11-15 15:12:45 +0000 |
commit | 34a407d4a95830ff9fad05e2bff34dcfc631c931 (patch) | |
tree | ff8673a7ea0ffa493885017400a3ea543fce96f9 /src/profiling/ProfilingUtils.hpp | |
parent | 30db8ad8b15e5d0e94ae2ff64c246350885c4b6b (diff) | |
download | armnn-34a407d4a95830ff9fad05e2bff34dcfc631c931.tar.gz |
IVGCVSW-4072 Add stream header to Timeline Message Directory packet
* Refactored the WriteTimelineMessageDirectoryPacket function
* Added the stream header to the packet
* Updated decoders/parsers
* Updated unit tests accordingly
* Minor refactoring
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Change-Id: I58f15fde54adc6414ca9fd5fb8d6157cad867339
Diffstat (limited to 'src/profiling/ProfilingUtils.hpp')
-rw-r--r-- | src/profiling/ProfilingUtils.hpp | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/src/profiling/ProfilingUtils.hpp b/src/profiling/ProfilingUtils.hpp index f7b46be972..4427140ece 100644 --- a/src/profiling/ProfilingUtils.hpp +++ b/src/profiling/ProfilingUtils.hpp @@ -25,13 +25,20 @@ namespace armnn namespace profiling { +struct SwTraceHeader +{ + uint8_t m_StreamVersion; + uint8_t m_PointerBytes; + uint8_t m_ThreadIdBytes; +}; + struct SwTraceMessage { - uint32_t id; - std::string name; - std::string uiName; - std::vector<char> argTypes; - std::vector<std::string> argNames; + uint32_t m_Id; + std::string m_Name; + std::string m_UiName; + std::vector<char> m_ArgTypes; + std::vector<std::string> m_ArgNames; }; struct SwTraceCharPolicy @@ -52,6 +59,29 @@ struct SwTraceNameCharPolicy } }; +struct SwTraceTypeCharPolicy +{ + static bool IsValidChar(unsigned char c) + { + // Check that the given character is among the allowed ones + switch (c) + { + case '@': + case 't': + case 'i': + case 'I': + case 'l': + case 'L': + case 'F': + case 'p': + case 's': + return true; // Valid char + default: + return false; // Invalid char + } + } +}; + template <typename SwTracePolicy> bool IsValidSwTraceString(const std::string& s) { @@ -87,6 +117,23 @@ bool StringToSwTraceString(const std::string& s, std::vector<uint32_t>& outputBu return true; } +template <typename SwTracePolicy, + typename SwTraceBuffer = std::vector<uint32_t>> +bool ConvertDirectoryComponent(const std::string& directoryComponent, SwTraceBuffer& swTraceBuffer) +{ + // Convert the directory component using the given policy + SwTraceBuffer tempSwTraceBuffer; + bool result = StringToSwTraceString<SwTracePolicy>(directoryComponent, tempSwTraceBuffer); + if (!result) + { + return false; + } + + swTraceBuffer.insert(swTraceBuffer.end(), tempSwTraceBuffer.begin(), tempSwTraceBuffer.end()); + + return true; +} + uint16_t GetNextUid(bool peekOnly = false); std::vector<uint16_t> GetNextCounterUids(uint16_t cores); @@ -103,6 +150,8 @@ void WriteUint32(const IPacketBufferPtr& packetBuffer, unsigned int offset, uint void WriteUint16(const IPacketBufferPtr& packetBuffer, unsigned int offset, uint16_t value); +void WriteUint8(const IPacketBufferPtr& packetBuffer, unsigned int offset, uint8_t value); + void WriteBytes(unsigned char* buffer, unsigned int offset, const void* value, unsigned int valueSize); void WriteUint64(unsigned char* buffer, unsigned int offset, uint64_t value); @@ -111,6 +160,8 @@ void WriteUint32(unsigned char* buffer, unsigned int offset, uint32_t value); void WriteUint16(unsigned char* buffer, unsigned int offset, uint16_t value); +void WriteUint8(unsigned char* buffer, unsigned int offset, uint8_t value); + void ReadBytes(const IPacketBufferPtr& packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[]); uint64_t ReadUint64(const IPacketBufferPtr& packetBuffer, unsigned int offset); |