ArmNN
 21.02
CommandHandler.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
9 #include <common/include/PacketVersionResolver.hpp>
10 
11 #include <common/include/CommandHandlerRegistry.hpp>
12 
13 #include <atomic>
14 #include <thread>
15 
16 namespace armnn
17 {
18 
19 namespace profiling
20 {
21 
23 {
24 public:
25  CommandHandler(uint32_t timeout,
26  bool stopAfterTimeout,
27  arm::pipe::CommandHandlerRegistry& commandHandlerRegistry,
28  arm::pipe::PacketVersionResolver& packetVersionResolver)
29  : m_Timeout(timeout),
30  m_StopAfterTimeout(stopAfterTimeout),
31  m_IsRunning(false),
32  m_KeepRunning(false),
33  m_CommandThread(),
34  m_CommandHandlerRegistry(commandHandlerRegistry),
35  m_PacketVersionResolver(packetVersionResolver)
36  {}
38 
39  void SetTimeout(uint32_t timeout) { m_Timeout.store(timeout); }
40  void SetStopAfterTimeout(bool stopAfterTimeout) { m_StopAfterTimeout.store(stopAfterTimeout); }
41 
42  void Start(IProfilingConnection& profilingConnection);
43  void Stop();
44  bool IsRunning() const { return m_IsRunning.load(); }
45 
46 private:
47  void HandleCommands(IProfilingConnection& profilingConnection);
48 
49  std::atomic<uint32_t> m_Timeout;
50  std::atomic<bool> m_StopAfterTimeout;
51  std::atomic<bool> m_IsRunning;
52  std::atomic<bool> m_KeepRunning;
53  std::thread m_CommandThread;
54 
55  arm::pipe::CommandHandlerRegistry& m_CommandHandlerRegistry;
56  arm::pipe::PacketVersionResolver& m_PacketVersionResolver;
57 };
58 
59 } // namespace profiling
60 
61 } // namespace armnn
CommandHandler(uint32_t timeout, bool stopAfterTimeout, arm::pipe::CommandHandlerRegistry &commandHandlerRegistry, arm::pipe::PacketVersionResolver &packetVersionResolver)
void Start(IProfilingConnection &profilingConnection)
DataLayout::NCHW false
Copyright (c) 2021 ARM Limited and Contributors.
void SetTimeout(uint32_t timeout)
void SetStopAfterTimeout(bool stopAfterTimeout)