diff options
author | Keith Davis <keith.davis@arm.com> | 2021-04-22 10:10:34 +0100 |
---|---|---|
committer | finn.williams <finn.williams@arm.com> | 2021-05-06 19:39:39 +0000 |
commit | e813d67f86df41a238ff79b5c554ef5027f56576 (patch) | |
tree | 54c2145a78297d61e6e94676729cb2468490ade3 /src/armnn/AsyncExecutionCallback.cpp | |
parent | d905decd256558bbee165e636ce4242ac3b9c917 (diff) | |
download | armnn-e813d67f86df41a238ff79b5c554ef5027f56576.tar.gz |
IVGCVSW-5813 Add Async Queue to IRuntime
Signed-off-by: Keith Davis <keith.davis@arm.com>
Change-Id: Icc0d131c8ee2e9748e2f14762a75962b39c10f9d
Diffstat (limited to 'src/armnn/AsyncExecutionCallback.cpp')
-rw-r--r-- | src/armnn/AsyncExecutionCallback.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/armnn/AsyncExecutionCallback.cpp b/src/armnn/AsyncExecutionCallback.cpp new file mode 100644 index 0000000000..c44808918d --- /dev/null +++ b/src/armnn/AsyncExecutionCallback.cpp @@ -0,0 +1,57 @@ +// +// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include <AsyncExecutionCallback.hpp> + +namespace armnn +{ + +namespace experimental +{ + +void AsyncExecutionCallback::Notify(armnn::Status status, InferenceTimingPair timeTaken) +{ + { + std::lock_guard<std::mutex> hold(m_Mutex); + if (m_Notified) + { + return; + } + // store results and mark as notified + m_Status = status; + m_StartTime = timeTaken.first; + m_EndTime = timeTaken.second; + m_Notified = true; + } + m_Condition.notify_all(); +} + +void AsyncExecutionCallback::Wait() const +{ + std::unique_lock<std::mutex> lock(m_Mutex); + m_Condition.wait(lock, [this] { return m_Notified; }); +} + +armnn::Status AsyncExecutionCallback::GetStatus() const +{ + Wait(); + return m_Status; +} + +HighResolutionClock AsyncExecutionCallback::GetStartTime() const +{ + Wait(); + return m_StartTime; +} + +HighResolutionClock AsyncExecutionCallback::GetEndTime() const +{ + Wait(); + return m_EndTime; +} + +} // namespace experimental + +} // namespace armnn
\ No newline at end of file |