From ae050524109f1ce827962665436ef7430f2ac479 Mon Sep 17 00:00:00 2001 From: David Monahan Date: Wed, 22 Mar 2023 16:48:58 +0000 Subject: IVGCVSW-7255 Update Doxygen Documentation and publish on GitHub. * Updating Doxygen documentation for 23.02 release. Signed-off-by: David Monahan Change-Id: I545574ff7664b4595d2fe6a91a3c35d2ad55df82 --- ...classarmnn_1_1experimental_1_1_threadpool.xhtml | 153 ++++++++++++++++----- 1 file changed, 118 insertions(+), 35 deletions(-) (limited to '23.02/classarmnn_1_1experimental_1_1_threadpool.xhtml') diff --git a/23.02/classarmnn_1_1experimental_1_1_threadpool.xhtml b/23.02/classarmnn_1_1experimental_1_1_threadpool.xhtml index d5ee30bbf6..eb8ff535e9 100644 --- a/23.02/classarmnn_1_1experimental_1_1_threadpool.xhtml +++ b/23.02/classarmnn_1_1experimental_1_1_threadpool.xhtml @@ -8,7 +8,7 @@ - + ArmNN: Threadpool Class Reference @@ -19,9 +19,6 @@ - @@ -30,7 +27,8 @@ extensions: ["tex2jax.js"], jax: ["input/TeX","output/HTML-CSS"], }); - + + @@ -51,18 +49,21 @@ - + +/* @license-end */
@@ -76,7 +77,9 @@ $(function() {
@@ -115,7 +118,7 @@ Public Member Functions 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...
+ Schedule an asynchronous execution on the loaded network. More...
  void TerminateThreadPool () noexcept   @@ -157,10 +160,18 @@ Public Member Functions

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
+
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 }
+

References Threadpool::LoadMemHandles().

+
@@ -187,10 +198,12 @@ Public Member Functions

Member Function Documentation

@@ -211,11 +224,35 @@ Public Member Functions

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:35
- +
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 }
+

Referenced by Threadpool::Threadpool().

+
@@ -265,15 +302,36 @@ Public Member Functions

Schedule an asynchronous execution on the loaded network.

Definition at line 69 of file Threadpool.cpp.

- +
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 }
+

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 }
- - - -
@@ -300,11 +358,22 @@ Public Member Functions

Definition at line 102 of file Threadpool.cpp.

- -

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

- +
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 }
+

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 }
+
@@ -324,9 +393,16 @@ Public Member Functions

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 }
+
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 }
@@ -336,13 +412,20 @@ Public Member Functions + + + + +
void LoadMemHandles(std::vector< std::shared_ptr< IWorkingMemHandle >> memHandles)
Definition: Threadpool.cpp:29
+
int NetworkId
Definition: IRuntime.hpp:35
+
void TerminateThreadPool() noexcept
Definition: Threadpool.cpp:102
-- cgit v1.2.1