From c1536d69c1468514425e143b0578656f51598b94 Mon Sep 17 00:00:00 2001 From: David Monahan Date: Wed, 12 Feb 2020 15:52:35 +0000 Subject: IVGCVSW-4400 Backend Counter Registry Functionality * Adding BackendProfilingContext to the MockBackend * Made IBackendProfilingContext pure Virtual * Added UnitTest using MockBackend for testing Backend Counter Registration * Moved Registry of backend counters from Initialize() to AddBackendProfilingContext() * Added m_MaxGlobalCounterId to ProfilingService * Removed automatic registration of MockBack in BackendRegistry() Signed-off-by: David Monahan Change-Id: Ie1c6c31e56d1ac7079d6116ecad041961014aedc --- .../backendsCommon/test/BackendProfilingTests.cpp | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/backends/backendsCommon/test/BackendProfilingTests.cpp (limited to 'src/backends/backendsCommon/test/BackendProfilingTests.cpp') diff --git a/src/backends/backendsCommon/test/BackendProfilingTests.cpp b/src/backends/backendsCommon/test/BackendProfilingTests.cpp new file mode 100644 index 0000000000..fc21730651 --- /dev/null +++ b/src/backends/backendsCommon/test/BackendProfilingTests.cpp @@ -0,0 +1,41 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "MockBackend.hpp" +#include "MockBackendId.hpp" +#include "Runtime.hpp" + +#include +#include +#include + +BOOST_AUTO_TEST_SUITE(BackendProfilingTestSuite) + +BOOST_AUTO_TEST_CASE(BackendProfilingCounterRegisterMockBackendTest) +{ + // 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 + armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); + + // Check if the MockBackends 3 dummy counters {0, 1, 2-5 (four cores)} are registered + armnn::BackendId mockId = armnn::MockBackendId(); + const armnn::profiling::ICounterMappings& counterMap = profilingService.GetCounterMappings(); + BOOST_CHECK(counterMap.GetGlobalId(0, mockId) == 5); + BOOST_CHECK(counterMap.GetGlobalId(1, mockId) == 6); + BOOST_CHECK(counterMap.GetGlobalId(2, mockId) == 7); + BOOST_CHECK(counterMap.GetGlobalId(3, mockId) == 8); + BOOST_CHECK(counterMap.GetGlobalId(4, mockId) == 9); + BOOST_CHECK(counterMap.GetGlobalId(5, mockId) == 10); + options.m_ProfilingOptions.m_EnableProfiling = false; + profilingService.ResetExternalProfilingOptions(options.m_ProfilingOptions, true); +} + +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file -- cgit v1.2.1