aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/test/ProfilerTests.cpp
diff options
context:
space:
mode:
authorSadik Armagan <sadik.armagan@arm.com>2021-08-05 15:01:07 +0100
committerNikhil Raj Arm <nikhil.raj@arm.com>2021-08-05 17:44:39 +0000
commit95e9efc28ce70a8cda93e722f5ce90ebc96bdd95 (patch)
treea386f0984280f15b782eaa84af4709d9a870b755 /src/armnn/test/ProfilerTests.cpp
parent2b9fe3aecb14938257537460d20e01e33cb03e5c (diff)
downloadarmnn-95e9efc28ce70a8cda93e722f5ce90ebc96bdd95.tar.gz
IVGCVSW-6258 'Unittest failures'
* Fixed unit test failures happening on threads. Signed-off-by: Sadik Armagan <sadik.armagan@arm.com> Change-Id: I2a6048f75ece4a9f4c2116306838ff55385aabe7
Diffstat (limited to 'src/armnn/test/ProfilerTests.cpp')
-rw-r--r--src/armnn/test/ProfilerTests.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/armnn/test/ProfilerTests.cpp b/src/armnn/test/ProfilerTests.cpp
index 8fd97179f1..b23ac1ccc3 100644
--- a/src/armnn/test/ProfilerTests.cpp
+++ b/src/armnn/test/ProfilerTests.cpp
@@ -7,6 +7,7 @@
#include <doctest/doctest.h>
+#include <algorithm>
#include <thread>
#include <Profiling.hpp>
@@ -90,15 +91,17 @@ TEST_CASE("RegisterUnregisterProfilerSingleThread")
TEST_CASE("RegisterUnregisterProfilerMultipleThreads")
{
bool res[3] = {false, false, false};
- std::thread thread1([&res]() { RegisterUnregisterProfilerSingleThreadImpl(res[0]); });
- std::thread thread2([&res]() { RegisterUnregisterProfilerSingleThreadImpl(res[1]); });
- std::thread thread3([&res]() { RegisterUnregisterProfilerSingleThreadImpl(res[2]); });
-
- thread1.join();
- thread2.join();
- thread3.join();
+ std::vector<std::thread> threads;
+ for (unsigned int i = 0; i < 3; ++i)
+ {
+ threads.push_back(std::thread([&res, i]() { RegisterUnregisterProfilerSingleThreadImpl(res[i]); }));
+ }
+ std::for_each(threads.begin(), threads.end(), [](std::thread& theThread)
+ {
+ theThread.join();
+ });
- for (int i = 0 ; i < 3 ; i++)
+ for (int i = 0 ; i < 3 ; ++i)
{
CHECK(res[i]);
}