#include <armnn/BackendId.hpp>
#include <armnn/Logging.hpp>
+#include <armnn/profiling/ISendTimelinePacket.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/numeric/conversion/cast.hpp>
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()
#pragma once
+#include "MockBackendId.hpp"
#include "armnn/backends/profiling/IBackendProfiling.hpp"
#include "armnn/backends/profiling/IBackendProfilingContext.hpp"
-#include "MockBackendId.hpp"
#include <LayerSupportCommon.hpp>
#include <armnn/backends/IBackendInternal.hpp>
#include <armnn/backends/OptimizationViews.hpp>
-#include <backendsCommon/LayerSupportBase.hpp>
#include <armnn/backends/profiling/IBackendProfiling.hpp>
#include <backends/BackendProfiling.hpp>
+#include <backendsCommon/LayerSupportBase.hpp>
namespace armnn
{
~MockBackendInitialiser();
};
-class MockBackendProfilingService
-{
-public:
- // Getter for the singleton instance
- static MockBackendProfilingService& Instance()
- {
- static MockBackendProfilingService instance;
- return instance;
- }
-
- armnn::profiling::IBackendProfilingContext* GetContext()
- {
- return m_sharedContext.get();
- }
-
- void SetProfilingContextPtr(IBackendInternal::IBackendProfilingContextPtr& shared)
- {
- m_sharedContext = shared;
- }
-
-private:
- IBackendInternal::IBackendProfilingContextPtr m_sharedContext;
-};
-
class MockBackendProfilingContext : public profiling::IBackendProfilingContext
{
public:
MockBackendProfilingContext(IBackendInternal::IBackendProfilingPtr& backendProfiling)
- : m_BackendProfiling(backendProfiling)
+ : m_BackendProfiling(std::move(backendProfiling))
, m_CapturePeriod(0)
{}
std::unique_ptr<profiling::IRegisterBackendCounters> counterRegistrar =
m_BackendProfiling->GetCounterRegistrationInterface(currentMaxGlobalCounterId);
- std::string categoryName("MockCounters");
- counterRegistrar->RegisterCategory(categoryName);
- uint16_t nextMaxGlobalCounterId = counterRegistrar->RegisterCounter(
- 0, categoryName, 0, 0, 1.f, "Mock Counter One", "Some notional counter");
+ std::string categoryName("MockCounters");
+ counterRegistrar->RegisterCategory(categoryName);
+ uint16_t nextMaxGlobalCounterId =
+ counterRegistrar->RegisterCounter(0, categoryName, 0, 0, 1.f, "Mock Counter One", "Some notional counter");
- nextMaxGlobalCounterId = counterRegistrar->RegisterCounter(
- 1, categoryName, 0, 0, 1.f, "Mock Counter Two", "Another notional counter");
+ nextMaxGlobalCounterId = counterRegistrar->RegisterCounter(1, categoryName, 0, 0, 1.f, "Mock Counter Two",
+ "Another notional counter");
- std::string units("microseconds");
- nextMaxGlobalCounterId = counterRegistrar->RegisterCounter(
- 2, categoryName, 0, 0, 1.f, "Mock MultiCore Counter", "A dummy four core counter", units, 4);
- return nextMaxGlobalCounterId;
+ std::string units("microseconds");
+ nextMaxGlobalCounterId = counterRegistrar->RegisterCounter(2, categoryName, 0, 0, 1.f, "Mock MultiCore Counter",
+ "A dummy four core counter", units, 4);
+ return nextMaxGlobalCounterId;
}
Optional<std::string> ActivateCounters(uint32_t capturePeriod, const std::vector<uint16_t>& counterIds)
{
- if ( capturePeriod == 0 || counterIds.size() == 0)
+ if (capturePeriod == 0 || counterIds.size() == 0)
{
m_ActiveCounters.clear();
}
{
return armnn::Optional<std::string>("ActivateCounters example test error");
}
- m_CapturePeriod = capturePeriod;
+ m_CapturePeriod = capturePeriod;
m_ActiveCounters = counterIds;
return armnn::Optional<std::string>();
}
{
std::vector<profiling::CounterValue> counterValues;
- for(auto counterId : m_ActiveCounters)
+ for (auto counterId : m_ActiveCounters)
{
- counterValues.emplace_back(profiling::CounterValue{counterId, counterId+1u});
+ counterValues.emplace_back(profiling::CounterValue{ counterId, counterId + 1u });
}
uint64_t timestamp = m_CapturePeriod;
- return {profiling::Timestamp{timestamp, counterValues}};
+ return { profiling::Timestamp{ timestamp, counterValues } };
}
void EnableProfiling(bool)
{}
private:
-
- IBackendInternal::IBackendProfilingPtr& m_BackendProfiling;
+ IBackendInternal::IBackendProfilingPtr m_BackendProfiling;
uint32_t m_CapturePeriod;
std::vector<uint16_t> m_ActiveCounters;
};
+class MockBackendProfilingService
+{
+public:
+ // Getter for the singleton instance
+ static MockBackendProfilingService& Instance()
+ {
+ static MockBackendProfilingService instance;
+ return instance;
+ }
+
+ MockBackendProfilingContext* GetContext()
+ {
+ return m_sharedContext.get();
+ }
+
+ void SetProfilingContextPtr(std::shared_ptr<MockBackendProfilingContext> shared)
+ {
+ m_sharedContext = shared;
+ }
+
+private:
+ std::shared_ptr<MockBackendProfilingContext> m_sharedContext;
+};
+
class MockBackend : public IBackendInternal
{
public: