aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFinn Williams <Finn.Williams@arm.com>2020-04-23 17:55:18 +0100
committerJim Flynn <jim.flynn@arm.com>2020-04-27 09:06:24 +0000
commitd7fcafaaaa917db458be362060e1b7855cad8083 (patch)
tree534e2898f2a7dd39a22bca8a073b085d8a7b7f80
parent8e84398b8eb4b2a2a558803f4c6359f6b255d49f (diff)
downloadarmnn-d7fcafaaaa917db458be362060e1b7855cad8083.tar.gz
IVGCVSW-4722 Add missing m_TimelineEnabled bool to ConnectionAcknowledgedCommandHandler
* Added timeline bool to ConnectionAcknowledgedCommandHandler * Added option to enable timeline profiling in ExecuteNetwork * Added CommandHandler stub to allow gatordMock to ignore packets Signed-off-by: Finn Williams <Finn.Williams@arm.com> Change-Id: I314f9411e0079cba8f103d3b8a89f2bf38bb21ab
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/profiling/ConnectionAcknowledgedCommandHandler.cpp8
-rw-r--r--src/profiling/ConnectionAcknowledgedCommandHandler.hpp6
-rw-r--r--src/profiling/ProfilingService.cpp1
-rw-r--r--src/timelineDecoder/TimelineDecoder.cpp7
-rw-r--r--tests/ExecuteNetwork/ExecuteNetwork.cpp39
-rw-r--r--tests/profiling/gatordmock/GatordMockService.hpp13
-rw-r--r--tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp3
-rw-r--r--tests/profiling/gatordmock/StubCommandHandler.hpp42
-rw-r--r--tests/profiling/gatordmock/tests/GatordMockTests.cpp5
10 files changed, 97 insertions, 28 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f74478565b..8f3aa0368a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1019,6 +1019,7 @@ if(BUILD_GATORD_MOCK)
tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
tests/profiling/gatordmock/StreamMetadataCommandHandler.cpp
tests/profiling/gatordmock/StreamMetadataCommandHandler.hpp
+ tests/profiling/gatordmock/StubCommandHandler.hpp
)
include_directories(src/profiling tests/profiling tests/profiling/gatordmock src/timelineDecoder)
diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
index 995562fb3f..7690573ccf 100644
--- a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
+++ b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp
@@ -40,8 +40,12 @@ void ConnectionAcknowledgedCommandHandler::operator()(const Packet& packet)
m_StateMachine.TransitionToState(ProfilingState::Active);
// Send the counter directory packet.
m_SendCounterPacket.SendCounterDirectoryPacket(m_CounterDirectory);
- m_SendTimelinePacket.SendTimelineMessageDirectoryPackage();
- TimelineUtilityMethods::SendWellKnownLabelsAndEventClasses(m_SendTimelinePacket);
+
+ if (m_TimelineEnabled)
+ {
+ m_SendTimelinePacket.SendTimelineMessageDirectoryPackage();
+ TimelineUtilityMethods::SendWellKnownLabelsAndEventClasses(m_SendTimelinePacket);
+ }
if(m_BackendProfilingContext.has_value())
{
diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
index e2bdff8e96..053d3c32fc 100644
--- a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
+++ b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp
@@ -44,12 +44,18 @@ public:
void operator()(const Packet& packet) override;
+ void setTimelineEnabled(bool timelineEnabled)
+ {
+ m_TimelineEnabled = timelineEnabled;
+ }
+
private:
const ICounterDirectory& m_CounterDirectory;
ISendCounterPacket& m_SendCounterPacket;
ISendTimelinePacket& m_SendTimelinePacket;
ProfilingStateMachine& m_StateMachine;
Optional<BackendProfilingContexts> m_BackendProfilingContext;
+ bool m_TimelineEnabled = false;
};
} // namespace profiling
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp
index 4d7241e7db..d87ed0bf67 100644
--- a/src/profiling/ProfilingService.cpp
+++ b/src/profiling/ProfilingService.cpp
@@ -35,6 +35,7 @@ void ProfilingService::ResetExternalProfilingOptions(const ExternalProfilingOpti
// Update the profiling options
m_Options = options;
m_TimelineReporting = options.m_TimelineEnabled;
+ m_ConnectionAcknowledgedCommandHandler.setTimelineEnabled(options.m_TimelineEnabled);
// Check if the profiling service needs to be reset
if (resetProfilingService)
diff --git a/src/timelineDecoder/TimelineDecoder.cpp b/src/timelineDecoder/TimelineDecoder.cpp
index f7f4663530..9aa84d2084 100644
--- a/src/timelineDecoder/TimelineDecoder.cpp
+++ b/src/timelineDecoder/TimelineDecoder.cpp
@@ -151,6 +151,13 @@ void TimelineDecoder::SetDefaultCallbacks()
void TimelineDecoder::print()
{
+ if (m_Model.m_Labels.empty() && m_Model.m_Entities.empty() && m_Model.m_EventClasses.empty() &&
+ m_Model.m_Events.empty() && m_Model.m_Relationships.empty())
+ {
+ std::cout << "No timeline packets received" << std::endl;
+ return;
+ }
+
printLabels();
printEntities();
printEventClasses();
diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp
index 9252a463cb..7dc9b65385 100644
--- a/tests/ExecuteNetwork/ExecuteNetwork.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp
@@ -109,6 +109,8 @@ int main(int argc, const char* argv[])
"If this option is enabled, the output of every graph layer will be printed.")
("enable-external-profiling,a", po::bool_switch()->default_value(false),
"If enabled external profiling will be switched on")
+ ("timeline-profiling", po::bool_switch()->default_value(false),
+ "If enabled timeline profiling will be switched on, requires external profiling")
("outgoing-capture-file,j", po::value(&outgoingCaptureFile),
"If specified the outgoing external profiling packets will be captured in this binary file")
("incoming-capture-file,k", po::value(&incomingCaptureFile),
@@ -168,6 +170,7 @@ int main(int argc, const char* argv[])
bool enableExternalProfiling = vm["enable-external-profiling"].as<bool>();
bool fileOnlyExternalProfiling = vm["file-only-external-profiling"].as<bool>();
bool parseUnsupported = vm["parse-unsupported"].as<bool>();
+ bool timelineEnabled = vm["timeline-profiling"].as<bool>();
if (enableBf16TurboMode && enableFp16TurboMode)
{
@@ -175,6 +178,23 @@ int main(int argc, const char* argv[])
return EXIT_FAILURE;
}
+ // Create runtime
+ armnn::IRuntime::CreationOptions options;
+ options.m_EnableGpuProfiling = enableProfiling;
+ options.m_DynamicBackendsPath = dynamicBackendsPath;
+ options.m_ProfilingOptions.m_EnableProfiling = enableExternalProfiling;
+ options.m_ProfilingOptions.m_IncomingCaptureFile = incomingCaptureFile;
+ options.m_ProfilingOptions.m_OutgoingCaptureFile = outgoingCaptureFile;
+ options.m_ProfilingOptions.m_FileOnly = fileOnlyExternalProfiling;
+ options.m_ProfilingOptions.m_CapturePeriod = counterCapturePeriod;
+ options.m_ProfilingOptions.m_FileFormat = fileFormat;
+ options.m_ProfilingOptions.m_TimelineEnabled = timelineEnabled;
+
+ if (timelineEnabled && !enableExternalProfiling)
+ {
+ ARMNN_LOG(fatal) << "Timeline profiling requires external profiling to be turned on";
+ return EXIT_FAILURE;
+ }
// Check whether we have to load test cases from a file.
if (CheckOption(vm, "test-cases"))
@@ -196,17 +216,7 @@ int main(int argc, const char* argv[])
ARMNN_LOG(fatal) << "Given file \"" << testCasesFile << "\" has no test cases";
return EXIT_FAILURE;
}
-
// Create runtime
- armnn::IRuntime::CreationOptions options;
- options.m_EnableGpuProfiling = enableProfiling;
- options.m_DynamicBackendsPath = dynamicBackendsPath;
- options.m_ProfilingOptions.m_EnableProfiling = enableExternalProfiling;
- options.m_ProfilingOptions.m_IncomingCaptureFile = incomingCaptureFile;
- options.m_ProfilingOptions.m_OutgoingCaptureFile = outgoingCaptureFile;
- options.m_ProfilingOptions.m_FileOnly = fileOnlyExternalProfiling;
- options.m_ProfilingOptions.m_CapturePeriod = counterCapturePeriod;
- options.m_ProfilingOptions.m_FileFormat = fileFormat;
std::shared_ptr<armnn::IRuntime> runtime(armnn::IRuntime::Create(options));
const std::string executableName("ExecuteNetwork");
@@ -276,15 +286,6 @@ int main(int argc, const char* argv[])
return EXIT_FAILURE;
}
// Create runtime
- armnn::IRuntime::CreationOptions options;
- options.m_EnableGpuProfiling = enableProfiling;
- options.m_DynamicBackendsPath = dynamicBackendsPath;
- options.m_ProfilingOptions.m_EnableProfiling = enableExternalProfiling;
- options.m_ProfilingOptions.m_IncomingCaptureFile = incomingCaptureFile;
- options.m_ProfilingOptions.m_OutgoingCaptureFile = outgoingCaptureFile;
- options.m_ProfilingOptions.m_FileOnly = fileOnlyExternalProfiling;
- options.m_ProfilingOptions.m_CapturePeriod = counterCapturePeriod;
- options.m_ProfilingOptions.m_FileFormat = fileFormat;
std::shared_ptr<armnn::IRuntime> runtime(armnn::IRuntime::Create(options));
return RunTest(modelFormat, inputTensorShapes, computeDevices, dynamicBackendsPath, modelPath, inputNames,
diff --git a/tests/profiling/gatordmock/GatordMockService.hpp b/tests/profiling/gatordmock/GatordMockService.hpp
index 9b72f72feb..232d2565e3 100644
--- a/tests/profiling/gatordmock/GatordMockService.hpp
+++ b/tests/profiling/gatordmock/GatordMockService.hpp
@@ -21,6 +21,7 @@
#include "StreamMetadataCommandHandler.hpp"
#include "PacketVersionResolver.hpp"
+#include "StubCommandHandler.hpp"
namespace armnn
{
@@ -56,10 +57,12 @@ public:
, m_PacketVersionResolver()
, m_HandlerRegistry()
, m_TimelineDecoder()
- , m_StreamMetadataCommandHandler(
- 0, 0, m_PacketVersionResolver.ResolvePacketVersion(0, 0).GetEncodedValue(), !echoPackets)
, m_CounterCaptureCommandHandler(
0, 4, m_PacketVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(), !echoPackets)
+ , m_StreamMetadataCommandHandler(
+ 0, 0, m_PacketVersionResolver.ResolvePacketVersion(0, 0).GetEncodedValue(), !echoPackets)
+ // This stub lets us ignore any counter capture packets we receive without throwing an error
+ , m_StubCommandHandler(3, 0, m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue())
, m_DirectoryCaptureCommandHandler(
0, 2, m_PacketVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), !echoPackets)
, m_TimelineCaptureCommandHandler(
@@ -70,8 +73,9 @@ public:
{
m_TimelineDecoder.SetDefaultCallbacks();
- m_HandlerRegistry.RegisterFunctor(&m_StreamMetadataCommandHandler);
m_HandlerRegistry.RegisterFunctor(&m_CounterCaptureCommandHandler);
+ m_HandlerRegistry.RegisterFunctor(&m_StreamMetadataCommandHandler);
+ m_HandlerRegistry.RegisterFunctor(&m_StubCommandHandler);
m_HandlerRegistry.RegisterFunctor(&m_DirectoryCaptureCommandHandler);
m_HandlerRegistry.RegisterFunctor(&m_TimelineDirectoryCaptureCommandHandler);
m_HandlerRegistry.RegisterFunctor(&m_TimelineCaptureCommandHandler);
@@ -207,8 +211,9 @@ private:
timelinedecoder::TimelineDecoder m_TimelineDecoder;
- gatordmock::StreamMetadataCommandHandler m_StreamMetadataCommandHandler;
gatordmock::PeriodicCounterCaptureCommandHandler m_CounterCaptureCommandHandler;
+ gatordmock::StreamMetadataCommandHandler m_StreamMetadataCommandHandler;
+ gatordmock::StubCommandHandler m_StubCommandHandler;
profiling::DirectoryCaptureCommandHandler m_DirectoryCaptureCommandHandler;
diff --git a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp b/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
index 6b82280e81..c075857816 100644
--- a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
+++ b/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
@@ -2,6 +2,7 @@
// Copyright © 2019 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
+#pragma once
#include <CommandHandlerFunctor.hpp>
#include <Packet.hpp>
@@ -14,8 +15,6 @@ namespace armnn
namespace gatordmock
{
-#pragma once
-
class PeriodicCounterSelectionResponseHandler : public profiling::CommandHandlerFunctor
{
diff --git a/tests/profiling/gatordmock/StubCommandHandler.hpp b/tests/profiling/gatordmock/StubCommandHandler.hpp
new file mode 100644
index 0000000000..450f90fd2b
--- /dev/null
+++ b/tests/profiling/gatordmock/StubCommandHandler.hpp
@@ -0,0 +1,42 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+#include <CommandHandlerFunctor.hpp>
+#include <armnn/utility/IgnoreUnused.hpp>
+
+#include <vector>
+
+namespace armnn
+{
+
+namespace gatordmock
+{
+
+class StubCommandHandler : public profiling::CommandHandlerFunctor
+{
+
+public:
+ /**
+ *
+ * @param packetId The id of packets this handler will process.
+ * @param version The version of that id.
+ */
+ StubCommandHandler(uint32_t familyId,
+ uint32_t packetId,
+ uint32_t version)
+ : CommandHandlerFunctor(familyId, packetId, version)
+ {}
+
+ void operator()(const armnn::profiling::Packet& packet) override
+ {
+ //No op
+ IgnoreUnused(packet);
+ }
+
+};
+
+} // namespace gatordmock
+} // namespace armnn
diff --git a/tests/profiling/gatordmock/tests/GatordMockTests.cpp b/tests/profiling/gatordmock/tests/GatordMockTests.cpp
index 11a96fdd7d..1929c7aeef 100644
--- a/tests/profiling/gatordmock/tests/GatordMockTests.cpp
+++ b/tests/profiling/gatordmock/tests/GatordMockTests.cpp
@@ -239,7 +239,9 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
// Enable the profiling service.
armnn::IRuntime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
+ options.m_EnableProfiling = true;
+ options.m_TimelineEnabled = true;
+
armnn::profiling::ProfilingService profilingService;
profilingService.ResetExternalProfilingOptions(options, true);
@@ -396,6 +398,7 @@ BOOST_AUTO_TEST_CASE(GatorDMockTimeLineActivation)
armnn::IRuntime::CreationOptions options;
options.m_ProfilingOptions.m_EnableProfiling = true;
+ options.m_ProfilingOptions.m_TimelineEnabled = true;
armnn::Runtime runtime(options);
armnnUtils::Sockets::Socket clientConnection;