From f4019872c1134c6fcc1d6993e5746f55c1e79208 Mon Sep 17 00:00:00 2001 From: Nikhil Raj Date: Tue, 8 Mar 2022 20:01:38 +0000 Subject: IVGCVSW-6819 Fix the directory structure and broken link to latest docu Signed-off-by: Nikhil Raj Change-Id: I05b559d15faf92c76ff536719693b361316be4f3 --- ...classarmnn_1_1experimental_1_1_threadpool.xhtml | 349 +++++++++++++++++++++ 1 file changed, 349 insertions(+) create mode 100644 22.02/classarmnn_1_1experimental_1_1_threadpool.xhtml (limited to '22.02/classarmnn_1_1experimental_1_1_threadpool.xhtml') diff --git a/22.02/classarmnn_1_1experimental_1_1_threadpool.xhtml b/22.02/classarmnn_1_1experimental_1_1_threadpool.xhtml new file mode 100644 index 0000000000..72a5f622d0 --- /dev/null +++ b/22.02/classarmnn_1_1experimental_1_1_threadpool.xhtml @@ -0,0 +1,349 @@ + + + + + + + + + + + + + +ArmNN: Threadpool Class Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  22.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
Threadpool Class Reference
+
+
+ +

#include <Threadpool.hpp>

+ + + + + + + + + + + + + + + +

+Public Member Functions

 Threadpool (std::size_t numThreads, IRuntime *runtimePtr, std::vector< std::shared_ptr< IWorkingMemHandle >> memHandles)
 
 ~Threadpool ()
 
void LoadMemHandles (std::vector< std::shared_ptr< IWorkingMemHandle >> memHandles)
 
void UnloadMemHandles (NetworkId networkId)
 
void Schedule (NetworkId networkId, const InputTensors &inputTensors, const OutputTensors &outputTensors, const QosExecPriority priority, std::shared_ptr< IAsyncExecutionCallback > cb)
 Schedule an asynchronous execution on the loaded network. More...
 
void TerminateThreadPool () noexcept
 
+

Detailed Description

+
+

Definition at line 24 of file Threadpool.hpp.

+

Constructor & Destructor Documentation

+ +

◆ Threadpool()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Threadpool (std::size_t numThreads,
IRuntimeruntimePtr,
std::vector< std::shared_ptr< IWorkingMemHandle >> memHandles 
)
+
+ +

Definition at line 16 of file Threadpool.cpp.

+ +

References Threadpool::LoadMemHandles().

+
19  : m_RuntimePtr(runtimePtr)
20 {
21  for (auto i = 0u; i < numThreads; ++i)
22  {
23  m_Threads.emplace_back(std::make_unique<std::thread>(&Threadpool::ProcessExecPriorities, this, i));
24  }
25 
26  LoadMemHandles(memHandles);
27 }
void LoadMemHandles(std::vector< std::shared_ptr< IWorkingMemHandle >> memHandles)
Definition: Threadpool.cpp:29
+
+
+
+ +

◆ ~Threadpool()

+ +
+
+ + + + + +
+ + + + + + + +
~Threadpool ()
+
+inline
+
+
+

Member Function Documentation

+ +

◆ LoadMemHandles()

+ +
+
+ + + + + + + + +
void LoadMemHandles (std::vector< std::shared_ptr< IWorkingMemHandle >> memHandles)
+
+ +

Definition at line 29 of file Threadpool.cpp.

+ +

Referenced by Threadpool::Threadpool(), and Threadpool::~Threadpool().

+
30 {
31  if (memHandles.size() == 0)
32  {
33  throw armnn::RuntimeException("Threadpool::UnloadMemHandles: Size of memHandles vector must be greater than 0");
34  }
35 
36  if (memHandles.size() != m_Threads.size())
37  {
39  "Threadpool::UnloadMemHandles: Size of memHandles vector must match the number of threads");
40  }
41 
42  NetworkId networkId = memHandles[0]->GetNetworkId();
43  for (uint32_t i = 1; i < memHandles.size(); ++i)
44  {
45  if (networkId != memHandles[i]->GetNetworkId())
46  {
48  "Threadpool::UnloadMemHandles: All network ids must be identical in memHandles");
49  }
50  }
51 
52  std::pair<NetworkId, std::vector<std::shared_ptr<IWorkingMemHandle>>> pair {networkId, memHandles};
53 
54  m_WorkingMemHandleMap.insert(pair);
55 }
int NetworkId
Definition: IRuntime.hpp:25
+ +
+
+
+ +

◆ Schedule()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void Schedule (NetworkId networkId,
const InputTensorsinputTensors,
const OutputTensorsoutputTensors,
const QosExecPriority priority,
std::shared_ptr< IAsyncExecutionCallbackcb 
)
+
+ +

Schedule an asynchronous execution on the loaded network.

+ +

Definition at line 69 of file Threadpool.cpp.

+ +

References armnn::High, armnn::Low, and armnn::Medium.

+ +

Referenced by Threadpool::~Threadpool().

+
74 {
75  if (m_WorkingMemHandleMap.find(networkId) == m_WorkingMemHandleMap.end())
76  {
77  throw armnn::RuntimeException("Threadpool::UnloadMemHandles: Unknown NetworkId");
78  }
79 
80  // Group execution parameters so that they can be easily added to the queue
81  ExecutionTuple groupExecParams = std::make_tuple(networkId, inputTensors, outputTensors, cb);
82 
83  std::shared_ptr<ExecutionTuple> operation = std::make_shared<ExecutionTuple>(groupExecParams);
84 
85  // Add a message to the queue and notify the request thread
86  std::unique_lock<std::mutex> lock(m_ThreadPoolMutex);
87  switch (priority)
88  {
90  m_HighPriorityQueue.push(operation);
91  break;
93  m_LowPriorityQueue.push(operation);
94  break;
96  default:
97  m_MediumPriorityQueue.push(operation);
98  }
99  m_ThreadPoolEvent.notify_one();
100 }
+ + + +
+
+
+ +

◆ TerminateThreadPool()

+ +
+
+ + + + + +
+ + + + + + + +
void TerminateThreadPool ()
+
+noexcept
+
+ +

Definition at line 102 of file Threadpool.cpp.

+ +

References IRuntime::Execute(), armnn::EXPIRE_RATE, armnn::Failure, armnn::GetTimeNow(), and armnn::Success.

+ +

Referenced by Threadpool::~Threadpool().

+
103 {
104  {
105  std::unique_lock<std::mutex> threadPoolLock(m_ThreadPoolMutex);
106  m_TerminatePool = true;
107  }
108 
109  m_ThreadPoolEvent.notify_all();
110 
111  for (auto &thread : m_Threads)
112  {
113  thread->join();
114  }
115 }
+
+
+ +

◆ UnloadMemHandles()

+ +
+
+ + + + + + + + +
void UnloadMemHandles (NetworkId networkId)
+
+ +

Definition at line 57 of file Threadpool.cpp.

+ +

Referenced by Threadpool::~Threadpool().

+
58 {
59  if (m_WorkingMemHandleMap.find(networkId) != m_WorkingMemHandleMap.end())
60  {
61  m_WorkingMemHandleMap.erase(networkId);
62  }
63  else
64  {
65  throw armnn::RuntimeException("Threadpool::UnloadMemHandles: Unknown NetworkId");
66  }
67 }
+
+
+
+
The documentation for this class was generated from the following files: +
+
+ + + + -- cgit v1.2.1