diff options
author | Keith Davis <keith.davis@arm.com> | 2019-10-24 17:30:41 +0100 |
---|---|---|
committer | Colm Donelan <colm.donelan@arm.com> | 2019-11-06 08:30:31 +0000 |
commit | 3201eea0565ce2bb0418d1936fec71bdeb14c084 (patch) | |
tree | f73017f6338d707165dbcfd717ddc9793b1858e0 /src/profiling/FileOnlyProfilingConnection.hpp | |
parent | fe2e2cbbbe5294072b2d58755b8a095f32a97e75 (diff) | |
download | armnn-3201eea0565ce2bb0418d1936fec71bdeb14c084.tar.gz |
IVGCVSW-3444 File Only Profiling Connection
* Add FileOnlyProfilingConnection Decorator
* Fix bug where Conn Ack not automatically sent back
* Modify GatordMock to use the Counter Directory class.
* Promote DirectoryCaptureCommandHandler from GatordMock into ArmNN.
* Remove MockUtils as it's contents were moved or deleted.
* Rewrite GatordMockTests to use Counter Directory class.
* Flush streams in ProfilingConnectionDumpToFileDecorator::Close.
Signed-off-by: Keith Davis <keith.davis@arm.com>
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
Change-Id: I77b2aedece24150dd31691b577f3b5d81b2e226f
Diffstat (limited to 'src/profiling/FileOnlyProfilingConnection.hpp')
-rw-r--r-- | src/profiling/FileOnlyProfilingConnection.hpp | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/profiling/FileOnlyProfilingConnection.hpp b/src/profiling/FileOnlyProfilingConnection.hpp new file mode 100644 index 0000000000..12a87a1535 --- /dev/null +++ b/src/profiling/FileOnlyProfilingConnection.hpp @@ -0,0 +1,82 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include "CounterDirectory.hpp" +#include "DirectoryCaptureCommandHandler.hpp" +#include "IProfilingConnection.hpp" +#include "ProfilingUtils.hpp" +#include "Runtime.hpp" + +#include <fstream> +#include <queue> + +namespace armnn +{ + +namespace profiling +{ + +enum class TargetEndianness +{ + BeWire, + LeWire +}; + +enum class PackageActivity +{ + StreamMetaData, + CounterDirectory, + Unknown +}; + +class FileOnlyProfilingConnection : public IProfilingConnection +{ +public: + FileOnlyProfilingConnection(const Runtime::CreationOptions::ExternalProfilingOptions& options, + const bool quietOp = true) + : m_Options(options) + , m_QuietOp(quietOp) + , m_Endianness(TargetEndianness::LeWire) // Set a sensible default. WaitForStreamMeta will set a real value. + {}; + + ~FileOnlyProfilingConnection(); + + bool IsOpen() const override; + + void Close() override; + + // This is effectively receiving a data packet from ArmNN. + bool WritePacket(const unsigned char* buffer, uint32_t length) override; + + // Sending a packet back to ArmNN. + Packet ReadPacket(uint32_t timeout) override; + +private: + bool WaitForStreamMeta(const unsigned char* buffer, uint32_t length); + + uint32_t ToUint32(const unsigned char* data, TargetEndianness endianness); + + void SendConnectionAck(); + + bool SendCounterSelectionPacket(); + + PackageActivity GetPackageActivity(const unsigned char* buffer, uint32_t headerAsWords[2]); + + void Fail(const std::string& errorMessage); + + static const uint32_t PIPE_MAGIC = 0x45495434; + + Runtime::CreationOptions::ExternalProfilingOptions m_Options; + bool m_QuietOp; + std::vector<uint16_t> m_IdList; + std::queue<Packet> m_PacketQueue; + TargetEndianness m_Endianness; +}; + +} // namespace profiling + +} // namespace armnn
\ No newline at end of file |