From cab588ac45bf1c39832d8a278ee46db851c1b015 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Mon, 17 Feb 2020 11:33:31 +0000 Subject: IVGCVSW-4320 Implement the bulk reporting of counter values from backends * Implemented unit test for ReportCounters function in BackendProfiling Signed-off-by: Jim Flynn Signed-off-by: Sadik Armagan Change-Id: Iec342a96060c8ef6090e6cc67bda8a7a3e890c50 --- src/profiling/test/ProfilingTests.cpp | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'src/profiling/test/ProfilingTests.cpp') diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index af9f1b8fcb..c025aa2e3e 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -3413,4 +3413,63 @@ BOOST_AUTO_TEST_CASE(CheckCounterStatusQuery) profilingService.ResetExternalProfilingOptions(options.m_ProfilingOptions, true); } +BOOST_AUTO_TEST_CASE(CheckRegisterCounters) +{ + armnn::Runtime::CreationOptions options; + options.m_ProfilingOptions.m_EnableProfiling = true; + MockBufferManager mockBuffer(1024); + CaptureData captureData; + MockProfilingService mockProfilingService( + mockBuffer, options.m_ProfilingOptions.m_EnableProfiling, captureData); + armnn::BackendId cpuRefId(armnn::Compute::CpuRef); + + mockProfilingService.RegisterMapping(6, 0, cpuRefId); + mockProfilingService.RegisterMapping(7, 1, cpuRefId); + mockProfilingService.RegisterMapping(8, 2, cpuRefId); + + armnn::profiling::BackendProfiling backendProfiling(options, + mockProfilingService, + cpuRefId); + + armnn::profiling::Timestamp timestamp; + timestamp.timestamp = 1000998; + timestamp.counterValues.emplace_back(0, 700); + timestamp.counterValues.emplace_back(2, 93); + std::vector timestamps; + timestamps.push_back(timestamp); + backendProfiling.ReportCounters(timestamps); + + auto readBuffer = mockBuffer.GetReadableBuffer(); + + uint32_t headerWord0 = ReadUint32(readBuffer, 0); + uint32_t headerWord1 = ReadUint32(readBuffer, 4); + uint64_t readTimestamp = ReadUint64(readBuffer, 8); + + BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 3); // packet family + BOOST_TEST(((headerWord0 >> 19) & 0x0000007F) == 0); // packet class + BOOST_TEST(((headerWord0 >> 16) & 0x00000007) == 0); // packet type + BOOST_TEST(headerWord1 == 20); // data length + BOOST_TEST(1000998 == readTimestamp); // capture period + + uint32_t offset = 16; + // Check Counter Index + uint16_t readIndex = ReadUint16(readBuffer, offset); + BOOST_TEST(6 == readIndex); + + // Check Counter Value + offset += 2; + uint32_t readValue = ReadUint32(readBuffer, offset); + BOOST_TEST(700 == readValue); + + // Check Counter Index + offset += 4; + readIndex = ReadUint16(readBuffer, offset); + BOOST_TEST(8 == readIndex); + + // Check Counter Value + offset += 2; + readValue = ReadUint32(readBuffer, offset); + BOOST_TEST(93 == readValue); +} + BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.1