* Updated ExecuteNetwork to propagate a configured Runtime down to RunTest.
* Fixed the creation of PeriodicCounterCaptureCommandHandler to match
other handlers.
* Moved around some printouts to make the MockGatorD output more useful.
* Added details to the exception handling for problems in the
GatordMockService receive thread.
* Mockutils::ConstructHeader is only used in GatordMockTests. Moved it
in there and deleted MockUtils.hpp
* Refactored SendPeriodicCounterSelectionList to use ProfilingUtils.
* Added PeriodicCounterSelectionResponseHandler to received packet echoed back.
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
Change-Id: I4accdbf6cf5dd3f7dcc12b210b8360b4a5e4e277
tests/profiling/gatordmock/CommandLineProcessor.cpp
tests/profiling/gatordmock/GatordMockService.hpp
tests/profiling/gatordmock/GatordMockService.cpp
- tests/profiling/gatordmock/MockUtils.hpp
tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.cpp
tests/profiling/gatordmock/PeriodicCounterCaptureCommandHandler.hpp
+ tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.cpp
+ tests/profiling/gatordmock/PeriodicCounterSelectionResponseHandler.hpp
)
include_directories(${Boost_INCLUDE_DIRS} src/profiling)
const std::string backendsMessage = "REQUIRED: Which device to run layers on by default. Possible choices: "
+ armnn::BackendRegistryInstance().GetBackendIdsAsString();
-
po::options_description desc("Options");
try
{
options.m_ProfilingOptions.m_OutgoingCaptureFile = outgoingCaptureFile;
options.m_ProfilingOptions.m_FileOnly = fileOnlyExternalProfiling;
options.m_ProfilingOptions.m_CapturePeriod = counterCapturePeriod;
-
std::shared_ptr<armnn::IRuntime> runtime(armnn::IRuntime::Create(options));
const std::string executableName("ExecuteNetwork");
std::cerr << desc << std::endl;
return EXIT_FAILURE;
}
-
+ // Create runtime
+ armnn::IRuntime::CreationOptions options;
+ options.m_EnableGpuProfiling = enableProfiling;
+ options.m_ProfilingOptions.m_EnableProfiling = enableExternalProfiling;
+ options.m_ProfilingOptions.m_IncomingCaptureFile = incomingCaptureFile;
+ options.m_ProfilingOptions.m_OutgoingCaptureFile = outgoingCaptureFile;
+ options.m_ProfilingOptions.m_FileOnly = fileOnlyExternalProfiling;
+ options.m_ProfilingOptions.m_CapturePeriod = counterCapturePeriod;
+ std::shared_ptr<armnn::IRuntime> runtime(armnn::IRuntime::Create(options));
return RunTest(modelFormat, inputTensorShapes, computeDevices, dynamicBackendsPath, modelPath, inputNames,
inputTensorDataFilePaths, inputTypes, quantizeInput, outputTypes, outputNames,
outputTensorFiles, enableProfiling, enableFp16TurboMode, thresholdTime, printIntermediate,
- subgraphId, enableLayerDetails);
+ subgraphId, enableLayerDetails, runtime);
}
}
#pragma once
-#include <string>
#include "GatordMockService.hpp"
+#include <string>
namespace armnn
{
void ParseFile(std::string CommandFile, GatordMockService& mockService);
};
-} // namespace gatordmock
-} // namespace armnn
-
-
+} // namespace gatordmock
+} // 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.
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; }
+ 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;
bool m_Echo;
};
-} // namespace gatordmock
+} // namespace gatordmock
-} // namespace armnn
+} // namespace armnn
// SPDX-License-Identifier: MIT
//
+#include "../../../src/profiling/PacketVersionResolver.hpp"
+#include "../../../src/profiling/PeriodicCounterSelectionCommandHandler.hpp"
#include "CommandFileParser.hpp"
#include "CommandLineProcessor.hpp"
#include "GatordMockService.hpp"
-#include "MockUtils.hpp"
#include "PeriodicCounterCaptureCommandHandler.hpp"
+#include "PeriodicCounterSelectionResponseHandler.hpp"
+#include <iostream>
#include <string>
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
// Process command line arguments
armnn::gatordmock::CommandLineProcessor cmdLine;
return EXIT_FAILURE;
}
- // Initialise functors and register into the CommandHandlerRegistry
- uint32_t version = 1;
-
- // Create headers
- uint32_t counterCaptureCommandHeader = armnn::gatordmock::ConstructHeader(1,0,0);
-
+ armnn::profiling::PacketVersionResolver packetVersionResolver;
// Create the Command Handler Registry
armnn::profiling::CommandHandlerRegistry registry;
- // Update with derived functors
- armnn::gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(counterCaptureCommandHeader,
- version,
- cmdLine.IsEchoEnabled());
+ // This functor will receive back the selection response packet.
+ armnn::gatordmock::PeriodicCounterSelectionResponseHandler periodicCounterSelectionResponseHandler(
+ 4, packetVersionResolver.ResolvePacketVersion(4).GetEncodedValue());
+ // This functor will receive the counter data.
+ armnn::gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(
+ 0, packetVersionResolver.ResolvePacketVersion(0).GetEncodedValue());
// Register different derived functors
+ registry.RegisterFunctor(&periodicCounterSelectionResponseHandler);
registry.RegisterFunctor(&counterCaptureCommandHandler);
armnn::gatordmock::GatordMockService mockService(registry, cmdLine.IsEchoEnabled());
{
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())
#include "GatordMockService.hpp"
#include <CommandHandlerRegistry.hpp>
+#include "../../src/profiling/PacketVersionResolver.hpp"
+#include "../../src/profiling/ProfilingUtils.hpp"
#include <cerrno>
#include <fcntl.h>
+#include <iomanip>
#include <iostream>
#include <poll.h>
#include <string>
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)))
+ 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;
std::cerr << ": Listen call on socket failed: " << strerror(errno) << std::endl;
return false;
}
- if (m_EchoPackets)
- {
- std::cout << "Bound to UDS namespace: \\0" << udsNamespace << std::endl;
- }
return true;
}
int GatordMockService::BlockForOneClient()
{
- if (m_EchoPackets)
- {
- std::cout << "Waiting for client connection." << std::endl;
- }
m_ClientConnection = accept4(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;
}
-
- if (m_EchoPackets)
- {
- std::cout << "Client connection established." << std::endl;
- }
return m_ClientConnection;
}
{
return false;
}
- EchoPacket(PacketDirection::Received, header, 8);
+ EchoPacket(PacketDirection::ReceivedHeader, header, 8);
// The first word, stream_metadata_identifer, should always be 0.
if (ToUint32(&header[0], TargetEndianness::BeWire) != 0)
{
{
return false;
}
- EchoPacket(PacketDirection::Received, pipeMagic, 4);
+ 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)
std::cerr << ": Protocol read error. Data length mismatch." << std::endl;
return false;
}
- EchoPacket(PacketDirection::Received, packetData, metaDataLength);
- m_StreamMetaDataVersion = ToUint32(&packetData[0], m_Endianness);
+ EchoPacket(PacketDirection::ReceivedData, packetData, metaDataLength);
+ m_StreamMetaDataVersion = ToUint32(&packetData[0], m_Endianness);
m_StreamMetaDataMaxDataLen = ToUint32(&packetData[4], m_Endianness);
- m_StreamMetaDataPid = ToUint32(&packetData[8], m_Endianness);
+ m_StreamMetaDataPid = ToUint32(&packetData[8], m_Endianness);
return true;
}
}
}
-
-void GatordMockService::SendPeriodicCounterSelectionList(uint period, std::vector<uint16_t> counters)
+void GatordMockService::SendPeriodicCounterSelectionList(uint32_t period, std::vector<uint16_t> counters)
{
- //get the datalength in bytes
- uint32_t datalength = static_cast<uint32_t>(4 + counters.size() * 2);
+ // 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.
- u_char data[datalength];
+ 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));
- *data = static_cast<u_char>(period >> 24);
- *(data + 1) = static_cast<u_char>(period >> 16 & 0xFF);
- *(data + 2) = static_cast<u_char>(period >> 8 & 0xFF);
- *(data + 3) = static_cast<u_char>(period & 0xFF);
+ std::unique_ptr<unsigned char[]> uniqueData = std::make_unique<unsigned char[]>(dataLength);
+ unsigned char* data = reinterpret_cast<unsigned char*>(uniqueData.get());
- for (unsigned long i = 0; i < counters.size(); ++i)
+ uint32_t offset = 0;
+ profiling::WriteUint32(data, offset, period);
+ offset += 4;
+ for (std::vector<uint16_t>::iterator it = counters.begin(); it != counters.end(); ++it)
{
- *(data + 4 + i * 2) = static_cast<u_char>(counters[i] >> 8);
- *(data + 5 + i * 2) = static_cast<u_char>(counters[i] & 0xFF);
+ profiling::WriteUint16(data, offset, *it);
+ offset += 2;
}
- // create packet send packet
- SendPacket(0, 4, data, datalength);
+ // 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(uint timeout)
{
armnn::profiling::Packet packet = mockService.WaitForPacket(500);
}
- catch(armnn::TimeoutException)
+ catch (armnn::TimeoutException)
{
// In this case we ignore timeouts and and keep trying to receive.
}
+ catch (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 (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);
+ }
}
}
// No there's not. Poll for more data.
struct pollfd pollingFd[1]{};
pollingFd[0].fd = m_ClientConnection;
- int pollResult = poll(pollingFd, 1, static_cast<int>(timeoutMs));
+ int pollResult = poll(pollingFd, 1, static_cast<int>(timeoutMs));
switch (pollResult)
{
// 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))
{
- std::cout << "Error while polling receiving socket." << std::endl;
- throw armnn::RuntimeException(std::string("File descriptor reported an error during polling: ") +
- strerror(errno));
+ 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
}
}
-
armnn::profiling::Packet GatordMockService::ReceivePacket()
{
uint32_t header[2];
}
// 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());
+ 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);
-
- // Pass packet into the handler registry
- if (packetRx.GetHeader()!= 0)
+ if (m_EchoPackets)
{
- m_PacketsReceivedCount.operator++(std::memory_order::memory_order_release);
- m_HandlerRegistry.GetFunctor(header[0],1)->operator()(packetRx);
+ std::cout << "Processing packet ID= " << packetRx.GetPacketId() << " Length=" << packetRx.GetLength()
+ << std::endl;
}
+ // Pass packet into the handler registry
+ m_PacketsReceivedCount.operator++(std::memory_order::memory_order_release);
+ m_HandlerRegistry
+ .GetFunctor(packetRx.GetPacketId(),
+ packetVersionResolver.ResolvePacketVersion(packetRx.GetPacketId()).GetEncodedValue())
+ ->operator()(packetRx);
- EchoPacket(PacketDirection::Received, packetData, sizeof(packetData));
return packetRx;
}
header[0] = packetFamily << 26 | packetId << 16;
header[1] = dataLength;
// Add the header to the packet.
- u_char packet[8 + dataLength ];
+ u_char packet[8 + dataLength];
InsertU32(header[0], packet, m_Endianness);
InsertU32(header[1], packet + 4, m_Endianness);
// And the rest of the data if there is any.
bool GatordMockService::ReadHeader(uint32_t headerAsWords[2])
{
- // The herader will always be 2x32bit words.
+ // The header will always be 2x32bit words.
u_char 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;
{
if (direction == PacketDirection::Sending)
{
- std::cout << "Sending " << std::dec << lengthInBytes << " bytes : ";
- } else
+ std::cout << "TX " << std::dec << lengthInBytes << " bytes : ";
+ }
+ else if (direction == PacketDirection::ReceivedHeader)
+ {
+ std::cout << "RX Header " << std::dec << lengthInBytes << " bytes : ";
+ }
+ else
{
- std::cout << "Received " << std::dec << lengthInBytes << " bytes : ";
+ std::cout << "RX Data " << std::dec << lengthInBytes << " bytes : ";
}
for (unsigned int i = 0; i < lengthInBytes; i++)
{
{
std::cout << std::endl;
}
- std::cout << std::hex << "0x" << static_cast<unsigned int>(packet[i]) << " ";
+ std::cout << "0x" << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned int>(packet[i])
+ << " ";
}
std::cout << std::endl;
}
// the endianness value.
if (endianness == TargetEndianness::BeWire)
{
- *data = static_cast<u_char>((value >> 24) & 0xFF);
+ *data = static_cast<u_char>((value >> 24) & 0xFF);
*(data + 1) = static_cast<u_char>((value >> 16) & 0xFF);
*(data + 2) = static_cast<u_char>((value >> 8) & 0xFF);
*(data + 3) = static_cast<u_char>(value & 0xFF);
*(data + 3) = static_cast<u_char>((value >> 24) & 0xFF);
*(data + 2) = static_cast<u_char>((value >> 16) & 0xFF);
*(data + 1) = static_cast<u_char>((value >> 8) & 0xFF);
- *data = static_cast<u_char>(value & 0xFF);
+ *data = static_cast<u_char>(value & 0xFF);
}
}
-} // namespace gatordmock
+} // namespace gatordmock
-} // namespace armnn
+} // namespace armnn
#include <CommandHandlerRegistry.hpp>
#include <Packet.hpp>
+#include <atomic>
#include <string>
#include <thread>
-#include <atomic>
namespace armnn
{
enum class TargetEndianness
{
- BeWire, LeWire
+ BeWire,
+ LeWire
};
enum class PacketDirection
{
- Sending, Received
+ Sending,
+ ReceivedHeader,
+ ReceivedData
};
/// A class that implements a Mock Gatord server. It will listen on a specified Unix domain socket (UDS)
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)
void WaitForReceivingThread();
/// Send the counter list to ArmNN.
- void SendPeriodicCounterSelectionList(uint period, std::vector<uint16_t> counters);
+ void SendPeriodicCounterSelectionList(uint32_t period, std::vector<uint16_t> counters);
/// Execute the WAIT command from the comamnd file.
void WaitCommand(uint timeout);
}
private:
-
void ReceiveLoop(GatordMockService& mockService);
/// Block on the client connection until a complete packet has been received. This is a placeholder function to
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;
+ TargetEndianness m_Endianness;
+ uint32_t m_StreamMetaDataVersion;
+ uint32_t m_StreamMetaDataMaxDataLen;
+ uint32_t m_StreamMetaDataPid;
armnn::profiling::CommandHandlerRegistry& m_HandlerRegistry;
std::thread m_ListeningThread;
std::atomic<bool> m_CloseReceivingThread;
};
-} // namespace gatordmock
-
-} // namespace armnn
-
+} // namespace gatordmock
+} // namespace armnn
+++ /dev/null
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-#include <EncodeVersion.hpp>
-
-namespace armnn
-{
-
-namespace gatordmock
-{
-
-
-uint32_t ConstructHeader(uint32_t packetFamily,
- uint32_t packetClass,
- uint32_t packetType)
-{
- return ((packetFamily & 0x3F) << 26)|
- ((packetClass & 0x3FF) << 19)|
- ((packetType & 0x3FFF) << 16);
-}
-
-uint32_t ConstructHeader(uint32_t packetFamily,
- uint32_t packetId)
-{
- return ((packetFamily & 0x3F) << 26)|
- ((packetId & 0x3FF) << 16);
-}
-
-} // gatordmock
-
-} // armnn
void PeriodicCounterCaptureCommandHandler::operator()(const profiling::Packet& packet)
{
ParseData(packet);
- if (m_EchoPackets)
+ if (!m_QuietOperation) // Are we supposed to print to stdout?
{
std::string header, body, uidString, valueString;
#include <Packet.hpp>
#include <CommandHandlerFunctor.hpp>
+#include "../../armnn/src/profiling/Packet.hpp"
#include <vector>
{
public:
- PeriodicCounterCaptureCommandHandler(uint32_t packetId,
- uint32_t version,
- bool echoPackets)
+ /**
+ *
+ * @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 packetId, uint32_t version, bool quietOperation = false)
: CommandHandlerFunctor(packetId, version)
- , m_EchoPackets(echoPackets)
+ , m_QuietOperation(quietOperation)
{}
void operator()(const armnn::profiling::Packet& packet) override;
uint64_t m_FirstTimestamp = 0, m_SecondTimestamp = 0;
bool m_HeaderPrinted = false;
- bool m_EchoPackets;
+ bool m_QuietOperation;
};
-} // namespace gatordmock
+} // namespace gatordmock
-} // namespace armnn
+} // namespace armnn
--- /dev/null
+//
+// 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
--- /dev/null
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "../../armnn/src/profiling/CommandHandlerFunctor.hpp"
+#include "../../armnn/src/profiling/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 packetId, uint32_t version, bool quietOperation = true)
+ : CommandHandlerFunctor(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
//
#include "../GatordMockService.hpp"
-#include "../MockUtils.hpp"
#include "../PeriodicCounterCaptureCommandHandler.hpp"
#include <CommandHandlerRegistry.hpp>
// Required so build succeeds when local variable used only in assert
#define _unused(x) ((void)(x))
+uint32_t ConstructHeader(uint32_t packetFamily, uint32_t packetClass, uint32_t packetType)
+{
+ return ((packetFamily & 0x3F) << 26) | ((packetClass & 0x3FF) << 19) | ((packetType & 0x3FFF) << 16);
+}
+
+uint32_t ConstructHeader(uint32_t packetFamily, uint32_t packetId)
+{
+ return ((packetFamily & 0x3F) << 26) | ((packetId & 0x3FF) << 16);
+}
+
BOOST_AUTO_TEST_CASE(CounterCaptureHandlingTest)
{
using boost::numeric_cast;
// Initialise functors and register into the CommandHandlerRegistry
- uint32_t headerWord1 = gatordmock::ConstructHeader(1, 0, 0);
+ uint32_t headerWord1 = ConstructHeader(1, 0, 0);
// Create the Command Handler Registry
profiling::CommandHandlerRegistry registry;
// 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());
+ 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());
+ 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));
profiling::Packet packet2(headerWord1, dataLength, uniqueData2);
uint32_t version = 1;
- gatordmock::PeriodicCounterCaptureCommandHandler commandHandler(headerWord1, version, false);
+ gatordmock::PeriodicCounterCaptureCommandHandler commandHandler(headerWord1, version, true);
// Simulate two separate packets coming in to calculate period
commandHandler(packet1);
// performance data.
// Initialise functors and register into the CommandHandlerRegistry
- uint32_t counterCaptureHeader = gatordmock::ConstructHeader(1, 0);
+ uint32_t counterCaptureHeader = ConstructHeader(1, 0);
uint32_t version = 1;
// Create the Command Handler Registry
profiling::CommandHandlerRegistry registry;
// Update with derived functors
- gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(counterCaptureHeader, version, false);
+ gatordmock::PeriodicCounterCaptureCommandHandler counterCaptureCommandHandler(counterCaptureHeader, version, true);
// Register different derived functors
registry.RegisterFunctor(&counterCaptureCommandHandler);