aboutsummaryrefslogtreecommitdiff
path: root/tests/profiling
diff options
context:
space:
mode:
Diffstat (limited to 'tests/profiling')
-rw-r--r--tests/profiling/gatordmock/CommandFileParser.cpp85
-rw-r--r--tests/profiling/gatordmock/CommandFileParser.hpp29
-rw-r--r--tests/profiling/gatordmock/CommandLineProcessor.cpp72
-rw-r--r--tests/profiling/gatordmock/CommandLineProcessor.hpp47
-rw-r--r--tests/profiling/gatordmock/CounterDirectory.hpp263
-rw-r--r--tests/profiling/gatordmock/GatordMockMain.cpp79
-rw-r--r--tests/profiling/gatordmock/GatordMockService.cpp485
-rw-r--r--tests/profiling/gatordmock/GatordMockService.hpp158
-rw-r--r--tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp128
-rw-r--r--tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp61
-rw-r--r--tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp37
-rw-r--r--tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp45
-rw-r--r--tests/profiling/gatordmock/StreamMetadataCommandHandler.cpp127
-rw-r--r--tests/profiling/gatordmock/StreamMetadataCommandHandler.hpp71
-rw-r--r--tests/profiling/gatordmock/tests/GatordMockTests.cpp295
-rw-r--r--tests/profiling/timelineDecoder/ITimelineDecoder.h41
-rw-r--r--tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.cpp300
-rw-r--r--tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.hpp66
-rw-r--r--tests/profiling/timelineDecoder/TimelineDecoder.cpp166
-rw-r--r--tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp117
-rw-r--r--tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp49
-rw-r--r--tests/profiling/timelineDecoder/TimelineModel.h96
-rw-r--r--tests/profiling/timelineDecoder/tests/TimelineTestFunctions.hpp143
-rw-r--r--tests/profiling/timelineDecoder/tests/TimelineTests.cpp220
24 files changed, 0 insertions, 3180 deletions
diff --git a/tests/profiling/gatordmock/CommandFileParser.cpp b/tests/profiling/gatordmock/CommandFileParser.cpp
deleted file mode 100644
index 7c746f16e9..0000000000
--- a/tests/profiling/gatordmock/CommandFileParser.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "CommandFileParser.hpp"
-
-#include <algorithm>
-#include <fstream>
-#include <iostream>
-#include <iterator>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-void CommandFileParser::ParseFile(std::string CommandFile, GatordMockService& mockService)
-{
- std::ifstream infile(CommandFile);
- std::string line;
-
- std::cout << "Parsing command file: " << CommandFile << std::endl;
-
- while (mockService.ReceiveThreadRunning() && std::getline(infile, line))
- {
- std::istringstream iss(line);
-
- std::vector<std::string> tokens;
-
- std::copy(std::istream_iterator<std::string>(iss), std::istream_iterator<std::string>(),
- std::back_inserter(tokens));
-
- std::string command = tokens[0];
-
- if (command == "LIST")
- {
- // Expected format for the SET command
- //
- // LIST
- //
-
- mockService.SendRequestCounterDir();
- }
- if (command == "SET")
- {
- // Expected format for the SET command
- //
- // SET 500000 1 2 5 10
- //
- // This breaks down to:
- // SET command
- // 500000 polling period in micro seconds
- // 1 2 5 10 counter list
-
- uint32_t period = static_cast<uint32_t>(std::stoul(tokens[1]));
-
- std::vector<uint16_t> counters;
-
- std::transform(tokens.begin() + 2, tokens.end(), std::back_inserter(counters),
- [](const std::string& str) { return static_cast<uint16_t>(std::stoul(str)); });
-
- mockService.SendPeriodicCounterSelectionList(period, counters);
- }
- else if (command == "WAIT")
- {
- // Expected format for the SET command
- //
- // WAIT 11000000
- //
- // This breaks down to:
- // WAIT command
- // 11000000 timeout period in micro seconds
-
- uint32_t timeout = static_cast<uint32_t>(std::stoul(tokens[1]));
-
- mockService.WaitCommand(timeout);
- }
- }
-}
-
-} // namespace gatordmock
-
-} // namespace armnn
diff --git a/tests/profiling/gatordmock/CommandFileParser.hpp b/tests/profiling/gatordmock/CommandFileParser.hpp
deleted file mode 100644
index fd4a4fdf38..0000000000
--- a/tests/profiling/gatordmock/CommandFileParser.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include "GatordMockService.hpp"
-#include <string>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-/// This class parses a command file for the GatordMockService. The file contains one command per line.
-/// Valid commands are: SET and WAIT.
-///
-/// SET: Will construct and send a PeriodicCounterSelection packet to enable a set of counters.
-/// WAIT: Will pause for a set period of time to allow for data to be received.
-class CommandFileParser
-{
-public:
- void ParseFile(std::string CommandFile, GatordMockService& mockService);
-};
-
-} // namespace gatordmock
-} // namespace armnn
diff --git a/tests/profiling/gatordmock/CommandLineProcessor.cpp b/tests/profiling/gatordmock/CommandLineProcessor.cpp
deleted file mode 100644
index 55b51137bc..0000000000
--- a/tests/profiling/gatordmock/CommandLineProcessor.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "CommandLineProcessor.hpp"
-
-#include <boost/program_options.hpp>
-#include <iostream>
-
-namespace armnn
-{
-namespace gatordmock
-{
-
-bool CommandLineProcessor::ProcessCommandLine(int argc, char *argv[])
-{
- namespace po = boost::program_options;
- po::options_description desc("Options");
- try
- {
- desc.add_options()
- ("help,h", "Display help messages")
- ("file,f", po::value<std::string>(&m_File),
- "The path to the file that contains instructions for the mock gatord")
- ("namespace,n", po::value<std::string>(&m_UdsNamespace)->default_value("gatord_namespace"),
- "The Unix domain socket namespace this server will bind to.\n"
- "This will always be prepended with \\0 to use the abstract namespace")
- ("echo,e", po::bool_switch(&m_Echo)->default_value(false),
- "Echo packets sent and received to stdout. Disabled by default.\n");
- }
- catch (const std::exception& e)
- {
- std::cerr << "Fatal internal error: [" << e.what() << "]" << std::endl;
- return false;
- }
-
- po::variables_map vm;
- try
- {
- po::store(po::parse_command_line(argc, argv, desc), vm);
-
- if (vm.count("help"))
- {
- std::cout << "Simulate a Gatord server to interact with ArmNN external profiling." << std::endl;
- std::cout << std::endl;
- std::cout << desc << std::endl;
- return false;
- }
- // Currently the file parameter is mandatory.
- if (!vm.count("file"))
- {
- std::cout << std::endl << "*** Expected --file or -f parameter." << std::endl;
- std::cout << std::endl;
- std::cout << desc << std::endl;
- return false;
- }
- po::notify(vm);
- }
- catch (const po::error& e)
- {
- std::cerr << e.what() << std::endl << std::endl;
- std::cerr << desc << std::endl;
- return false;
- }
-
- return true;
-}
-
-} // namespace gatordmock
-
-} // namespace armnn \ No newline at end of file
diff --git a/tests/profiling/gatordmock/CommandLineProcessor.hpp b/tests/profiling/gatordmock/CommandLineProcessor.hpp
deleted file mode 100644
index 532948a5cf..0000000000
--- a/tests/profiling/gatordmock/CommandLineProcessor.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#pragma once
-
-#include <string>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-/// Use Boost program options to process the command line.
-/// -h or --help to print the options.
-/// -n or --namespace to specify the UDS namespace that the server will be listening on.
-/// -e or --echo print all sent and received packets to stdout.
-/// -f or --file The path to the file that contains instructions for the mock gatord.
-class CommandLineProcessor
-{
-public:
- bool ProcessCommandLine(int argc, char* argv[]);
- bool IsEchoEnabled()
- {
- return m_Echo;
- }
-
- std::string GetUdsNamespace()
- {
- return m_UdsNamespace;
- }
- std::string GetCommandFile()
- {
- return m_File;
- }
-
-private:
- std::string m_UdsNamespace;
- std::string m_File;
-
- bool m_Echo;
-};
-
-} // namespace gatordmock
-
-} // namespace armnn
diff --git a/tests/profiling/gatordmock/CounterDirectory.hpp b/tests/profiling/gatordmock/CounterDirectory.hpp
deleted file mode 100644
index 7b45e661e0..0000000000
--- a/tests/profiling/gatordmock/CounterDirectory.hpp
+++ /dev/null
@@ -1,263 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-
-#include "GatordMockService.hpp"
-#include "MockUtils.hpp"
-
-#include "Packet.hpp"
-#include "CommandHandlerFunctor.hpp"
-#include "SendCounterPacket.hpp"
-#include "IPeriodicCounterCapture.hpp"
-
-#include <vector>
-#include <thread>
-#include <atomic>
-#include <iostream>
-#include <functional>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-struct EventRecord
-{
- uint16_t m_CounterUid;
- uint16_t m_MaxCounterUid;
- uint16_t m_DeviceUid;
- uint16_t m_CounterSetUid;
- uint16_t m_CounterClass;
- uint16_t m_CounterInterpolation;
- double m_CounterMultiplier;
- std::string m_CounterName;
- std::string m_CounterDescription;
- std::string m_CounterUnits;
-
- static void printHeader(std::string categoryName)
- {
- std::string header;
-
- header.append(gatordmock::CentreAlignFormatting("Counter Name", 20));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Description", 50));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Units", 14));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("UID", 6));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Max UID",10));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Class", 8));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Interpolation", 14));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Multiplier", 20));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Counter set UID", 16));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Device UID", 14));
- header.append("\n");
-
- std::cout << "\n" << "\n";
- std::cout << gatordmock::CentreAlignFormatting("EVENTS IN CATEGORY: " + categoryName,
- static_cast<int>(header.size()));
- std::cout << "\n";
- std::cout << std::string(header.size(), '=') << "\n";
- std::cout << header;
- }
-
- void printContents() const
- {
- std::string body;
-
- body.append(gatordmock::CentreAlignFormatting(m_CounterName, 20));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(m_CounterDescription, 50));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(m_CounterUnits, 14));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_CounterUid), 6));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_MaxCounterUid), 10));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_CounterClass), 8));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_CounterInterpolation), 14));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_CounterMultiplier), 20));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_CounterSetUid), 16));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_DeviceUid), 14));
-
- body.append("\n");
-
- std::cout << std::string(body.size(), '-') << "\n";
-
- std::cout << body;
- }
-};
-
-struct CategoryRecord
-{
- uint16_t m_DeviceUid;
- uint16_t m_CounterSet;
- uint16_t m_EventCount;
- std::string m_CategoryName;
- std::vector<EventRecord> m_EventRecords;
-
- void print() const
- {
- std::string body;
- std::string header;
-
- header.append(gatordmock::CentreAlignFormatting("Name", 20));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Device", 12));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Counter set UID:", 16));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Event Count", 14));
- header.append("\n");
-
- body.append(gatordmock::CentreAlignFormatting(m_CategoryName, 20));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_DeviceUid), 12));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_CounterSet), 16));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_EventCount), 14));
-
- std::cout << "\n" << "\n";
- std::cout << gatordmock::CentreAlignFormatting("CATEGORY", static_cast<int>(header.size()));
- std::cout << "\n";
- std::cout << std::string(header.size(), '=') << "\n";
-
- std::cout<< header;
-
- std::cout << std::string(body.size(), '-') << "\n";
-
- std::cout<< body;
-
- if(m_EventRecords.size() > 0)
- {
- EventRecord::printHeader(m_CategoryName);
-
- std::for_each(m_EventRecords.begin(), m_EventRecords.end(), std::mem_fun_ref(&EventRecord::printContents));
- }
- }
-};
-
-struct CounterSetRecord
-{
- uint16_t m_CounterSetUid;
- uint16_t m_CounterSetCount;
- std::string m_CounterSetName;
-
- static void printHeader()
- {
- std::string header;
-
- header.append(gatordmock::CentreAlignFormatting("Counter set name", 20));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("UID",13));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Count",10));
- header.append("\n");
-
- std::cout << "\n" << "\n";
- std::cout << gatordmock::CentreAlignFormatting("COUNTER SETS", static_cast<int>(header.size()));
- std::cout << "\n";
- std::cout << std::string(header.size(), '=') << "\n";
-
- std::cout<< header;
- }
-
- void printContents() const
- {
- std::string body;
-
- body.append(gatordmock::CentreAlignFormatting(m_CounterSetName, 20));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_CounterSetUid), 13));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_CounterSetCount), 10));
- body.append("\n");
-
- std::cout << std::string(body.size(), '-') << "\n";
-
- std::cout<< body;
- }
-};
-
-struct DeviceRecord
-{
- uint16_t m_DeviceUid;
- uint16_t m_DeviceCores;
- std::string m_DeviceName;
-
- static void printHeader()
- {
- std::string header;
-
- header.append(gatordmock::CentreAlignFormatting("Device name", 20));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("UID",13));
- header.append(" | ");
- header.append(gatordmock::CentreAlignFormatting("Cores",10));
- header.append("\n");
-
- std::cout << "\n" << "\n";
- std::cout << gatordmock::CentreAlignFormatting("DEVICES", static_cast<int>(header.size()));
- std::cout << "\n";
- std::cout << std::string(header.size(), '=') << "\n";
- std::cout<< header;
- }
-
- void printContents() const
- {
- std::string body;
-
- body.append(gatordmock::CentreAlignFormatting(m_DeviceName, 20));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_DeviceUid), 13));
- body.append(" | ");
- body.append(gatordmock::CentreAlignFormatting(std::to_string(m_DeviceCores), 10));
- body.append("\n");
-
- std::cout << std::string(body.size(), '-') << "\n";
- std::cout<< body;
- }
-};
-
-struct CounterDirectory
-{
- std::vector<CategoryRecord> m_Categories;
- std::vector<CounterSetRecord> m_CounterSets;
- std::vector<DeviceRecord> m_DeviceRecords;
-
- void print() const
- {
- DeviceRecord::printHeader();
- std::for_each(m_DeviceRecords.begin(), m_DeviceRecords.end(),
- std::mem_fun_ref(&DeviceRecord::printContents));
-
- CounterSetRecord::printHeader();
- std::for_each(m_CounterSets.begin(), m_CounterSets.end(),
- std::mem_fun_ref(&CounterSetRecord::printContents));
-
- std::for_each(m_Categories.begin(), m_Categories.end(),
- std::mem_fun_ref(&CategoryRecord::print));
- std::cout << "\n";
- }
-};
-
-} // namespace gatordmock
-
-} // namespace armnn \ No newline at end of file
diff --git a/tests/profiling/gatordmock/GatordMockMain.cpp b/tests/profiling/gatordmock/GatordMockMain.cpp
deleted file mode 100644
index edad85cffe..0000000000
--- a/tests/profiling/gatordmock/GatordMockMain.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "../../../src/profiling/PacketVersionResolver.hpp"
-#include "../../../src/profiling/PeriodicCounterSelectionCommandHandler.hpp"
-#include "CommandFileParser.hpp"
-#include "CommandLineProcessor.hpp"
-#include "DirectoryCaptureCommandHandler.hpp"
-#include "GatordMockService.hpp"
-#include "PeriodicCounterCaptureCommandHandler.hpp"
-#include "PeriodicCounterSelectionResponseHandler.hpp"
-
-#include <iostream>
-#include <string>
-
-int main(int argc, char* argv[])
-{
- // Process command line arguments
- armnn::gatordmock::CommandLineProcessor cmdLine;
- if (!cmdLine.ProcessCommandLine(argc, argv))
- {
- return EXIT_FAILURE;
- }
-
- armnn::profiling::PacketVersionResolver packetVersionResolver;
- // Create the Command Handler Registry
- armnn::profiling::CommandHandlerRegistry registry;
-
- // This functor will receive back the selection response packet.
- armnn::gatordmock::PeriodicCounterSelectionResponseHandler periodicCounterSelectionResponseHandler(
- 0, 4, packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue());
- // This functor will receive the counter data.
- armnn::gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(
- 3, 0, packetVersionResolver.ResolvePacketVersion(3, 0).GetEncodedValue());
-
- armnn::profiling::DirectoryCaptureCommandHandler directoryCaptureCommandHandler(
- 0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), false);
-
- // Register different derived functors
- registry.RegisterFunctor(&periodicCounterSelectionResponseHandler);
- registry.RegisterFunctor(&counterCaptureCommandHandler);
- registry.RegisterFunctor(&directoryCaptureCommandHandler);
-
- armnn::gatordmock::GatordMockService mockService(registry, cmdLine.IsEchoEnabled());
-
- if (!mockService.OpenListeningSocket(cmdLine.GetUdsNamespace()))
- {
- return EXIT_FAILURE;
- }
- std::cout << "Bound to UDS namespace: \\0" << cmdLine.GetUdsNamespace() << std::endl;
-
- // Wait for a single connection.
- if (-1 == mockService.BlockForOneClient())
- {
- return EXIT_FAILURE;
- }
- std::cout << "Client connection established." << std::endl;
-
- // Send receive the strweam metadata and send connection ack.
- if (!mockService.WaitForStreamMetaData())
- {
- return EXIT_FAILURE;
- }
- mockService.SendConnectionAck();
-
- // Prepare to receive data.
- mockService.LaunchReceivingThread();
-
- // Process the SET and WAIT command from the file.
- armnn::gatordmock::CommandFileParser commandLineParser;
- commandLineParser.ParseFile(cmdLine.GetCommandFile(), mockService);
-
- // Once we've finished processing the file wait for the receiving thread to close.
- mockService.WaitForReceivingThread();
-
- return EXIT_SUCCESS;
-}
diff --git a/tests/profiling/gatordmock/GatordMockService.cpp b/tests/profiling/gatordmock/GatordMockService.cpp
deleted file mode 100644
index c5211962d3..0000000000
--- a/tests/profiling/gatordmock/GatordMockService.cpp
+++ /dev/null
@@ -1,485 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "GatordMockService.hpp"
-
-#include <CommandHandlerRegistry.hpp>
-#include <PacketVersionResolver.hpp>
-#include <ProfilingUtils.hpp>
-#include <NetworkSockets.hpp>
-
-#include <cerrno>
-#include <fcntl.h>
-#include <iomanip>
-#include <iostream>
-#include <string>
-
-using namespace armnnUtils;
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-bool GatordMockService::OpenListeningSocket(std::string udsNamespace)
-{
- Sockets::Initialize();
- m_ListeningSocket = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
- if (-1 == m_ListeningSocket)
- {
- std::cerr << ": Socket construction failed: " << strerror(errno) << std::endl;
- return false;
- }
-
- sockaddr_un udsAddress;
- memset(&udsAddress, 0, sizeof(sockaddr_un));
- // We've set the first element of sun_path to be 0, skip over it and copy the namespace after it.
- memcpy(udsAddress.sun_path + 1, udsNamespace.c_str(), strlen(udsNamespace.c_str()));
- udsAddress.sun_family = AF_UNIX;
-
- // Bind the socket to the UDS namespace.
- if (-1 == bind(m_ListeningSocket, reinterpret_cast<const sockaddr*>(&udsAddress), sizeof(sockaddr_un)))
- {
- std::cerr << ": Binding on socket failed: " << strerror(errno) << std::endl;
- return false;
- }
- // Listen for 1 connection.
- if (-1 == listen(m_ListeningSocket, 1))
- {
- std::cerr << ": Listen call on socket failed: " << strerror(errno) << std::endl;
- return false;
- }
- return true;
-}
-
-Sockets::Socket GatordMockService::BlockForOneClient()
-{
- m_ClientConnection = Sockets::Accept(m_ListeningSocket, nullptr, nullptr, SOCK_CLOEXEC);
- if (-1 == m_ClientConnection)
- {
- std::cerr << ": Failure when waiting for a client connection: " << strerror(errno) << std::endl;
- return -1;
- }
- return m_ClientConnection;
-}
-
-bool GatordMockService::WaitForStreamMetaData()
-{
- if (m_EchoPackets)
- {
- std::cout << "Waiting for stream meta data..." << std::endl;
- }
- // The start of the stream metadata is 2x32bit words, 0 and packet length.
- uint8_t header[8];
- if (!ReadFromSocket(header, 8))
- {
- return false;
- }
- EchoPacket(PacketDirection::ReceivedHeader, header, 8);
- // The first word, stream_metadata_identifer, should always be 0.
- if (ToUint32(&header[0], TargetEndianness::BeWire) != 0)
- {
- std::cerr << ": Protocol error. The stream_metadata_identifer was not 0." << std::endl;
- return false;
- }
-
- uint8_t pipeMagic[4];
- if (!ReadFromSocket(pipeMagic, 4))
- {
- return false;
- }
- EchoPacket(PacketDirection::ReceivedData, pipeMagic, 4);
-
- // Before we interpret the length we need to read the pipe_magic word to determine endianness.
- if (ToUint32(&pipeMagic[0], TargetEndianness::BeWire) == PIPE_MAGIC)
- {
- m_Endianness = TargetEndianness::BeWire;
- }
- else if (ToUint32(&pipeMagic[0], TargetEndianness::LeWire) == PIPE_MAGIC)
- {
- m_Endianness = TargetEndianness::LeWire;
- }
- else
- {
- std::cerr << ": Protocol read error. Unable to read PIPE_MAGIC value." << std::endl;
- return false;
- }
- // Now we know the endianness we can get the length from the header.
- // Remember we already read the pipe magic 4 bytes.
- uint32_t metaDataLength = ToUint32(&header[4], m_Endianness) - 4;
- // Read the entire packet.
- std::vector<uint8_t> packetData(metaDataLength);
- if (metaDataLength !=
- boost::numeric_cast<uint32_t>(Sockets::Read(m_ClientConnection, packetData.data(), metaDataLength)))
- {
- std::cerr << ": Protocol read error. Data length mismatch." << std::endl;
- return false;
- }
- EchoPacket(PacketDirection::ReceivedData, packetData.data(), metaDataLength);
- m_StreamMetaDataVersion = ToUint32(&packetData[0], m_Endianness);
- m_StreamMetaDataMaxDataLen = ToUint32(&packetData[4], m_Endianness);
- m_StreamMetaDataPid = ToUint32(&packetData[8], m_Endianness);
-
- return true;
-}
-
-void GatordMockService::SendConnectionAck()
-{
- if (m_EchoPackets)
- {
- std::cout << "Sending connection acknowledgement." << std::endl;
- }
- // The connection ack packet is an empty data packet with packetId == 1.
- SendPacket(0, 1, nullptr, 0);
-}
-
-void GatordMockService::SendRequestCounterDir()
-{
- if (m_EchoPackets)
- {
- std::cout << "Sending connection acknowledgement." << std::endl;
- }
- // The connection ack packet is an empty data packet with packetId == 1.
- SendPacket(0, 3, nullptr, 0);
-}
-
-bool GatordMockService::LaunchReceivingThread()
-{
- if (m_EchoPackets)
- {
- std::cout << "Launching receiving thread." << std::endl;
- }
- // At this point we want to make the socket non blocking.
- if (!Sockets::SetNonBlocking(m_ClientConnection))
- {
- Sockets::Close(m_ClientConnection);
- std::cerr << "Failed to set socket as non blocking: " << strerror(errno) << std::endl;
- return false;
- }
- m_ListeningThread = std::thread(&GatordMockService::ReceiveLoop, this, std::ref(*this));
- return true;
-}
-
-void GatordMockService::WaitForReceivingThread()
-{
- // The receiving thread may already have died.
- if (m_CloseReceivingThread != true)
- {
- m_CloseReceivingThread.store(true);
- }
- // Check that the receiving thread is running
- if (m_ListeningThread.joinable())
- {
- // Wait for the receiving thread to complete operations
- m_ListeningThread.join();
- }
-}
-
-void GatordMockService::SendPeriodicCounterSelectionList(uint32_t period, std::vector<uint16_t> counters)
-{
- // The packet body consists of a UINT32 representing the period following by zero or more
- // UINT16's representing counter UID's. If the list is empty it implies all counters are to
- // be disabled.
-
- if (m_EchoPackets)
- {
- std::cout << "SendPeriodicCounterSelectionList: Period=" << std::dec << period << "uSec" << std::endl;
- std::cout << "List length=" << counters.size() << std::endl;
- ;
- }
- // Start by calculating the length of the packet body in bytes. This will be at least 4.
- uint32_t dataLength = static_cast<uint32_t>(4 + (counters.size() * 2));
-
- std::unique_ptr<unsigned char[]> uniqueData = std::make_unique<unsigned char[]>(dataLength);
- unsigned char* data = reinterpret_cast<unsigned char*>(uniqueData.get());
-
- uint32_t offset = 0;
- profiling::WriteUint32(data, offset, period);
- offset += 4;
- for (std::vector<uint16_t>::iterator it = counters.begin(); it != counters.end(); ++it)
- {
- profiling::WriteUint16(data, offset, *it);
- offset += 2;
- }
-
- // Send the packet.
- SendPacket(0, 4, data, dataLength);
- // There will be an echo response packet sitting in the receive thread. PeriodicCounterSelectionResponseHandler
- // should deal with it.
-}
-
-void GatordMockService::WaitCommand(uint32_t timeout)
-{
- // Wait for a maximum of timeout microseconds or if the receive thread has closed.
- // There is a certain level of rounding involved in this timing.
- uint32_t iterations = timeout / 1000;
- std::cout << std::dec << "Wait command with timeout of " << timeout << " iterations = " << iterations << std::endl;
- uint32_t count = 0;
- while ((this->ReceiveThreadRunning() && (count < iterations)))
- {
- std::this_thread::sleep_for(std::chrono::microseconds(1000));
- ++count;
- }
- if (m_EchoPackets)
- {
- std::cout << std::dec << "Wait command with timeout of " << timeout << " microseconds completed. " << std::endl;
- }
-}
-
-void GatordMockService::ReceiveLoop(GatordMockService& mockService)
-{
- m_CloseReceivingThread.store(false);
- while (!m_CloseReceivingThread.load())
- {
- try
- {
- armnn::profiling::Packet packet = mockService.WaitForPacket(500);
- }
- catch (const armnn::TimeoutException&)
- {
- // In this case we ignore timeouts and and keep trying to receive.
- }
- catch (const armnn::InvalidArgumentException& e)
- {
- // We couldn't find a functor to handle the packet?
- std::cerr << "Packet received that could not be processed: " << e.what() << std::endl;
- }
- catch (const armnn::RuntimeException& e)
- {
- // A runtime exception occurred which means we must exit the loop.
- std::cerr << "Receive thread closing: " << e.what() << std::endl;
- m_CloseReceivingThread.store(true);
- }
- }
-}
-
-armnn::profiling::Packet GatordMockService::WaitForPacket(uint32_t timeoutMs)
-{
- // Is there currently more than a headers worth of data waiting to be read?
- int bytes_available;
- Sockets::Ioctl(m_ClientConnection, FIONREAD, &bytes_available);
- if (bytes_available > 8)
- {
- // Yes there is. Read it:
- return ReceivePacket();
- }
- else
- {
- // No there's not. Poll for more data.
- struct pollfd pollingFd[1]{};
- pollingFd[0].fd = m_ClientConnection;
- int pollResult = Sockets::Poll(pollingFd, 1, static_cast<int>(timeoutMs));
-
- switch (pollResult)
- {
- // Error
- case -1:
- throw armnn::RuntimeException(std::string("File descriptor reported an error during polling: ") +
- strerror(errno));
-
- // Timeout
- case 0:
- throw armnn::TimeoutException("Timeout while waiting to receive packet.");
-
- // Normal poll return. It could still contain an error signal
- default:
- // Check if the socket reported an error
- if (pollingFd[0].revents & (POLLNVAL | POLLERR | POLLHUP))
- {
- if (pollingFd[0].revents == POLLNVAL)
- {
- throw armnn::RuntimeException(std::string("Error while polling receiving socket: POLLNVAL"));
- }
- if (pollingFd[0].revents == POLLERR)
- {
- throw armnn::RuntimeException(std::string("Error while polling receiving socket: POLLERR: ") +
- strerror(errno));
- }
- if (pollingFd[0].revents == POLLHUP)
- {
- throw armnn::RuntimeException(std::string("Connection closed by remote client: POLLHUP"));
- }
- }
-
- // Check if there is data to read
- if (!(pollingFd[0].revents & (POLLIN)))
- {
- // This is a corner case. The socket as been woken up but not with any data.
- // We'll throw a timeout exception to loop around again.
- throw armnn::TimeoutException("File descriptor was polled but no data was available to receive.");
- }
- return ReceivePacket();
- }
- }
-}
-
-armnn::profiling::Packet GatordMockService::ReceivePacket()
-{
- uint32_t header[2];
- if (!ReadHeader(header))
- {
- return armnn::profiling::Packet();
- }
- // Read data_length bytes from the socket.
- std::unique_ptr<unsigned char[]> uniquePacketData = std::make_unique<unsigned char[]>(header[1]);
- unsigned char* packetData = reinterpret_cast<unsigned char*>(uniquePacketData.get());
-
- if (!ReadFromSocket(packetData, header[1]))
- {
- return armnn::profiling::Packet();
- }
-
- EchoPacket(PacketDirection::ReceivedData, packetData, header[1]);
-
- // Construct received packet
- armnn::profiling::PacketVersionResolver packetVersionResolver;
- armnn::profiling::Packet packetRx = armnn::profiling::Packet(header[0], header[1], uniquePacketData);
- if (m_EchoPackets)
- {
- std::cout << "Processing packet ID= " << packetRx.GetPacketId() << " Length=" << packetRx.GetLength()
- << std::endl;
- }
-
- profiling::Version version =
- packetVersionResolver.ResolvePacketVersion(packetRx.GetPacketFamily(), packetRx.GetPacketId());
-
- profiling::CommandHandlerFunctor* commandHandlerFunctor =
- m_HandlerRegistry.GetFunctor(packetRx.GetPacketFamily(), packetRx.GetPacketId(), version.GetEncodedValue());
- BOOST_ASSERT(commandHandlerFunctor);
- commandHandlerFunctor->operator()(packetRx);
- return packetRx;
-}
-
-bool GatordMockService::SendPacket(uint32_t packetFamily, uint32_t packetId, const uint8_t* data, uint32_t dataLength)
-{
- // Construct a packet from the id and data given and send it to the client.
- // Encode the header.
- uint32_t header[2];
- header[0] = packetFamily << 26 | packetId << 16;
- header[1] = dataLength;
- // Add the header to the packet.
- std::vector<uint8_t> packet(8 + dataLength);
- InsertU32(header[0], packet.data(), m_Endianness);
- InsertU32(header[1], packet.data() + 4, m_Endianness);
- // And the rest of the data if there is any.
- if (dataLength > 0)
- {
- memcpy((packet.data() + 8), data, dataLength);
- }
- EchoPacket(PacketDirection::Sending, packet.data(), packet.size());
- if (-1 == Sockets::Write(m_ClientConnection, packet.data(), packet.size()))
- {
- std::cerr << ": Failure when writing to client socket: " << strerror(errno) << std::endl;
- return false;
- }
- return true;
-}
-
-bool GatordMockService::ReadHeader(uint32_t headerAsWords[2])
-{
- // The header will always be 2x32bit words.
- uint8_t header[8];
- if (!ReadFromSocket(header, 8))
- {
- return false;
- }
- EchoPacket(PacketDirection::ReceivedHeader, header, 8);
- headerAsWords[0] = ToUint32(&header[0], m_Endianness);
- headerAsWords[1] = ToUint32(&header[4], m_Endianness);
- return true;
-}
-
-bool GatordMockService::ReadFromSocket(uint8_t* packetData, uint32_t expectedLength)
-{
- // This is a blocking read until either expectedLength has been received or an error is detected.
- long totalBytesRead = 0;
- while (boost::numeric_cast<uint32_t>(totalBytesRead) < expectedLength)
- {
- long bytesRead = Sockets::Read(m_ClientConnection, packetData, expectedLength);
- if (bytesRead < 0)
- {
- std::cerr << ": Failure when reading from client socket: " << strerror(errno) << std::endl;
- return false;
- }
- if (bytesRead == 0)
- {
- std::cerr << ": EOF while reading from client socket." << std::endl;
- return false;
- }
- totalBytesRead += bytesRead;
- }
- return true;
-};
-
-void GatordMockService::EchoPacket(PacketDirection direction, uint8_t* packet, size_t lengthInBytes)
-{
- // If enabled print the contents of the data packet to the console.
- if (m_EchoPackets)
- {
- if (direction == PacketDirection::Sending)
- {
- std::cout << "TX " << std::dec << lengthInBytes << " bytes : ";
- }
- else if (direction == PacketDirection::ReceivedHeader)
- {
- std::cout << "RX Header " << std::dec << lengthInBytes << " bytes : ";
- }
- else
- {
- std::cout << "RX Data " << std::dec << lengthInBytes << " bytes : ";
- }
- for (unsigned int i = 0; i < lengthInBytes; i++)
- {
- if ((i % 10) == 0)
- {
- std::cout << std::endl;
- }
- std::cout << "0x" << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned int>(packet[i])
- << " ";
- }
- std::cout << std::endl;
- }
-}
-
-uint32_t GatordMockService::ToUint32(uint8_t* data, TargetEndianness endianness)
-{
- // Extract the first 4 bytes starting at data and push them into a 32bit integer based on the
- // specified endianness.
- if (endianness == TargetEndianness::BeWire)
- {
- return static_cast<uint32_t>(data[0]) << 24 | static_cast<uint32_t>(data[1]) << 16 |
- static_cast<uint32_t>(data[2]) << 8 | static_cast<uint32_t>(data[3]);
- }
- else
- {
- return static_cast<uint32_t>(data[3]) << 24 | static_cast<uint32_t>(data[2]) << 16 |
- static_cast<uint32_t>(data[1]) << 8 | static_cast<uint32_t>(data[0]);
- }
-}
-
-void GatordMockService::InsertU32(uint32_t value, uint8_t* data, TargetEndianness endianness)
-{
- // Take the bytes of a 32bit integer and copy them into char array starting at data considering
- // the endianness value.
- if (endianness == TargetEndianness::BeWire)
- {
- *data = static_cast<uint8_t>((value >> 24) & 0xFF);
- *(data + 1) = static_cast<uint8_t>((value >> 16) & 0xFF);
- *(data + 2) = static_cast<uint8_t>((value >> 8) & 0xFF);
- *(data + 3) = static_cast<uint8_t>(value & 0xFF);
- }
- else
- {
- *(data + 3) = static_cast<uint8_t>((value >> 24) & 0xFF);
- *(data + 2) = static_cast<uint8_t>((value >> 16) & 0xFF);
- *(data + 1) = static_cast<uint8_t>((value >> 8) & 0xFF);
- *data = static_cast<uint8_t>(value & 0xFF);
- }
-}
-
-} // namespace gatordmock
-
-} // namespace armnn
diff --git a/tests/profiling/gatordmock/GatordMockService.hpp b/tests/profiling/gatordmock/GatordMockService.hpp
deleted file mode 100644
index f91e902db8..0000000000
--- a/tests/profiling/gatordmock/GatordMockService.hpp
+++ /dev/null
@@ -1,158 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include <CommandHandlerRegistry.hpp>
-#include <Packet.hpp>
-#include <NetworkSockets.hpp>
-
-#include <atomic>
-#include <string>
-#include <thread>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-enum class TargetEndianness
-{
- BeWire,
- LeWire
-};
-
-enum class PacketDirection
-{
- Sending,
- ReceivedHeader,
- ReceivedData
-};
-
-/// A class that implements a Mock Gatord server. It will listen on a specified Unix domain socket (UDS)
-/// namespace for client connections. It will then allow opertaions to manage coutners while receiving counter data.
-class GatordMockService
-{
-public:
- /// @param registry reference to a command handler registry.
- /// @param echoPackets if true the raw packets will be printed to stdout.
- GatordMockService(armnn::profiling::CommandHandlerRegistry& registry, bool echoPackets)
- : m_HandlerRegistry(registry)
- , m_EchoPackets(echoPackets)
- , m_CloseReceivingThread(false)
- {
- m_PacketsReceivedCount.store(0, std::memory_order_relaxed);
- }
-
- ~GatordMockService()
- {
- // We have set SOCK_CLOEXEC on these sockets but we'll close them to be good citizens.
- armnnUtils::Sockets::Close(m_ClientConnection);
- armnnUtils::Sockets::Close(m_ListeningSocket);
- }
-
- /// Establish the Unix domain socket and set it to listen for connections.
- /// @param udsNamespace the namespace (socket address) associated with the listener.
- /// @return true only if the socket has been correctly setup.
- bool OpenListeningSocket(std::string udsNamespace);
-
- /// Block waiting to accept one client to connect to the UDS.
- /// @return the file descriptor of the client connection.
- armnnUtils::Sockets::Socket BlockForOneClient();
-
- /// Once the connection is open wait to receive the stream meta data packet from the client. Reading this
- /// packet differs from others as we need to determine endianness.
- /// @return true only if a valid stream met data packet has been received.
- bool WaitForStreamMetaData();
-
- /// Send a connection acknowledged packet back to the client.
- void SendConnectionAck();
-
- /// Send a request counter directory packet back to the client.
- void SendRequestCounterDir();
-
- /// Start the thread that will receive all packets and print them nicely to stdout.
- bool LaunchReceivingThread();
-
- /// Return the total number of periodic counter capture packets received since the receive thread started.
- /// @return number of periodic counter capture packets received.
- uint32_t GetPacketsReceivedCount()
- {
- return m_PacketsReceivedCount.load(std::memory_order_acquire);
- }
-
- /// This is a placeholder method to prevent main exiting. It can be removed once the
- /// command handling code is added.
- void WaitForReceivingThread();
-
- // @return true only if the receive thread is closed or closing.
- bool ReceiveThreadRunning()
- {
- return !m_CloseReceivingThread.load();
- }
-
- /// Send the counter list to ArmNN.
- void SendPeriodicCounterSelectionList(uint32_t period, std::vector<uint16_t> counters);
-
- /// Execute the WAIT command from the comamnd file.
- void WaitCommand(uint32_t timeout);
-
- uint32_t GetStreamMetadataVersion()
- {
- return m_StreamMetaDataVersion;
- }
-
- uint32_t GetStreamMetadataMaxDataLen()
- {
- return m_StreamMetaDataMaxDataLen;
- }
-
- uint32_t GetStreamMetadataPid()
- {
- return m_StreamMetaDataPid;
- }
-
-private:
- void ReceiveLoop(GatordMockService& mockService);
-
- /// Block on the client connection until a complete packet has been received. This is a placeholder function to
- /// enable early testing of the tool.
- /// @return true if a valid packet has been received.
- armnn::profiling::Packet WaitForPacket(uint32_t timeoutMs);
-
- armnn::profiling::Packet ReceivePacket();
-
- bool SendPacket(uint32_t packetFamily, uint32_t packetId, const uint8_t* data, uint32_t dataLength);
-
- void EchoPacket(PacketDirection direction, uint8_t* packet, size_t lengthInBytes);
-
- bool ReadHeader(uint32_t headerAsWords[2]);
-
- bool ReadFromSocket(uint8_t* packetData, uint32_t expectedLength);
-
- uint32_t ToUint32(uint8_t* data, TargetEndianness endianness);
-
- void InsertU32(uint32_t value, uint8_t* data, TargetEndianness endianness);
-
- static const uint32_t PIPE_MAGIC = 0x45495434;
-
- std::atomic<uint32_t> m_PacketsReceivedCount;
- TargetEndianness m_Endianness;
- uint32_t m_StreamMetaDataVersion;
- uint32_t m_StreamMetaDataMaxDataLen;
- uint32_t m_StreamMetaDataPid;
-
- armnn::profiling::CommandHandlerRegistry& m_HandlerRegistry;
-
- bool m_EchoPackets;
- armnnUtils::Sockets::Socket m_ListeningSocket;
- armnnUtils::Sockets::Socket m_ClientConnection;
- std::thread m_ListeningThread;
- std::atomic<bool> m_CloseReceivingThread;
-};
-} // namespace gatordmock
-
-} // namespace armnn
diff --git a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp b/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp
deleted file mode 100644
index 9dd7064c90..0000000000
--- a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "PeriodicCounterCaptureCommandHandler.hpp"
-
-#include <ProfilingUtils.hpp>
-
-#include <boost/numeric/conversion/cast.hpp>
-
-#include <iostream>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-using boost::numeric_cast;
-
-void PeriodicCounterCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet)
-{
- std::vector<uint16_t> counterIds;
- std::vector<uint32_t> counterValues;
-
- uint32_t sizeOfUint64 = numeric_cast<uint32_t>(sizeof(uint64_t));
- uint32_t sizeOfUint32 = numeric_cast<uint32_t>(sizeof(uint32_t));
- uint32_t sizeOfUint16 = numeric_cast<uint32_t>(sizeof(uint16_t));
-
- uint32_t offset = 0;
-
- if (packet.GetLength() >= 8)
- {
- offset = 0;
-
- uint64_t timestamp = profiling::ReadUint64(reinterpret_cast<const unsigned char*>(packet.GetData()), offset);
-
- if (m_FirstTimestamp == 0) // detect the first timestamp we receive.
- {
- m_FirstTimestamp = timestamp;
- }
- else
- {
- m_SecondTimestamp = timestamp;
- m_CurrentPeriodValue = m_SecondTimestamp - m_FirstTimestamp;
- m_FirstTimestamp = m_SecondTimestamp;
- }
-
- // Length minus timestamp and header divided by the length of an indexPair
- unsigned int counters = (packet.GetLength() - 8) / 6;
-
- if (counters > 0)
- {
- counterIds.reserve(counters);
- counterValues.reserve(counters);
- // Move offset over timestamp area
- offset += sizeOfUint64;
- for (unsigned int pos = 0; pos < counters; ++pos)
- {
- counterIds.emplace_back(
- profiling::ReadUint16(reinterpret_cast<const unsigned char*>(packet.GetData()), offset));
- offset += sizeOfUint16;
-
- counterValues.emplace_back(
- profiling::ReadUint32(reinterpret_cast<const unsigned char*>(packet.GetData()), offset));
- offset += sizeOfUint32;
- }
- }
-
- m_CounterCaptureValues.m_Timestamp = timestamp;
- m_CounterCaptureValues.m_Uids = counterIds;
- m_CounterCaptureValues.m_Values = counterValues;
- }
-}
-
-void PeriodicCounterCaptureCommandHandler::operator()(const profiling::Packet& packet)
-{
- ParseData(packet);
- if (!m_QuietOperation) // Are we supposed to print to stdout?
- {
- std::string header, body, uidString, valueString;
-
- for (uint16_t uid : m_CounterCaptureValues.m_Uids)
- {
- uidString.append(std::to_string(uid));
- uidString.append(", ");
- }
-
- for (uint32_t val : m_CounterCaptureValues.m_Values)
- {
- valueString.append(std::to_string(val));
- valueString.append(", ");
- }
-
- body.append(profiling::CentreAlignFormatting(std::to_string(m_CounterCaptureValues.m_Timestamp), 10));
- body.append(" | ");
- body.append(profiling::CentreAlignFormatting(std::to_string(m_CurrentPeriodValue), 13));
- body.append(" | ");
- body.append(profiling::CentreAlignFormatting(uidString, 10));
- body.append(" | ");
- body.append(profiling::CentreAlignFormatting(valueString, 10));
- body.append("\n");
-
- if (!m_HeaderPrinted)
- {
- header.append(profiling::CentreAlignFormatting(" Timestamp", 11));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("Period (us)", 13));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("UID's", static_cast<int>(uidString.size())));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("Values", 10));
- header.append("\n");
-
- std::cout << header;
- m_HeaderPrinted = true;
- }
-
- std::cout << std::string(body.size(), '-') << "\n";
-
- std::cout << body;
- }
-}
-
-} // namespace gatordmock
-
-} // namespace armnn
diff --git a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp b/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp
deleted file mode 100644
index 478d0a6ca9..0000000000
--- a/tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include <Packet.hpp>
-#include <CommandHandlerFunctor.hpp>
-
-#include <vector>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-struct CounterCaptureValues
-{
- uint64_t m_Timestamp;
- std::vector<uint16_t> m_Uids;
- std::vector<uint32_t> m_Values;
-};
-
-class PeriodicCounterCaptureCommandHandler : public profiling::CommandHandlerFunctor
-{
-
-public:
- /**
- * @param familyId The family of the packets this handler will service
- * @param packetId The id of packets this handler will process.
- * @param version The version of that id.
- * @param quietOperation Optional parameter to turn off printouts. This is useful for unittests.
- */
- PeriodicCounterCaptureCommandHandler(uint32_t familyId,
- uint32_t packetId,
- uint32_t version,
- bool quietOperation = false)
- : CommandHandlerFunctor(familyId, packetId, version)
- , m_QuietOperation(quietOperation)
- {}
-
- void operator()(const armnn::profiling::Packet& packet) override;
-
- CounterCaptureValues m_CounterCaptureValues;
-
- uint64_t m_CurrentPeriodValue = 0;
-
-private:
- void ParseData(const armnn::profiling::Packet& packet);
-
- uint64_t m_FirstTimestamp = 0, m_SecondTimestamp = 0;
-
- bool m_HeaderPrinted = false;
- bool m_QuietOperation;
-};
-
-} // namespace gatordmock
-
-} // namespace armnn
diff --git a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp b/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp
deleted file mode 100644
index 645b0b3507..0000000000
--- a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "PeriodicCounterSelectionResponseHandler.hpp"
-
-#include "../../../src/profiling/ProfilingUtils.hpp"
-
-#include <iostream>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-void PeriodicCounterSelectionResponseHandler::operator()(const profiling::Packet& packet)
-{
- if (!m_QuietOperation) // Are we supposed to print to stdout?
- {
- uint32_t period = profiling::ReadUint32(reinterpret_cast<const unsigned char*>(packet.GetData()), 0);
- uint32_t numCounters = 0;
- // First check if there are any counters mentioned.
- if(packet.GetLength() > 4)
- {
- // Length will be 4 bytes for the period and then a list of 16 bit UIDS.
- numCounters = ((packet.GetLength() - 4) / 2);
- }
- std::cout << "PeriodicCounterSelectionResponse: Collection interval = " << std::dec << period << "uSec"
- << " Num counters activated = " << numCounters << std::endl;
- }
-}
-
-} // namespace gatordmock
-
-} // namespace armnn \ No newline at end of file
diff --git a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp b/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
deleted file mode 100644
index 6b82280e81..0000000000
--- a/tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <CommandHandlerFunctor.hpp>
-#include <Packet.hpp>
-
-#include <vector>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-#pragma once
-
-class PeriodicCounterSelectionResponseHandler : public profiling::CommandHandlerFunctor
-{
-
-public:
- /**
- *
- * @param packetId The id of packets this handler will process.
- * @param version The version of that id.
- * @param quietOperation Optional parameter to turn off printouts. This is useful for unittests.
- */
- PeriodicCounterSelectionResponseHandler(uint32_t familyId,
- uint32_t packetId,
- uint32_t version,
- bool quietOperation = true)
- : CommandHandlerFunctor(familyId, packetId, version)
- , m_QuietOperation(quietOperation)
- {}
-
- void operator()(const armnn::profiling::Packet& packet) override;
-
-private:
- bool m_QuietOperation;
-};
-
-} // namespace gatordmock
-
-} // namespace armnn \ No newline at end of file
diff --git a/tests/profiling/gatordmock/StreamMetadataCommandHandler.cpp b/tests/profiling/gatordmock/StreamMetadataCommandHandler.cpp
deleted file mode 100644
index 09255a57a1..0000000000
--- a/tests/profiling/gatordmock/StreamMetadataCommandHandler.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "StreamMetadataCommandHandler.hpp"
-
-#include <ProfilingUtils.hpp>
-
-#include <boost/cast.hpp>
-
-#include <sstream>
-#include <iostream>
-
-using namespace armnn::profiling;
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-void StreamMetadataCommandHandler::operator()(const Packet& packet)
-{
- ParseData(packet);
-
- if (m_QuietOperation)
- {
- return;
- }
-
- std::stringstream ss;
-
- ss << "Stream metadata packet received" << std::endl << std::endl;
-
- ss << "Pipe magic: " << m_PipeMagic << std::endl;
- ss << "Stream metadata version: " << m_StreamMetadataVersion << std::endl;
- ss << "Max data len: " << m_MaxDataLen << std::endl;
- ss << "Pid: " << m_Pid << std::endl;
- ss << "Software info: " << m_SoftwareInfo << std::endl;
- ss << "Hardware version: " << m_HardwareVersion << std::endl;
- ss << "Software version: " << m_SoftwareVersion << std::endl;
- ss << "Process name: " << m_ProcessName << std::endl;
- ss << "Packet versions: " << m_PacketVersionTable.size() << std::endl;
-
- for (const auto& packetVersion : m_PacketVersionTable)
- {
- ss << "-----------------------" << std::endl;
- ss << "Packet family: " << packetVersion.m_PacketFamily << std::endl;
- ss << "Packet id: " << packetVersion.m_PacketId << std::endl;
- ss << "Packet version: " << packetVersion.m_PacketVersion << std::endl;
- }
-
- std::cout << ss.str() << std::endl;
-}
-
-std::string ReadString(const unsigned char* buffer, unsigned int &offset)
-{
- const char* stringPtr = reinterpret_cast<const char*>(&buffer[offset]);
- return stringPtr != nullptr ? std::string(stringPtr) : "";
-}
-
-void StreamMetadataCommandHandler::ParseData(const Packet &packet)
-{
- // Check that at least the packet contains the fixed-length fields
- if (packet.GetLength() < 80)
- {
- return;
- }
-
- // Utils
- unsigned int uint16_t_size = sizeof(uint16_t);
- unsigned int uint32_t_size = sizeof(uint32_t);
-
- const unsigned char* buffer = packet.GetData();
- unsigned int offset = 0;
-
- // Get the fixed-length fields
- m_PipeMagic = ReadUint32(buffer, offset);
- offset += uint32_t_size;
- m_StreamMetadataVersion = ReadUint32(buffer, offset);
- offset += uint32_t_size;
- m_MaxDataLen = ReadUint32(buffer, offset);
- offset += uint32_t_size;
- m_Pid = ReadUint32(buffer, offset);
- offset += uint32_t_size;
- m_OffsetInfo = ReadUint32(buffer, offset);
- offset += uint32_t_size;
- m_OffsetHwVersion = ReadUint32(buffer, offset);
- offset += uint32_t_size;
- m_OffsetSwVersion = ReadUint32(buffer, offset);
- offset += uint32_t_size;
- m_OffsetProcessName = ReadUint32(buffer, offset);
- offset += uint32_t_size;
- m_OffsetPacketVersionTable = ReadUint32(buffer, offset);
- offset += uint32_t_size * 2; // Also skipping the reserved word (all zeros)
-
- // Get the string fields
- m_SoftwareInfo = m_OffsetInfo > 0 ? ReadString(buffer, m_OffsetInfo) : "";
- m_HardwareVersion = m_OffsetHwVersion > 0 ? ReadString(buffer, m_OffsetHwVersion) : "";
- m_SoftwareVersion = m_OffsetSwVersion > 0 ? ReadString(buffer, m_OffsetSwVersion) : "";
- m_ProcessName = m_OffsetProcessName > 0 ? ReadString(buffer, m_OffsetProcessName) : "";
-
- // Get the packet versions
- m_PacketVersionTable.clear();
- if (m_OffsetPacketVersionTable > 0)
- {
- offset = m_OffsetPacketVersionTable;
- uint16_t packetEntries = ReadUint16(buffer, offset + uint16_t_size);
- offset += uint32_t_size; // Also skipping the reserved bytes (all zeros)
- for (uint16_t i = 0; i < packetEntries; i++)
- {
- uint16_t packetFamilyAndId = ReadUint16(buffer, offset + uint16_t_size);
- uint16_t packetFamily = (packetFamilyAndId >> 10) & 0x003F;
- uint16_t packetId = (packetFamilyAndId >> 0) & 0x03FF;
- offset += uint32_t_size; // Also skipping the reserved bytes (all zeros)
- uint32_t packetVersion = ReadUint32(buffer, offset);
- offset += uint32_t_size;
-
- m_PacketVersionTable.push_back({ packetFamily, packetId, packetVersion });
- }
- }
-}
-
-} // namespace gatordmock
-
-} // namespace armnn
diff --git a/tests/profiling/gatordmock/StreamMetadataCommandHandler.hpp b/tests/profiling/gatordmock/StreamMetadataCommandHandler.hpp
deleted file mode 100644
index 4558345e67..0000000000
--- a/tests/profiling/gatordmock/StreamMetadataCommandHandler.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include <Packet.hpp>
-#include <CommandHandlerFunctor.hpp>
-
-#include <vector>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-struct PacketVersion
-{
- uint16_t m_PacketFamily;
- uint16_t m_PacketId;
- uint32_t m_PacketVersion;
-};
-
-class StreamMetadataCommandHandler : public profiling::CommandHandlerFunctor
-{
-
-public:
- /**
- * @param familyId The family of the packets this handler will service
- * @param packetId The id of packets this handler will process
- * @param version The version of that id
- * @param quietOperation Optional parameter to turn off printouts. This is useful for unit tests
- */
- StreamMetadataCommandHandler(uint32_t familyId,
- uint32_t packetId,
- uint32_t version,
- bool quietOperation = false)
- : CommandHandlerFunctor(familyId, packetId, version)
- , m_QuietOperation(quietOperation)
- {}
-
- void operator()(const armnn::profiling::Packet& packet) override;
-
-private:
- void ParseData(const armnn::profiling::Packet& packet);
-
- uint32_t m_PipeMagic;
- uint32_t m_StreamMetadataVersion;
- uint32_t m_MaxDataLen;
- uint32_t m_Pid;
- uint32_t m_OffsetInfo;
- uint32_t m_OffsetHwVersion;
- uint32_t m_OffsetSwVersion;
- uint32_t m_OffsetProcessName;
- uint32_t m_OffsetPacketVersionTable;
-
- std::string m_SoftwareInfo;
- std::string m_HardwareVersion;
- std::string m_SoftwareVersion;
- std::string m_ProcessName;
-
- std::vector<PacketVersion> m_PacketVersionTable;
-
- bool m_QuietOperation;
-};
-
-} // namespace gatordmock
-
-} // namespace armnn
diff --git a/tests/profiling/gatordmock/tests/GatordMockTests.cpp b/tests/profiling/gatordmock/tests/GatordMockTests.cpp
deleted file mode 100644
index 02adffb2cc..0000000000
--- a/tests/profiling/gatordmock/tests/GatordMockTests.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <CommandHandlerRegistry.hpp>
-#include <DirectoryCaptureCommandHandler.hpp>
-#include <ProfilingService.hpp>
-#include <GatordMockService.hpp>
-#include <PeriodicCounterCaptureCommandHandler.hpp>
-#include <StreamMetadataCommandHandler.hpp>
-#include <TimelineDirectoryCaptureCommandHandler.hpp>
-
-#include <test/ProfilingMocks.hpp>
-
-#include <boost/cast.hpp>
-#include <boost/test/test_tools.hpp>
-#include <boost/test/unit_test_suite.hpp>
-
-BOOST_AUTO_TEST_SUITE(GatordMockTests)
-
-using namespace armnn;
-using namespace std::this_thread; // sleep_for, sleep_until
-using namespace std::chrono_literals;
-
-BOOST_AUTO_TEST_CASE(CounterCaptureHandlingTest)
-{
- using boost::numeric_cast;
-
- profiling::PacketVersionResolver packetVersionResolver;
-
- // Data with timestamp, counter idx & counter values
- std::vector<std::pair<uint16_t, uint32_t>> indexValuePairs;
- indexValuePairs.reserve(5);
- indexValuePairs.emplace_back(std::make_pair<uint16_t, uint32_t>(0, 100));
- indexValuePairs.emplace_back(std::make_pair<uint16_t, uint32_t>(1, 200));
- indexValuePairs.emplace_back(std::make_pair<uint16_t, uint32_t>(2, 300));
- indexValuePairs.emplace_back(std::make_pair<uint16_t, uint32_t>(3, 400));
- indexValuePairs.emplace_back(std::make_pair<uint16_t, uint32_t>(4, 500));
-
- // ((uint16_t (2 bytes) + uint32_t (4 bytes)) * 5) + word1 + word2
- uint32_t dataLength = 38;
-
- // Simulate two different packets incoming 500 ms apart
- uint64_t time = static_cast<uint64_t>(
- std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now().time_since_epoch())
- .count());
-
- uint64_t time2 = time + 5000;
-
- // UniqueData required for Packet class
- std::unique_ptr<unsigned char[]> uniqueData1 = std::make_unique<unsigned char[]>(dataLength);
- unsigned char* data1 = reinterpret_cast<unsigned char*>(uniqueData1.get());
-
- std::unique_ptr<unsigned char[]> uniqueData2 = std::make_unique<unsigned char[]>(dataLength);
- unsigned char* data2 = reinterpret_cast<unsigned char*>(uniqueData2.get());
-
- uint32_t sizeOfUint64 = numeric_cast<uint32_t>(sizeof(uint64_t));
- uint32_t sizeOfUint32 = numeric_cast<uint32_t>(sizeof(uint32_t));
- uint32_t sizeOfUint16 = numeric_cast<uint32_t>(sizeof(uint16_t));
- // Offset index to point to mem address
- uint32_t offset = 0;
-
- profiling::WriteUint64(data1, offset, time);
- offset += sizeOfUint64;
- for (const auto& pair : indexValuePairs)
- {
- profiling::WriteUint16(data1, offset, pair.first);
- offset += sizeOfUint16;
- profiling::WriteUint32(data1, offset, pair.second);
- offset += sizeOfUint32;
- }
-
- offset = 0;
-
- profiling::WriteUint64(data2, offset, time2);
- offset += sizeOfUint64;
- for (const auto& pair : indexValuePairs)
- {
- profiling::WriteUint16(data2, offset, pair.first);
- offset += sizeOfUint16;
- profiling::WriteUint32(data2, offset, pair.second);
- offset += sizeOfUint32;
- }
-
- uint32_t headerWord1 = packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue();
- // Create packet to send through to the command functor
- profiling::Packet packet1(headerWord1, dataLength, uniqueData1);
- profiling::Packet packet2(headerWord1, dataLength, uniqueData2);
-
- gatordmock::PeriodicCounterCaptureCommandHandler commandHandler(0, 4, headerWord1, true);
-
- // Simulate two separate packets coming in to calculate period
- commandHandler(packet1);
- commandHandler(packet2);
-
- BOOST_ASSERT(commandHandler.m_CurrentPeriodValue == 5000);
-
- for (size_t i = 0; i < commandHandler.m_CounterCaptureValues.m_Uids.size(); ++i)
- {
- BOOST_ASSERT(commandHandler.m_CounterCaptureValues.m_Uids[i] == i);
- }
-}
-
-BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd)
-{
- // The purpose of this test is to setup both sides of the profiling service and get to the point of receiving
- // performance data.
-
- //These variables are used to wait for the profiling service
- uint32_t timeout = 2000;
- uint32_t sleepTime = 50;
- uint32_t timeSlept = 0;
-
- profiling::PacketVersionResolver packetVersionResolver;
-
- // Create the Command Handler Registry
- profiling::CommandHandlerRegistry registry;
-
- // Update with derived functors
- gatordmock::StreamMetadataCommandHandler streamMetadataCommandHandler(
- 0, 0, packetVersionResolver.ResolvePacketVersion(0, 0).GetEncodedValue(), true);
-
- gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(
- 0, 4, packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(), true);
-
- profiling::DirectoryCaptureCommandHandler directoryCaptureCommandHandler(
- 0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), true);
-
- gatordmock::TimelineDirectoryCaptureCommandHandler timelineDirectoryCaptureCommandHandler(
- 1, 0, packetVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue(), true);
-
- // Register different derived functors
- registry.RegisterFunctor(&streamMetadataCommandHandler);
- registry.RegisterFunctor(&counterCaptureCommandHandler);
- registry.RegisterFunctor(&directoryCaptureCommandHandler);
- registry.RegisterFunctor(&timelineDirectoryCaptureCommandHandler);
- // Setup the mock service to bind to the UDS.
- std::string udsNamespace = "gatord_namespace";
- gatordmock::GatordMockService mockService(registry, false);
- mockService.OpenListeningSocket(udsNamespace);
-
- // Enable the profiling service.
- armnn::IRuntime::CreationOptions::ExternalProfilingOptions options;
- options.m_EnableProfiling = true;
- profiling::ProfilingService& profilingService = profiling::ProfilingService::Instance();
- profilingService.ResetExternalProfilingOptions(options, true);
-
- // Bring the profiling service to the "WaitingForAck" state
- BOOST_CHECK(profilingService.GetCurrentState() == profiling::ProfilingState::Uninitialised);
- profilingService.Update();
- BOOST_CHECK(profilingService.GetCurrentState() == profiling::ProfilingState::NotConnected);
- profilingService.Update();
-
- // Connect the profiling service to the mock Gatord.
- int clientFd = mockService.BlockForOneClient();
- if (-1 == clientFd)
- {
- BOOST_FAIL("Failed to connect client");
- }
-
- // Give the profiling service sending thread time start executing and send the stream metadata.
- while (profilingService.GetCurrentState() != profiling::ProfilingState::WaitingForAck)
- {
- if (timeSlept >= timeout)
- {
- BOOST_FAIL("Timeout: Profiling service did not switch to WaitingForAck state");
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
- timeSlept += sleepTime;
- }
-
- profilingService.Update();
- // Read the stream metadata on the mock side.
- if (!mockService.WaitForStreamMetaData())
- {
- BOOST_FAIL("Failed to receive StreamMetaData");
- }
- // Send Ack from GatorD
- mockService.SendConnectionAck();
-
- timeSlept = 0;
- while (profilingService.GetCurrentState() != profiling::ProfilingState::Active)
- {
- if (timeSlept >= timeout)
- {
- BOOST_FAIL("Timeout: Profiling service did not switch to Active state");
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
- timeSlept += sleepTime;
- }
-
- mockService.LaunchReceivingThread();
- // As part of the default startup of the profiling service a counter directory packet will be sent.
- timeSlept = 0;
- while (!directoryCaptureCommandHandler.ParsedCounterDirectory())
- {
- if (timeSlept >= timeout)
- {
- BOOST_FAIL("Timeout: MockGatord did not receive counter directory packet");
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
- timeSlept += sleepTime;
- }
-
- const profiling::ICounterDirectory& serviceCounterDirectory = profilingService.GetCounterDirectory();
- const profiling::ICounterDirectory& receivedCounterDirectory = directoryCaptureCommandHandler.GetCounterDirectory();
-
- // Compare thre basics of the counter directory from the service and the one we received over the wire.
- BOOST_ASSERT(serviceCounterDirectory.GetDeviceCount() == receivedCounterDirectory.GetDeviceCount());
- BOOST_ASSERT(serviceCounterDirectory.GetCounterSetCount() == receivedCounterDirectory.GetCounterSetCount());
- BOOST_ASSERT(serviceCounterDirectory.GetCategoryCount() == receivedCounterDirectory.GetCategoryCount());
- BOOST_ASSERT(serviceCounterDirectory.GetCounterCount() == receivedCounterDirectory.GetCounterCount());
-
- receivedCounterDirectory.GetDeviceCount();
- serviceCounterDirectory.GetDeviceCount();
-
- const profiling::Devices& serviceDevices = serviceCounterDirectory.GetDevices();
- for (auto& device : serviceDevices)
- {
- // Find the same device in the received counter directory.
- auto foundDevice = receivedCounterDirectory.GetDevices().find(device.second->m_Uid);
- BOOST_CHECK(foundDevice != receivedCounterDirectory.GetDevices().end());
- BOOST_CHECK(device.second->m_Name.compare((*foundDevice).second->m_Name) == 0);
- BOOST_CHECK(device.second->m_Cores == (*foundDevice).second->m_Cores);
- }
-
- const profiling::CounterSets& serviceCounterSets = serviceCounterDirectory.GetCounterSets();
- for (auto& counterSet : serviceCounterSets)
- {
- // Find the same counter set in the received counter directory.
- auto foundCounterSet = receivedCounterDirectory.GetCounterSets().find(counterSet.second->m_Uid);
- BOOST_CHECK(foundCounterSet != receivedCounterDirectory.GetCounterSets().end());
- BOOST_CHECK(counterSet.second->m_Name.compare((*foundCounterSet).second->m_Name) == 0);
- BOOST_CHECK(counterSet.second->m_Count == (*foundCounterSet).second->m_Count);
- }
-
- const profiling::Categories& serviceCategories = serviceCounterDirectory.GetCategories();
- for (auto& category : serviceCategories)
- {
- for (auto& receivedCategory : receivedCounterDirectory.GetCategories())
- {
- if (receivedCategory->m_Name.compare(category->m_Name) == 0)
- {
- // We've found the matching category.
- BOOST_CHECK(category->m_DeviceUid == receivedCategory->m_DeviceUid);
- BOOST_CHECK(category->m_CounterSetUid == receivedCategory->m_CounterSetUid);
- // Now look at the interiors of the counters. Start by sorting them.
- std::sort(category->m_Counters.begin(), category->m_Counters.end());
- std::sort(receivedCategory->m_Counters.begin(), receivedCategory->m_Counters.end());
- // When comparing uid's here we need to translate them.
- std::function<bool(const uint16_t&, const uint16_t&)> comparator =
- [&directoryCaptureCommandHandler](const uint16_t& first, const uint16_t& second) {
- uint16_t translated = directoryCaptureCommandHandler.TranslateUIDCopyToOriginal(second);
- if (translated == first)
- {
- return true;
- }
- return false;
- };
- // Then let vector == do the work.
- BOOST_CHECK(std::equal(category->m_Counters.begin(), category->m_Counters.end(),
- receivedCategory->m_Counters.begin(), comparator));
- break;
- }
- }
- }
-
- // Finally check the content of the counters.
- const profiling::Counters& receivedCounters = receivedCounterDirectory.GetCounters();
- for (auto& receivedCounter : receivedCounters)
- {
- // Translate the Uid and find the corresponding counter in the original counter directory.
- // Note we can't check m_MaxCounterUid here as it will likely differ between the two counter directories.
- uint16_t translated = directoryCaptureCommandHandler.TranslateUIDCopyToOriginal(receivedCounter.first);
- const profiling::Counter* serviceCounter = serviceCounterDirectory.GetCounter(translated);
- BOOST_CHECK(serviceCounter->m_DeviceUid == receivedCounter.second->m_DeviceUid);
- BOOST_CHECK(serviceCounter->m_Name.compare(receivedCounter.second->m_Name) == 0);
- BOOST_CHECK(serviceCounter->m_CounterSetUid == receivedCounter.second->m_CounterSetUid);
- BOOST_CHECK(serviceCounter->m_Multiplier == receivedCounter.second->m_Multiplier);
- BOOST_CHECK(serviceCounter->m_Interpolation == receivedCounter.second->m_Interpolation);
- BOOST_CHECK(serviceCounter->m_Class == receivedCounter.second->m_Class);
- BOOST_CHECK(serviceCounter->m_Units.compare(receivedCounter.second->m_Units) == 0);
- BOOST_CHECK(serviceCounter->m_Description.compare(receivedCounter.second->m_Description) == 0);
- }
-
- mockService.WaitForReceivingThread();
- options.m_EnableProfiling = false;
- profilingService.ResetExternalProfilingOptions(options, true);
-
- // Future tests here will add counters to the ProfilingService, increment values and examine
- // PeriodicCounterCapture data received. These are yet to be integrated.
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/profiling/timelineDecoder/ITimelineDecoder.h b/tests/profiling/timelineDecoder/ITimelineDecoder.h
deleted file mode 100644
index 65ec8bfa6e..0000000000
--- a/tests/profiling/timelineDecoder/ITimelineDecoder.h
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#ifndef ARMNN_ITIMELINEDECODER_H
-#define ARMNN_ITIMELINEDECODER_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "TimelineModel.h"
-
-typedef enum ErrorCode
-{
- ErrorCode_Success,
- ErrorCode_Fail
-} ErrorCode;
-
-ErrorCode CreateModel(Model** model);
-ErrorCode DestroyModel(Model** model);
-
-ErrorCode SetEntityCallback(OnNewEntityCallback cb, Model* model);
-ErrorCode SetEventClassCallback(OnNewEventClassCallback cb, Model* model);
-ErrorCode SetEventCallback(OnNewEventCallback cb, Model* model);
-ErrorCode SetLabelCallback(OnNewLabelCallback cb, Model* model);
-ErrorCode SetRelationshipCallback(OnNewRelationshipCallback cb, Model* model);
-
-ErrorCode CreateEntity(const Entity entity, Model* model);
-ErrorCode CreateEventClass(const EventClass eventClass, Model* model);
-ErrorCode CreateEvent(const Event event, Model* model);
-ErrorCode CreateLabel(const Label label, Model* model);
-ErrorCode CreateRelationship(const Relationship relationship, Model* model);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //ARMNN_ITIMELINEDECODER_H \ No newline at end of file
diff --git a/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.cpp b/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.cpp
deleted file mode 100644
index 78b1300ed3..0000000000
--- a/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "TimelineCaptureCommandHandler.hpp"
-
-#include <iostream>
-#include <string>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-//Array of member functions, the array index matches the decl_id
-const TimelineCaptureCommandHandler::ReadFunction TimelineCaptureCommandHandler::m_ReadFunctions[5]
-{
- &TimelineCaptureCommandHandler::ReadLabel, // Label decl_id = 0
- &TimelineCaptureCommandHandler::ReadEntity, // Entity decl_id = 1
- &TimelineCaptureCommandHandler::ReadEventClass, // EventClass decl_id = 2
- &TimelineCaptureCommandHandler::ReadRelationship, // Relationship decl_id = 3
- &TimelineCaptureCommandHandler::ReadEvent // Event decl_id = 4
-};
-
-void TimelineCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet)
-{
- uint32_t offset = 0;
-
- if (packet.GetLength() < 8)
- {
- return;
- }
-
- const unsigned char* data = reinterpret_cast<const unsigned char*>(packet.GetData());
-
- uint32_t declId = 0;
-
- declId = profiling::ReadUint32(data, offset);
- offset += uint32_t_size;
-
- (this->*m_ReadFunctions[declId])(data, offset);
-}
-
-void TimelineCaptureCommandHandler::ReadLabel(const unsigned char* data, uint32_t offset)
-{
- Label label;
- label.m_Guid = profiling::ReadUint64(data, offset);
- offset += uint64_t_size;
-
- uint32_t nameLength = profiling::ReadUint32(data, offset);
- offset += uint32_t_size;
-
- label.m_Name = new char[nameLength];
- for (uint32_t i = 0; i< nameLength; ++i)
- {
- label.m_Name[i] = static_cast<char>(profiling::ReadUint8(data, offset + i));
- }
-
- CreateLabel(label, m_Model);
-
- if (!m_QuietOperation)
- {
- printLabels();
- }
-}
-
-void TimelineCaptureCommandHandler::ReadEntity(const unsigned char* data, uint32_t offset)
-{
- Entity entity;
- entity.m_Guid = profiling::ReadUint64(data, offset);
-
- CreateEntity(entity, m_Model);
-
- if (!m_QuietOperation)
- {
- printEntities();
- }
-}
-
-void TimelineCaptureCommandHandler::ReadEventClass(const unsigned char* data, uint32_t offset)
-{
- EventClass eventClass;
- eventClass.m_Guid = profiling::ReadUint64(data, offset);
-
- CreateEventClass(eventClass, m_Model);
-
- if (!m_QuietOperation)
- {
- printEventClasses();
- }
-}
-
-void TimelineCaptureCommandHandler::ReadRelationship(const unsigned char* data, uint32_t offset)
-{
- Relationship relationship;
- relationship.m_RelationshipType = static_cast<RelationshipType>(profiling::ReadUint32(data, offset));
- offset += uint32_t_size;
-
- relationship.m_Guid = profiling::ReadUint64(data, offset);
- offset += uint64_t_size;
-
- relationship.m_HeadGuid = profiling::ReadUint64(data, offset);
- offset += uint64_t_size;
-
- relationship.m_TailGuid = profiling::ReadUint64(data, offset);
-
- CreateRelationship(relationship, m_Model);
-
- if (!m_QuietOperation)
- {
- printRelationships();
- }
-}
-
-
-
-void TimelineCaptureCommandHandler::ReadEvent(const unsigned char* data, uint32_t offset)
-{
- Event event;
- event.m_TimeStamp = profiling::ReadUint64(data, offset);
- offset += uint64_t_size;
-
- event.m_ThreadId = new uint8_t[threadId_size];
- profiling::ReadBytes(data, offset, threadId_size, event.m_ThreadId);
- offset += threadId_size;
-
- event.m_Guid = profiling::ReadUint64(data, offset);
-
- CreateEvent(event, m_Model);
-
- if (!m_QuietOperation)
- {
- printEvents();
- }
-}
-
-void TimelineCaptureCommandHandler::operator()(const profiling::Packet& packet)
-{
- ParseData(packet);
-}
-
-void TimelineCaptureCommandHandler::printLabels()
-{
- std::string header;
-
- header.append(profiling::CentreAlignFormatting("guid", 12));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("value", 30));
- header.append("\n");
-
- std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("LABELS", static_cast<int>(header.size()));
- std::cout << "\n";
- std::cout << std::string(header.size(), '=') << "\n";
- std::cout << header;
-
- for (uint32_t i = 0; i < m_Model->m_LabelCount; ++i)
- {
- std::string body;
-
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model->m_Labels[i]->m_Guid), 12));
- body.append(" | ");
- body.append(profiling::CentreAlignFormatting(m_Model->m_Labels[i]->m_Name, 30));
- body.append("\n");
-
- std::cout << std::string(body.size(), '-') << "\n";
- std::cout<< body;
- }
-}
-
-void TimelineCaptureCommandHandler::printEntities()
-{
- std::string header;
- header.append(profiling::CentreAlignFormatting("guid", 12));
- header.append("\n");
-
- std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("ENTITIES", static_cast<int>(header.size()));
- std::cout << "\n";
- std::cout << std::string(header.size(), '=') << "\n";
- std::cout << header;
-
- for (uint32_t i = 0; i < m_Model->m_EntityCount; ++i)
- {
- std::string body;
-
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model->m_Entities[i]->m_Guid), 12));
- body.append("\n");
-
- std::cout << std::string(body.size(), '-') << "\n";
- std::cout<< body;
- }
-}
-
-void TimelineCaptureCommandHandler::printEventClasses()
-{
- std::string header;
- header.append(profiling::CentreAlignFormatting("guid", 12));
- header.append("\n");
-
- std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("EVENT CLASSES", static_cast<int>(header.size()));
- std::cout << "\n";
- std::cout << std::string(header.size(), '=') << "\n";
- std::cout << header;
-
- for (uint32_t i = 0; i < m_Model->m_EventClassCount; ++i)
- {
- std::string body;
-
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model->m_EventClasses[i]->m_Guid), 12));
- body.append("\n");
-
- std::cout << std::string(body.size(), '-') << "\n";
- std::cout<< body;
- }
-}
-
-void TimelineCaptureCommandHandler::printRelationships()
-{
- std::string header;
- header.append(profiling::CentreAlignFormatting("relationshipType", 20));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("relationshipGuid", 20));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("headGuid", 12));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("tailGuid", 12));
- header.append("\n");
-
- std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("RELATIONSHIPS", static_cast<int>(header.size()));
- std::cout << "\n";
- std::cout << std::string(header.size(), '=') << "\n";
- std::cout << header;
-
- for (uint32_t i = 0; i < m_Model->m_RelationshipCount; ++i)
- {
- std::string body;
-
- body.append(
- profiling::CentreAlignFormatting(std::to_string(m_Model->m_Relationships[i]->m_RelationshipType), 20));
- body.append(" | ");
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model->m_Relationships[i]->m_Guid), 20));
- body.append(" | ");
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model->m_Relationships[i]->m_HeadGuid), 12));
- body.append(" | ");
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model->m_Relationships[i]->m_TailGuid), 12));
- body.append(" | ");
- body.append("\n");
-
- std::cout << std::string(body.size(), '-') << "\n";
- std::cout<< body;
- }
-}
-
-void TimelineCaptureCommandHandler::printEvents()
-{
- std::string header;
-
- header.append(profiling::CentreAlignFormatting("timestamp", 12));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("threadId", 12));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("eventGuid", 12));
- header.append("\n");
-
- std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("EVENTS", static_cast<int>(header.size()));
- std::cout << "\n";
- std::cout << std::string(header.size(), '=') << "\n";
- std::cout << header;
-
- for (uint32_t i = 0; i < m_Model->m_EventCount; ++i)
- {
- std::string body;
-
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model->m_Events[i]->m_TimeStamp), 12));
- body.append(" | ");
-
- std::string threadId;
- for(uint32_t j =0; j< threadId_size; j++)
- {
- threadId += static_cast<char>(m_Model->m_Events[i]->m_ThreadId[j]);
- }
- body.append(profiling::CentreAlignFormatting(threadId, 12));
- body.append(" | ");
- body.append(profiling::CentreAlignFormatting(std::to_string(m_Model->m_Events[i]->m_Guid), 12));
- body.append("\n");
-
- std::cout << std::string(body.size(), '-') << "\n";
- std::cout<< body;
- }
-}
-
-} //namespace gatordmock
-
-} //namespace armnn
diff --git a/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.hpp b/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.hpp
deleted file mode 100644
index 3f3240491f..0000000000
--- a/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include "ITimelineDecoder.h"
-
-#include <CommandHandlerFunctor.hpp>
-#include <Packet.hpp>
-#include <ProfilingUtils.hpp>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-class TimelineCaptureCommandHandler : public profiling::CommandHandlerFunctor
-{
- // Utils
- uint32_t uint32_t_size = sizeof(uint32_t);
- uint32_t uint64_t_size = sizeof(uint64_t);
- uint32_t threadId_size = sizeof(std::thread::id);
-
- using ReadFunction = void (TimelineCaptureCommandHandler::*)(const unsigned char*, uint32_t);
-
-public:
- TimelineCaptureCommandHandler(uint32_t familyId,
- uint32_t packetId,
- uint32_t version,
- Model* model,
- bool quietOperation = false)
- : CommandHandlerFunctor(familyId, packetId, version)
- , m_Model(model)
- , m_QuietOperation(quietOperation)
- {}
-
- void operator()(const armnn::profiling::Packet& packet) override;
-
- void ReadLabel(const unsigned char* data, uint32_t offset);
- void ReadEntity(const unsigned char* data, uint32_t offset);
- void ReadEventClass(const unsigned char* data, uint32_t offset);
- void ReadRelationship(const unsigned char* data, uint32_t offset);
- void ReadEvent(const unsigned char* data, uint32_t offset);
-
- void print();
-
-private:
- void ParseData(const armnn::profiling::Packet& packet);
-
- Model* m_Model;
- bool m_QuietOperation;
- static const ReadFunction m_ReadFunctions[];
-
- void printLabels();
- void printEntities();
- void printEventClasses();
- void printRelationships();
- void printEvents();
-};
-
-} //namespace gatordmock
-
-} //namespace armnn
diff --git a/tests/profiling/timelineDecoder/TimelineDecoder.cpp b/tests/profiling/timelineDecoder/TimelineDecoder.cpp
deleted file mode 100644
index b6f051b745..0000000000
--- a/tests/profiling/timelineDecoder/TimelineDecoder.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "ITimelineDecoder.h"
-
-ErrorCode CreateEntity(const Entity entity, Model* model)
-{
- if (model == nullptr || model->m_EntityCb == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
- model->m_EntityCb(entity, model);
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode CreateEventClass(const EventClass eventClass, Model* model)
-{
- if (model == nullptr || model->m_EventClassCb == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
- model->m_EventClassCb(eventClass, model);
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode CreateEvent(const Event event, Model* model)
-{
- if (model == nullptr || model->m_EventCb == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
- model->m_EventCb(event, model);
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode CreateLabel(const Label label, Model* model)
-{
- if (model == nullptr || model->m_LabelCb == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
- model->m_LabelCb(label, model);
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode CreateRelationship(Relationship relationship, Model* model)
-{
- if (model == nullptr || model->m_RelationshipCb == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
- model->m_RelationshipCb(relationship, model);
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode SetEntityCallback(OnNewEntityCallback cb, Model* model)
-{
- if (cb == nullptr || model == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
- model->m_EntityCb = cb;
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode SetEventClassCallback(OnNewEventClassCallback cb, Model* model)
-{
- if (cb == nullptr || model == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
- model->m_EventClassCb = cb;
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode SetEventCallback(OnNewEventCallback cb, Model* model)
-{
- if (cb == nullptr || model == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
- model->m_EventCb = cb;
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode SetLabelCallback(OnNewLabelCallback cb, Model* model)
-{
- if (cb == nullptr || model == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
- model->m_LabelCb = cb;
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode SetRelationshipCallback(OnNewRelationshipCallback cb, Model* model)
-{
- if (cb == nullptr || model == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
- model->m_RelationshipCb = cb;
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode CreateModel(Model** model)
-{
- Model* modelPtr = new Model;
-
- modelPtr->m_EntityCount = 0;
- modelPtr->m_EventClassCount = 0;
- modelPtr->m_EventCount = 0;
- modelPtr->m_LabelCount = 0;
- modelPtr->m_RelationshipCount = 0;
-
- *model = modelPtr;
- return ErrorCode::ErrorCode_Success;
-}
-
-ErrorCode DestroyModel(Model** model)
-{
- if (*model == nullptr)
- {
- return ErrorCode::ErrorCode_Fail;
- }
-
- Model* modelPtr = *model;
-
- for (uint32_t i = 0; i < modelPtr->m_EntityCount; ++i)
- {
- delete modelPtr->m_Entities[i];
- }
-
- for (uint32_t i = 0; i < modelPtr->m_EventClassCount; ++i)
- {
- delete modelPtr->m_EventClasses[i];
- }
-
- for (uint32_t i = 0; i < modelPtr->m_EventCount; ++i)
- {
- delete[] modelPtr->m_Events[i]->m_ThreadId;
- delete modelPtr->m_Events[i];
- }
-
- for (uint32_t i = 0; i < modelPtr->m_LabelCount; ++i)
- {
- delete[] modelPtr->m_Labels[i]->m_Name;
- delete modelPtr->m_Labels[i];
- }
-
- for (uint32_t i = 0; i < modelPtr->m_RelationshipCount; ++i)
- {
- delete modelPtr->m_Relationships[i];
- }
-
- delete[] modelPtr->m_Entities;
- delete[] modelPtr->m_EventClasses;
- delete[] modelPtr->m_Events;
- delete[] modelPtr->m_Labels;
- delete[] modelPtr->m_Relationships;
-
- delete modelPtr;
- return ErrorCode::ErrorCode_Success;
-} \ No newline at end of file
diff --git a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp b/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp
deleted file mode 100644
index f28c7b50bf..0000000000
--- a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "TimelineDirectoryCaptureCommandHandler.hpp"
-
-#include <ProfilingUtils.hpp>
-
-#include <iostream>
-#include <string>
-
-using namespace armnn::profiling;
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-void TimelineDirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet)
-{
- uint32_t offset = 0;
-
- if (packet.GetLength() < 8)
- {
- return;
- }
-
- const unsigned char* data = packet.GetData();
-
- m_SwTraceHeader.m_StreamVersion = ReadUint8(data, offset);
- offset += uint8_t_size;
- m_SwTraceHeader.m_PointerBytes = ReadUint8(data, offset);
- offset += uint8_t_size;
- m_SwTraceHeader.m_ThreadIdBytes = ReadUint8(data, offset);
- offset += uint8_t_size;
-
- uint32_t numberOfDeclarations = profiling::ReadUint32(data, offset);
- offset += uint32_t_size;
-
- for (uint32_t declaration = 0; declaration < numberOfDeclarations; ++declaration)
- {
- m_SwTraceMessages.push_back(profiling::ReadSwTraceMessage(data, offset));
- }
-}
-
-void TimelineDirectoryCaptureCommandHandler::Print()
-{
- std::string header;
-
- header.append(profiling::CentreAlignFormatting("decl_id", 12));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("decl_name", 20));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("ui_name", 20));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("arg_types", 16));
- header.append(" | ");
- header.append(profiling::CentreAlignFormatting("arg_names", 80));
- header.append("\n");
-
- std::cout << "\n" << "\n";
- std::cout << profiling::CentreAlignFormatting("SW DIRECTORY", static_cast<int>(header.size()));
- std::cout << "\n";
- std::cout << std::string(header.size(), '=') << "\n";
-
- std::cout << header;
-
- for (const auto& swTraceMessage : m_SwTraceMessages)
- {
- std::string body;
-
- body.append(profiling::CentreAlignFormatting(std::to_string(swTraceMessage.m_Id), 12));
- body.append(" | ");
- body.append(profiling::CentreAlignFormatting(swTraceMessage.m_Name, 20));
- body.append(" | ");
- body.append(profiling::CentreAlignFormatting(swTraceMessage.m_UiName, 20));
- body.append(" | ");
-
- std::string argTypes;
- for (auto argType: swTraceMessage.m_ArgTypes)
- {
- argTypes += argType;
- argTypes += " ";
- }
- body.append(profiling::CentreAlignFormatting(argTypes, 16));
- body.append(" | ");
-
- std::string argNames;
- for (auto argName: swTraceMessage.m_ArgNames)
- {
- argNames += argName + " ";
- }
- body.append(profiling::CentreAlignFormatting(argNames, 80));
-
- body.append("\n");
-
- std::cout << std::string(body.size(), '-') << "\n";
-
- std::cout << body;
- }
-}
-
-void TimelineDirectoryCaptureCommandHandler::operator()(const profiling::Packet& packet)
-{
- ParseData(packet);
-
- if (!m_QuietOperation)
- {
- Print();
- }
-}
-
-} //namespace gatordmock
-
-} //namespace armnn
diff --git a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp b/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp
deleted file mode 100644
index 36a82b5510..0000000000
--- a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-
-#include <CommandHandlerFunctor.hpp>
-#include <Packet.hpp>
-#include <PacketBuffer.hpp>
-#include <ProfilingUtils.hpp>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-class TimelineDirectoryCaptureCommandHandler : public profiling::CommandHandlerFunctor
-{
- // Utils
- uint32_t uint8_t_size = sizeof(uint8_t);
- uint32_t uint32_t_size = sizeof(uint32_t);
-
-public:
- TimelineDirectoryCaptureCommandHandler(uint32_t familyId,
- uint32_t packetId,
- uint32_t version,
- bool quietOperation = false)
- : CommandHandlerFunctor(familyId, packetId, version)
- , m_QuietOperation(quietOperation)
- {}
-
- void operator()(const armnn::profiling::Packet& packet) override;
-
- profiling::SwTraceHeader m_SwTraceHeader;
- std::vector<profiling::SwTraceMessage> m_SwTraceMessages;
-
-private:
- void ParseData(const armnn::profiling::Packet& packet);
- void Print();
-
- bool m_QuietOperation;
-};
-
-} //namespace gatordmock
-
-} //namespace armnn
diff --git a/tests/profiling/timelineDecoder/TimelineModel.h b/tests/profiling/timelineDecoder/TimelineModel.h
deleted file mode 100644
index a4fbd0dbde..0000000000
--- a/tests/profiling/timelineDecoder/TimelineModel.h
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#ifndef ARMNN_ITIMELINEMODEL_H
-#define ARMNN_ITIMELINEMODEL_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <stdint.h>
-
-struct Model;
-
-typedef enum RelationshipType
-{
- RetentionLink, /// Head retains(parents) Tail
- ExecutionLink, /// Head execution start depends on Tail execution completion
- DataLink, /// Head uses data of Tail
- LabelLink /// Head uses label Tail (Tail MUST be a guid of a label).
-} RelationshipType;
-
-typedef struct Entity
-{
- uint64_t m_Guid;
-} Entity;
-
-typedef struct EventClass
-{
- uint64_t m_Guid;
-} EventClass;
-
-typedef struct Event
-{
- uint64_t m_Guid;
- uint64_t m_TimeStamp;
- unsigned char* m_ThreadId;
-} ProfilingEvent;
-
-typedef struct Label
-{
- uint64_t m_Guid;
- char* m_Name;
-} Label;
-
-typedef struct Relationship
-{
- RelationshipType m_RelationshipType;
- uint64_t m_Guid;
- uint64_t m_HeadGuid;
- uint64_t m_TailGuid;
-} Relationship;
-
-typedef void (*OnNewEntityCallback)(const Entity, struct Model* model);
-typedef void (*OnNewEventClassCallback)(const EventClass, struct Model* model);
-typedef void (*OnNewEventCallback)(const Event, struct Model* model);
-typedef void (*OnNewLabelCallback)(const Label, struct Model* model);
-typedef void (*OnNewRelationshipCallback)(const Relationship, struct Model* model) ;
-
-typedef struct Model
-{
- OnNewEntityCallback m_EntityCb;
- OnNewEventClassCallback m_EventClassCb;
- OnNewEventCallback m_EventCb;
- OnNewLabelCallback m_LabelCb;
- OnNewRelationshipCallback m_RelationshipCb;
-
- Entity** m_Entities;
- EventClass** m_EventClasses;
- Event** m_Events;
- Label** m_Labels;
- Relationship** m_Relationships;
-
- uint32_t m_EntityCount;
- uint32_t m_EntityCapacity;
-
- uint32_t m_EventClassCount;
- uint32_t m_EventClassCapacity;
-
- uint32_t m_EventCount;
- uint32_t m_EventCapacity;
-
- uint32_t m_LabelCount;
- uint32_t m_LabelCapacity;
-
- uint32_t m_RelationshipCount;
- uint32_t m_RelationshipCapacity;
-} Model;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //ARMNN_ITIMELINEMODEL_H \ No newline at end of file
diff --git a/tests/profiling/timelineDecoder/tests/TimelineTestFunctions.hpp b/tests/profiling/timelineDecoder/tests/TimelineTestFunctions.hpp
deleted file mode 100644
index 3fd9d04dbc..0000000000
--- a/tests/profiling/timelineDecoder/tests/TimelineTestFunctions.hpp
+++ /dev/null
@@ -1,143 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <algorithm>
-#include "../TimelineModel.h"
-
-void PushEntity(const Entity entity, Model* model)
-{
- if(model->m_EntityCount == 0)
- {
- model->m_EntityCapacity = 1;
- model->m_Entities = new Entity*[model->m_EntityCapacity];
- }
- else if(model->m_EntityCount >= model->m_EntityCapacity)
- {
- Entity** newEntityArray = new Entity*[model->m_EntityCapacity*2];
-
- std::copy(model->m_Entities, model->m_Entities + model->m_EntityCapacity, newEntityArray);
- delete[] model->m_Entities;
- model->m_Entities = newEntityArray;
-
- model->m_EntityCapacity = model->m_EntityCapacity *2;
- }
-
- Entity* newEntity = new Entity;
-
- newEntity->m_Guid = entity.m_Guid;
-
- model->m_Entities[model->m_EntityCount] = newEntity;
- model->m_EntityCount++;
-};
-
-void PushEventClass(const EventClass eventClass, Model* model)
-{
- if(model->m_EventClassCount == 0)
- {
- model->m_EventClassCapacity = 1;
- model->m_EventClasses = new EventClass*[model->m_EventClassCapacity];
- }
- else if(model->m_EventClassCount >= model->m_EventClassCapacity)
- {
- EventClass** newEventClassArray = new EventClass*[model->m_EventClassCapacity *2];
-
- std::copy(model->m_EventClasses, model->m_EventClasses + model->m_EventClassCapacity, newEventClassArray);
- delete[] model->m_EventClasses;
- model->m_EventClasses = newEventClassArray;
-
- model->m_EventClassCapacity = model->m_EventClassCapacity *2;
- }
-
- EventClass* newEventClass = new EventClass;
-
- newEventClass->m_Guid = eventClass.m_Guid;
-
- model->m_EventClasses[model->m_EventClassCount] = newEventClass;
- model->m_EventClassCount++;
-};
-
-void PushEvent(const Event event, Model* model)
-{
- if(model->m_EventCount == 0)
- {
- model->m_EventCapacity = 1;
- model->m_Events = new Event*[model->m_EventCapacity];
- }
- else if(model->m_EventCount >= model->m_EventCapacity)
- {
- Event** newEventArray = new Event*[model->m_EventCapacity * 2];
-
- std::copy(model->m_Events, model->m_Events + model->m_EventCapacity, newEventArray);
- delete[] model->m_Events;
- model->m_Events = newEventArray;
-
- model->m_EventCapacity = model->m_EventCapacity *2;
- }
-
- Event* newEvent = new Event;
-
- newEvent->m_TimeStamp = event.m_TimeStamp;
- newEvent->m_ThreadId = event.m_ThreadId;
- newEvent->m_Guid = event.m_Guid;
-
- model->m_Events[model->m_EventCount] = newEvent;
- model->m_EventCount++;
-};
-
-void PushLabel(const Label label, Model* model)
-{
- if(model->m_LabelCount == 0)
- {
- model->m_LabelCapacity = 1;
- model->m_Labels = new Label*[model->m_LabelCapacity];
- }
- else if(model->m_LabelCount >= model->m_LabelCapacity)
- {
- Label** newLabelArray = new Label*[model->m_LabelCapacity *2];
-
- std::copy(model->m_Labels, model->m_Labels + model->m_LabelCapacity, newLabelArray);
- delete[] model->m_Labels;
- model->m_Labels = newLabelArray;
-
- model->m_LabelCapacity = model->m_LabelCapacity *2;
- }
-
- Label* newLabel = new Label;
-
- newLabel->m_Guid = label.m_Guid;
- newLabel->m_Name = label.m_Name;
-
- model->m_Labels[model->m_LabelCount] = newLabel;
- model->m_LabelCount++;
-};
-
-void PushRelationship(const Relationship relationship, Model* model)
-{
- if(model->m_RelationshipCount == 0)
- {
- model->m_RelationshipCapacity = 1;
- model->m_Relationships = new Relationship*[model->m_RelationshipCapacity];
- }
- else if(model->m_RelationshipCount >= model->m_RelationshipCapacity)
- {
- Relationship** newRelationshipArray = new Relationship*[model->m_RelationshipCapacity *2];
-
- std::copy(model->m_Relationships, model->m_Relationships + model->m_RelationshipCapacity, newRelationshipArray);
- delete[] model->m_Relationships;
- model->m_Relationships = newRelationshipArray;
-
- model->m_RelationshipCapacity = model->m_RelationshipCapacity *2;
- }
-
- Relationship* newRelationship = new Relationship;
-
- newRelationship->m_Guid = relationship.m_Guid;
- newRelationship->m_RelationshipType = relationship.m_RelationshipType;
- newRelationship->m_HeadGuid = relationship.m_HeadGuid;
- newRelationship->m_TailGuid = relationship.m_TailGuid;
-
- model->m_Relationships[model->m_RelationshipCount] = newRelationship;
- model->m_RelationshipCount++;
-};
diff --git a/tests/profiling/timelineDecoder/tests/TimelineTests.cpp b/tests/profiling/timelineDecoder/tests/TimelineTests.cpp
deleted file mode 100644
index 8106e6a996..0000000000
--- a/tests/profiling/timelineDecoder/tests/TimelineTests.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-//
-// Copyright © 2019 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "../TimelineCaptureCommandHandler.hpp"
-#include "../TimelineDirectoryCaptureCommandHandler.hpp"
-#include "../ITimelineDecoder.h"
-#include "../TimelineModel.h"
-#include "TimelineTestFunctions.hpp"
-
-#include <CommandHandlerFunctor.hpp>
-#include <ProfilingService.hpp>
-#include <PacketBuffer.hpp>
-#include <TimelinePacketWriterFactory.hpp>
-
-#include <boost/test/test_tools.hpp>
-#include <boost/test/unit_test_suite.hpp>
-
-BOOST_AUTO_TEST_SUITE(TimelineDecoderTests)
-
-using namespace armnn;
-
-void SendTimelinePacketToCommandHandler(const unsigned char* packetBuffer,
- profiling::CommandHandlerFunctor &CommandHandler)
-{
- uint32_t uint32_t_size = sizeof(uint32_t);
- unsigned int offset = 0;
-
- uint32_t header[2];
- header[0] = profiling::ReadUint32(packetBuffer, offset);
- offset += uint32_t_size;
- header[1] = profiling::ReadUint32(packetBuffer, offset);
- offset += uint32_t_size;
-
- uint32_t PacketDataLength = header[1] & 0x00FFFFFF;
-
- auto uniquePacketData = std::make_unique<unsigned char[]>(PacketDataLength);
- std::memcpy(uniquePacketData.get(), packetBuffer + offset, PacketDataLength);
-
- armnn::profiling::Packet packet(header[0], PacketDataLength, uniquePacketData);
-
- BOOST_CHECK(std::memcmp(packetBuffer + offset, packet.GetData(), packet.GetLength()) == 0);
-
- CommandHandler(packet);
-}
-
-BOOST_AUTO_TEST_CASE(TimelineDirectoryTest)
-{
- uint32_t uint8_t_size = sizeof(uint8_t);
- uint32_t uint32_t_size = sizeof(uint32_t);
- uint32_t uint64_t_size = sizeof(uint64_t);
- uint32_t threadId_size = sizeof(std::thread::id);
-
- profiling::BufferManager bufferManager(5);
- profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
-
- std::unique_ptr<profiling::ISendTimelinePacket> sendTimelinePacket =
- timelinePacketWriterFactory.GetSendTimelinePacket();
-
- profiling::PacketVersionResolver packetVersionResolver;
-
- gatordmock::TimelineDirectoryCaptureCommandHandler timelineDirectoryCaptureCommandHandler(
- 1, 0, packetVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue(), true);
-
- sendTimelinePacket->SendTimelineMessageDirectoryPackage();
- sendTimelinePacket->Commit();
-
- std::vector<profiling::SwTraceMessage> swTraceBufferMessages;
-
- unsigned int offset = uint32_t_size * 2;
-
- std::unique_ptr<profiling::IPacketBuffer> packetBuffer = bufferManager.GetReadableBuffer();
-
- uint8_t readStreamVersion = ReadUint8(packetBuffer, offset);
- BOOST_CHECK(readStreamVersion == 4);
- offset += uint8_t_size;
- uint8_t readPointerBytes = ReadUint8(packetBuffer, offset);
- BOOST_CHECK(readPointerBytes == uint64_t_size);
- offset += uint8_t_size;
- uint8_t readThreadIdBytes = ReadUint8(packetBuffer, offset);
- BOOST_CHECK(readThreadIdBytes == threadId_size);
- offset += uint8_t_size;
-
- uint32_t declarationSize = profiling::ReadUint32(packetBuffer, offset);
- offset += uint32_t_size;
- for(uint32_t i = 0; i < declarationSize; ++i)
- {
- swTraceBufferMessages.push_back(profiling::ReadSwTraceMessage(packetBuffer->GetReadableData(), offset));
- }
-
- SendTimelinePacketToCommandHandler(packetBuffer->GetReadableData(), timelineDirectoryCaptureCommandHandler);
-
- for(uint32_t index = 0; index < declarationSize; ++index)
- {
- profiling::SwTraceMessage& bufferMessage = swTraceBufferMessages[index];
- profiling::SwTraceMessage& handlerMessage = timelineDirectoryCaptureCommandHandler.m_SwTraceMessages[index];
-
- BOOST_CHECK(bufferMessage.m_Name == handlerMessage.m_Name);
- BOOST_CHECK(bufferMessage.m_UiName == handlerMessage.m_UiName);
- BOOST_CHECK(bufferMessage.m_Id == handlerMessage.m_Id);
-
- BOOST_CHECK(bufferMessage.m_ArgTypes.size() == handlerMessage.m_ArgTypes.size());
- for(uint32_t i = 0; i < bufferMessage.m_ArgTypes.size(); ++i)
- {
- BOOST_CHECK(bufferMessage.m_ArgTypes[i] == handlerMessage.m_ArgTypes[i]);
- }
-
- BOOST_CHECK(bufferMessage.m_ArgNames.size() == handlerMessage.m_ArgNames.size());
- for(uint32_t i = 0; i < bufferMessage.m_ArgNames.size(); ++i)
- {
- BOOST_CHECK(bufferMessage.m_ArgNames[i] == handlerMessage.m_ArgNames[i]);
- }
- }
-}
-
-BOOST_AUTO_TEST_CASE(TimelineCaptureTest)
-{
- uint32_t threadId_size = sizeof(std::thread::id);
-
- profiling::BufferManager bufferManager(50);
- profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
-
- std::unique_ptr<profiling::ISendTimelinePacket> sendTimelinePacket =
- timelinePacketWriterFactory.GetSendTimelinePacket();
-
- profiling::PacketVersionResolver packetVersionResolver;
-
- Model* modelPtr;
- CreateModel(&modelPtr);
-
- gatordmock::TimelineCaptureCommandHandler timelineCaptureCommandHandler(
- 1, 1, packetVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), modelPtr, true);
-
- BOOST_CHECK(SetEntityCallback(PushEntity, modelPtr) == ErrorCode_Success);
- BOOST_CHECK(SetEventClassCallback(PushEventClass, modelPtr) == ErrorCode_Success);
- BOOST_CHECK(SetEventCallback(PushEvent, modelPtr) == ErrorCode_Success);
- BOOST_CHECK(SetLabelCallback(PushLabel, modelPtr) == ErrorCode_Success);
- BOOST_CHECK(SetRelationshipCallback(PushRelationship, modelPtr) == ErrorCode_Success);
-
- const uint64_t entityGuid = 22222u;
-
- const uint64_t eventClassGuid = 33333u;
-
- const uint64_t timestamp = 111111u;
- const uint64_t eventGuid = 55555u;
-
- const std::thread::id threadId = std::this_thread::get_id();;
-
- const uint64_t labelGuid = 11111u;
- std::string labelName = "test_label";
-
- const uint64_t relationshipGuid = 44444u;
- const uint64_t headGuid = 111111u;
- const uint64_t tailGuid = 222222u;
-
- for (int i = 0; i < 10; ++i)
- {
- // Send entity
- sendTimelinePacket->SendTimelineEntityBinaryPacket(entityGuid);
- sendTimelinePacket->Commit();
- SendTimelinePacketToCommandHandler(bufferManager.GetReadableBuffer()->GetReadableData(),
- timelineCaptureCommandHandler);
-
- // Send event class
- sendTimelinePacket->SendTimelineEventClassBinaryPacket(eventClassGuid);
- sendTimelinePacket->Commit();
- SendTimelinePacketToCommandHandler(bufferManager.GetReadableBuffer()->GetReadableData(),
- timelineCaptureCommandHandler);
-
- // Send event
- sendTimelinePacket->SendTimelineEventBinaryPacket(timestamp, threadId, eventGuid);
- sendTimelinePacket->Commit();
- SendTimelinePacketToCommandHandler(bufferManager.GetReadableBuffer()->GetReadableData(),
- timelineCaptureCommandHandler);
-
- // Send label
- sendTimelinePacket->SendTimelineLabelBinaryPacket(labelGuid, labelName);
- sendTimelinePacket->Commit();
- SendTimelinePacketToCommandHandler(bufferManager.GetReadableBuffer()->GetReadableData(),
- timelineCaptureCommandHandler);
-
- // Send relationship
- profiling::ProfilingRelationshipType relationshipType = profiling::ProfilingRelationshipType::DataLink;
- sendTimelinePacket->SendTimelineRelationshipBinaryPacket(relationshipType,
- relationshipGuid,
- headGuid,
- tailGuid);
- sendTimelinePacket->Commit();
- SendTimelinePacketToCommandHandler(bufferManager.GetReadableBuffer()->GetReadableData(),
- timelineCaptureCommandHandler);
- }
-
- for (int i = 0; i < 10; ++i)
- {
- BOOST_CHECK(modelPtr->m_Entities[i]->m_Guid == entityGuid);
-
- BOOST_CHECK(modelPtr->m_EventClasses[i]->m_Guid == eventClassGuid);
-
- BOOST_CHECK(modelPtr->m_Events[i]->m_TimeStamp == timestamp);
-
- std::vector<uint8_t> readThreadId(threadId_size, 0);
- profiling::ReadBytes(modelPtr->m_Events[i]->m_ThreadId, 0, threadId_size, readThreadId.data());
- BOOST_CHECK(readThreadId == threadId);
-
- BOOST_CHECK(modelPtr->m_Events[i]->m_Guid == eventGuid);
-
- BOOST_CHECK(modelPtr->m_Labels[i]->m_Guid == labelGuid);
- BOOST_CHECK(std::string(modelPtr->m_Labels[i]->m_Name) == labelName);
-
- BOOST_CHECK(modelPtr->m_Relationships[i]->m_RelationshipType == RelationshipType::DataLink);
- BOOST_CHECK(modelPtr->m_Relationships[i]->m_Guid == relationshipGuid);
- BOOST_CHECK(modelPtr->m_Relationships[i]->m_HeadGuid == headGuid);
- BOOST_CHECK(modelPtr->m_Relationships[i]->m_TailGuid == tailGuid);
- }
-
- DestroyModel(&modelPtr);
-}
-
-BOOST_AUTO_TEST_SUITE_END()