blob: fc2173065140b622d123746f836dfaf17d0bef83 [file] [log] [blame]
David Monahanc1536d62020-02-12 15:52:35 +00001//
2// Copyright © 2020 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "MockBackend.hpp"
7#include "MockBackendId.hpp"
8#include "Runtime.hpp"
9
10#include <armnn/BackendId.hpp>
11#include <boost/test/unit_test.hpp>
12#include <vector>
13
14BOOST_AUTO_TEST_SUITE(BackendProfilingTestSuite)
15
16BOOST_AUTO_TEST_CASE(BackendProfilingCounterRegisterMockBackendTest)
17{
18 // Reset the profiling service to the uninitialized state
19 armnn::IRuntime::CreationOptions options;
20 options.m_ProfilingOptions.m_EnableProfiling = true;
21 armnn::profiling::ProfilingService& profilingService = armnn::profiling::ProfilingService::Instance();
22 profilingService.ConfigureProfilingService(options.m_ProfilingOptions, true);
23
24 armnn::MockBackendInitialiser initialiser;
25 // Create a runtime
26 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
27
28 // Check if the MockBackends 3 dummy counters {0, 1, 2-5 (four cores)} are registered
29 armnn::BackendId mockId = armnn::MockBackendId();
30 const armnn::profiling::ICounterMappings& counterMap = profilingService.GetCounterMappings();
31 BOOST_CHECK(counterMap.GetGlobalId(0, mockId) == 5);
32 BOOST_CHECK(counterMap.GetGlobalId(1, mockId) == 6);
33 BOOST_CHECK(counterMap.GetGlobalId(2, mockId) == 7);
34 BOOST_CHECK(counterMap.GetGlobalId(3, mockId) == 8);
35 BOOST_CHECK(counterMap.GetGlobalId(4, mockId) == 9);
36 BOOST_CHECK(counterMap.GetGlobalId(5, mockId) == 10);
37 options.m_ProfilingOptions.m_EnableProfiling = false;
38 profilingService.ResetExternalProfilingOptions(options.m_ProfilingOptions, true);
39}
40
41BOOST_AUTO_TEST_SUITE_END()