diff options
author | Colm Donelan <Colm.Donelan@arm.com> | 2020-02-13 20:47:08 +0000 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2020-02-17 13:01:47 +0000 |
commit | fcb802bf62a092806041785cd6081cb99c518527 (patch) | |
tree | 58aa84ab59abeac9a31326691fbb490102f8e6fb /src/backends/backendsCommon/test/BackendProfilingTests.cpp | |
parent | cab588ac45bf1c39832d8a278ee46db851c1b015 (diff) | |
download | armnn-fcb802bf62a092806041785cd6081cb99c518527.tar.gz |
IVGCVSW-4340 Backend profiling: Add tests for Timeline functions
* Add tests for the timeline functions that are part of
IBackendProfiling: GetSendTimelinePacket & GetProfilingGuidGenerator
* Modify MockBackendProfilingService to store a
MockBackendProfilingContext shared pointer.
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
Change-Id: I99fc4b1da019858b9f29409cd59ef8f590c0d3a2
Diffstat (limited to 'src/backends/backendsCommon/test/BackendProfilingTests.cpp')
-rw-r--r-- | src/backends/backendsCommon/test/BackendProfilingTests.cpp | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/src/backends/backendsCommon/test/BackendProfilingTests.cpp b/src/backends/backendsCommon/test/BackendProfilingTests.cpp index 6e4a020fa5..455533699d 100644 --- a/src/backends/backendsCommon/test/BackendProfilingTests.cpp +++ b/src/backends/backendsCommon/test/BackendProfilingTests.cpp @@ -16,6 +16,7 @@ #include <armnn/BackendId.hpp> #include <armnn/Logging.hpp> +#include <armnn/profiling/ISendTimelinePacket.hpp> #include <boost/algorithm/string.hpp> #include <boost/numeric/conversion/cast.hpp> @@ -442,4 +443,69 @@ BOOST_AUTO_TEST_CASE(TestBackendCounterLogging) BOOST_CHECK(boost::contains(ss.str(), "ActivateCounters example test error")); } -BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file +BOOST_AUTO_TEST_CASE(BackendProfilingContextGetSendTimelinePacket) +{ + // Reset the profiling service to the uninitialized state + armnn::IRuntime::CreationOptions options; + options.m_ProfilingOptions.m_EnableProfiling = true; + armnn::profiling::ProfilingService& profilingService = armnn::profiling::ProfilingService::Instance(); + profilingService.ConfigureProfilingService(options.m_ProfilingOptions, true); + + armnn::MockBackendInitialiser initialiser; + // Create a runtime. During this the mock backend will be registered and context returned. + armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); + armnn::MockBackendProfilingService mockProfilingService = armnn::MockBackendProfilingService::Instance(); + armnn::MockBackendProfilingContext *mockBackEndProfilingContext = mockProfilingService.GetContext(); + // Check that there is a valid context set. + BOOST_CHECK(mockBackEndProfilingContext); + armnn::IBackendInternal::IBackendProfilingPtr& backendProfilingIface = + mockBackEndProfilingContext->GetBackendProfiling(); + BOOST_CHECK(backendProfilingIface); + + // Now for the meat of the test. We're just going to send a random packet and make sure there + // are no exceptions or errors. The sending of packets is already tested in SendTimelinePacketTests. + std::unique_ptr<armnn::profiling::ISendTimelinePacket> timelinePacket = + backendProfilingIface->GetSendTimelinePacket(); + // Send TimelineEntityClassBinaryPacket + const uint64_t entityBinaryPacketProfilingGuid = 123456u; + timelinePacket->SendTimelineEntityBinaryPacket(entityBinaryPacketProfilingGuid); + timelinePacket->Commit(); + + // Reset the profiling servie after the test. + options.m_ProfilingOptions.m_EnableProfiling = false; + profilingService.ResetExternalProfilingOptions(options.m_ProfilingOptions, true); +} + +BOOST_AUTO_TEST_CASE(GetProfilingGuidGenerator) +{ + // Reset the profiling service to the uninitialized state + armnn::IRuntime::CreationOptions options; + options.m_ProfilingOptions.m_EnableProfiling = true; + armnn::profiling::ProfilingService& profilingService = armnn::profiling::ProfilingService::Instance(); + profilingService.ConfigureProfilingService(options.m_ProfilingOptions, true); + + armnn::MockBackendInitialiser initialiser; + // Create a runtime. During this the mock backend will be registered and context returned. + armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); + armnn::MockBackendProfilingService mockProfilingService = armnn::MockBackendProfilingService::Instance(); + armnn::MockBackendProfilingContext *mockBackEndProfilingContext = mockProfilingService.GetContext(); + // Check that there is a valid context set. + BOOST_CHECK(mockBackEndProfilingContext); + armnn::IBackendInternal::IBackendProfilingPtr& backendProfilingIface = + mockBackEndProfilingContext->GetBackendProfiling(); + BOOST_CHECK(backendProfilingIface); + + // Get the Guid generator and check the getting two Guid's results in the second being greater than the first. + armnn::profiling::IProfilingGuidGenerator& guidGenerator = backendProfilingIface->GetProfilingGuidGenerator(); + BOOST_CHECK(backendProfilingIface); + const armnn::profiling::ProfilingDynamicGuid& firstGuid = guidGenerator.NextGuid(); + BOOST_CHECK(firstGuid); + const armnn::profiling::ProfilingDynamicGuid& secondGuid = guidGenerator.NextGuid(); + BOOST_CHECK(secondGuid > firstGuid); + + // Reset the profiling servie after the test. + options.m_ProfilingOptions.m_EnableProfiling = false; + profilingService.ResetExternalProfilingOptions(options.m_ProfilingOptions, true); +} + +BOOST_AUTO_TEST_SUITE_END() |