diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-11-04 14:05:28 +0000 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-11-05 15:34:21 +0000 |
commit | 378bbfc0d7e97f7e63dc7e39117751a5ac3f21fe (patch) | |
tree | 84567dc58b1c7776adce48008db0f27a3420c0c5 /src/profiling/test | |
parent | 2ffcc4179648bbd6fb08342969391a2bcd027221 (diff) | |
download | armnn-378bbfc0d7e97f7e63dc7e39117751a5ac3f21fe.tar.gz |
IVGCVSW-4065 Use platform-specific thread id size in Timeline packets
* Using std::thread::id as a general data type for thread id
* Added new profiling util functions for reading/writing a thread id
to/from a buffer
* Fixed code and unit tests accordingly
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Change-Id: I1aaa3bdb740c8a97010f655b1e9f7581b52e7aff
Diffstat (limited to 'src/profiling/test')
-rw-r--r-- | src/profiling/test/SendTimelinePacketTests.cpp | 10 | ||||
-rw-r--r-- | src/profiling/test/TimelinePacketTests.cpp | 18 |
2 files changed, 16 insertions, 12 deletions
diff --git a/src/profiling/test/SendTimelinePacketTests.cpp b/src/profiling/test/SendTimelinePacketTests.cpp index 53e52b5b5b..60cda9a657 100644 --- a/src/profiling/test/SendTimelinePacketTests.cpp +++ b/src/profiling/test/SendTimelinePacketTests.cpp @@ -207,6 +207,7 @@ BOOST_AUTO_TEST_CASE(SendTimelinePacketTests1) { unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); + unsigned int threadId_size = sizeof(std::thread::id); MockBufferManager bufferManager(512); TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); @@ -303,7 +304,7 @@ BOOST_AUTO_TEST_CASE(SendTimelinePacketTests1) // Send TimelineEventBinaryPacket const uint64_t timestamp = 456789u; - const uint32_t threadId = 654321u; + const std::thread::id threadId = std::this_thread::get_id(); const uint64_t eventProfilingGuid = 123456u; sendTimelinePacket->SendTimelineEventBinaryPacket(timestamp, threadId, eventProfilingGuid); @@ -333,7 +334,7 @@ BOOST_AUTO_TEST_CASE(SendTimelinePacketTests1) uint32_t eventBinaryPacketSequenceNumbered = (eventBinaryPacketHeaderWord1 >> 24) & 0x00000001; uint32_t eventBinaryPacketDataLength = (eventBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; BOOST_CHECK(eventBinaryPacketSequenceNumbered == 0); - BOOST_CHECK(eventBinaryPacketDataLength == 24); + BOOST_CHECK(eventBinaryPacketDataLength == 28); // Check the decl_id offset += uint32_t_size; @@ -347,11 +348,12 @@ BOOST_AUTO_TEST_CASE(SendTimelinePacketTests1) // Check the thread id offset += uint64_t_size; - uint32_t readThreadId = ReadUint32(packetBuffer, offset); + std::vector<uint8_t> readThreadId(threadId_size, 0); + ReadBytes(packetBuffer, offset, threadId_size, readThreadId.data()); BOOST_CHECK(readThreadId == threadId); // Check the profiling GUID - offset += uint32_t_size; + offset += threadId_size; readProfilingGuid = ReadUint64(packetBuffer, offset); BOOST_CHECK(readProfilingGuid == eventProfilingGuid); } diff --git a/src/profiling/test/TimelinePacketTests.cpp b/src/profiling/test/TimelinePacketTests.cpp index a9ba516e53..6a8aa85fc0 100644 --- a/src/profiling/test/TimelinePacketTests.cpp +++ b/src/profiling/test/TimelinePacketTests.cpp @@ -790,7 +790,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventClassTest4) BOOST_AUTO_TEST_CASE(TimelineEventPacketTest1) { const uint64_t timestamp = 456789u; - const uint32_t threadId = 654321u; + const std::thread::id threadId = std::this_thread::get_id(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp, @@ -808,7 +808,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest2) std::vector<unsigned char> buffer(512, 0); const uint64_t timestamp = 456789u; - const uint32_t threadId = 654321u; + const std::thread::id threadId = std::this_thread::get_id(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp, @@ -826,7 +826,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest3) std::vector<unsigned char> buffer(10, 0); const uint64_t timestamp = 456789u; - const uint32_t threadId = 654321u; + const std::thread::id threadId = std::this_thread::get_id(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp, @@ -844,7 +844,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest4) std::vector<unsigned char> buffer(512, 0); const uint64_t timestamp = 456789u; - const uint32_t threadId = 654321u; + const std::thread::id threadId = std::this_thread::get_id(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp, @@ -854,10 +854,11 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest4) boost::numeric_cast<unsigned int>(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); - BOOST_CHECK(numberOfBytesWritten == 32); + BOOST_CHECK(numberOfBytesWritten == 36); unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); + unsigned int threadId_size = sizeof(std::thread::id); // Check the packet header unsigned int offset = 0; @@ -876,7 +877,7 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest4) uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001; uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF; BOOST_CHECK(sequenceNumbered == 0); - BOOST_CHECK(dataLength == 24); + BOOST_CHECK(dataLength == 28); // Check the decl_id offset += uint32_t_size; @@ -890,11 +891,12 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest4) // Check the thread id offset += uint64_t_size; - uint32_t readThreadId = ReadUint32(buffer.data(), offset); + std::vector<uint8_t> readThreadId(threadId_size, 0); + ReadBytes(buffer.data(), offset, threadId_size, readThreadId.data()); BOOST_CHECK(readThreadId == threadId); // Check the profiling GUID - offset += uint32_t_size; + offset += threadId_size; uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset); BOOST_CHECK(readProfilingGuid == profilingGuid); } |