From 344302581b66677a748a456f370752db75adde21 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 4 Mar 2022 15:03:58 +0000 Subject: IVGCVSW-6816 Inject counter registration into ProfilingService Change-Id: I87ce3a1306eced9fc347cc383d9c7bc8994f0b0c Signed-off-by: Jim Flynn --- .../backendsCommon/test/BackendProfilingTests.cpp | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'src/backends/backendsCommon/test') diff --git a/src/backends/backendsCommon/test/BackendProfilingTests.cpp b/src/backends/backendsCommon/test/BackendProfilingTests.cpp index d262abca1b..c0b4e0a485 100644 --- a/src/backends/backendsCommon/test/BackendProfilingTests.cpp +++ b/src/backends/backendsCommon/test/BackendProfilingTests.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: MIT // +#include "ArmNNProfilingServiceInitialiser.hpp" #include "CounterDirectory.hpp" #include "CounterIdMap.hpp" #include "Holder.hpp" @@ -38,6 +39,11 @@ class ReadCounterVals : public IReadCounterValues { return (counterUid > 4 && counterUid < 11); } + virtual bool IsCounterRegistered(const std::string& counterName) const override + { + armnn::IgnoreUnused(counterName); + return false; + } virtual uint16_t GetCounterCount() const override { return 1; @@ -161,12 +167,14 @@ TEST_CASE("TestBackendCounters") ProfilingOptions options; options.m_EnableProfiling = true; - ProfilingService profilingService; + armnn::ArmNNProfilingServiceInitialiser initialiser; + std::unique_ptr profilingService = arm::pipe::IProfilingService::CreateProfilingService( + arm::pipe::MAX_ARMNN_COUNTER, initialiser); std::unique_ptr cpuBackendProfilingPtr = - std::make_unique(options, profilingService, cpuAccId); + std::make_unique(options, *profilingService.get(), cpuAccId); std::unique_ptr gpuBackendProfilingPtr = - std::make_unique(options, profilingService, gpuAccId); + std::make_unique(options, *profilingService.get(), gpuAccId); std::shared_ptr cpuProfilingContextPtr = std::make_shared(cpuBackendProfilingPtr); @@ -409,10 +417,12 @@ TEST_CASE("TestBackendCounterLogging") ProfilingOptions options; options.m_EnableProfiling = true; - ProfilingService profilingService; + armnn::ArmNNProfilingServiceInitialiser initialiser; + std::unique_ptr profilingService = arm::pipe::IProfilingService::CreateProfilingService( + arm::pipe::MAX_ARMNN_COUNTER, initialiser); std::unique_ptr cpuBackendProfilingPtr = - std::make_unique(options, profilingService, cpuAccId); + std::make_unique(options, *profilingService.get(), cpuAccId); std::shared_ptr cpuProfilingContextPtr = std::make_shared(cpuBackendProfilingPtr); @@ -461,15 +471,19 @@ TEST_CASE("BackendProfilingContextGetSendTimelinePacket") // Reset the profiling service to the uninitialized state armnn::IRuntime::CreationOptions options; options.m_ProfilingOptions.m_EnableProfiling = true; - ProfilingService profilingService; - profilingService.ConfigureProfilingService( + + armnn::ArmNNProfilingServiceInitialiser psInitialiser; + std::unique_ptr profilingService = arm::pipe::IProfilingService::CreateProfilingService( + arm::pipe::MAX_ARMNN_COUNTER, psInitialiser); + + profilingService->ConfigureProfilingService( ConvertExternalProfilingOptions(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(); + armnn::MockBackendProfilingContext* mockBackEndProfilingContext = mockProfilingService.GetContext(); // Check that there is a valid context set. CHECK(mockBackEndProfilingContext); armnn::IBackendInternal::IBackendProfilingPtr& backendProfilingIface = @@ -487,7 +501,7 @@ TEST_CASE("BackendProfilingContextGetSendTimelinePacket") // Reset the profiling servie after the test. options.m_ProfilingOptions.m_EnableProfiling = false; - profilingService.ResetExternalProfilingOptions( + profilingService->ResetExternalProfilingOptions( ConvertExternalProfilingOptions(options.m_ProfilingOptions), true); } -- cgit v1.2.1