aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/BufferManager.hpp
diff options
context:
space:
mode:
authorNarumol Prangnawarat <narumol.prangnawarat@arm.com>2019-09-27 18:00:11 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-09-30 14:00:10 +0000
commit7be47efac07b6276f02a17cb486f9061a426a837 (patch)
treeb63cc8dddef79b6540c9b2abae03055bf85bb685 /src/profiling/BufferManager.hpp
parentaab82c5ebc5b65f5f5f657d7bee6bd60f106d3b9 (diff)
downloadarmnn-7be47efac07b6276f02a17cb486f9061a426a837.tar.gz
IVGCVSW-3903 Create Counter Stream Buffer
* Add implementation of PacketBuffer * Add implementation of BufferManager * Unit tests Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com> Change-Id: Icca3807149ff5a8ed31cc87de73c50b95bca39d4
Diffstat (limited to 'src/profiling/BufferManager.hpp')
-rw-r--r--src/profiling/BufferManager.hpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/profiling/BufferManager.hpp b/src/profiling/BufferManager.hpp
new file mode 100644
index 0000000000..04a1507512
--- /dev/null
+++ b/src/profiling/BufferManager.hpp
@@ -0,0 +1,59 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "IBufferManager.hpp"
+
+#include <condition_variable>
+#include <mutex>
+#include <vector>
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+class BufferManager : public IBufferManager
+{
+public:
+ BufferManager(unsigned int numberOfBuffers = 5, unsigned int maxPacketSize = 4096);
+
+ ~BufferManager() {}
+
+ std::unique_ptr<IPacketBuffer> Reserve(unsigned int requestedSize, unsigned int& reservedSize) override;
+
+ void Commit(std::unique_ptr<IPacketBuffer>& packetBuffer, unsigned int size) override;
+
+ void Release(std::unique_ptr<IPacketBuffer>& packetBuffer) override;
+
+ std::unique_ptr<IPacketBuffer> GetReadableBuffer() override;
+
+ void MarkRead(std::unique_ptr<IPacketBuffer>& packetBuffer) override;
+
+private:
+ // Maximum buffer size
+ unsigned int m_MaxBufferSize;
+
+ // List of available packet buffers
+ std::vector<std::unique_ptr<IPacketBuffer>> m_AvailableList;
+
+ // List of readable packet buffers
+ std::vector<std::unique_ptr<IPacketBuffer>> m_ReadableList;
+
+ // Mutex for available packet buffer list
+ std::mutex m_AvailableMutex;
+
+ // Mutex for readable packet buffer list
+ std::mutex m_ReadableMutex;
+
+ // Condition to notify when data is availabe to be read
+ std::condition_variable m_ReadDataAvailable;
+};
+
+} // namespace profiling
+
+} // namespace armnn