aboutsummaryrefslogtreecommitdiff
path: root/test/test_blocking_counter.cc
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2017-12-12 14:22:24 -0800
committerMiao Wang <miaowang@google.com>2017-12-12 16:14:38 -0800
commit1963df9ac4a0424674e72ef5da522b5d830605fd (patch)
treeefd8fbbe69f13c4057f2cc5a5b1f7852fd57a2ab /test/test_blocking_counter.cc
parentcbcfdf963151219ca77f54657defabde8d845bac (diff)
downloadgemmlowp-1963df9ac4a0424674e72ef5da522b5d830605fd.tar.gz
Rebase gemmlowp to 6a2a908temp_72223856
Bug: 70573221 Test: mm Test: mm and Pixel2 boot Test: NeuralNetworksTest pass Change-Id: I8fac98811e9a276d3ff8054167dc45225c04147e
Diffstat (limited to 'test/test_blocking_counter.cc')
-rw-r--r--test/test_blocking_counter.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/test_blocking_counter.cc b/test/test_blocking_counter.cc
index 8260576..d1e0932 100644
--- a/test/test_blocking_counter.cc
+++ b/test/test_blocking_counter.cc
@@ -1,4 +1,4 @@
-// Copyright 2015 Google Inc. All Rights Reserved.
+// Copyright 2015 The Gemmlowp Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -13,8 +13,8 @@
// limitations under the License.
#include "test.h"
+#include "../profiling/pthread_everywhere.h"
-#include <pthread.h>
#include <vector>
#include "../internal/multi_thread_gemm.h"
@@ -26,6 +26,7 @@ class Thread {
Thread(BlockingCounter* blocking_counter, int number_of_times_to_decrement)
: blocking_counter_(blocking_counter),
number_of_times_to_decrement_(number_of_times_to_decrement),
+ finished_(false),
made_the_last_decrement_(false) {
pthread_create(&thread_, nullptr, ThreadFunc, this);
}
@@ -33,7 +34,9 @@ class Thread {
~Thread() { Join(); }
bool Join() const {
- pthread_join(thread_, nullptr);
+ if (!finished_) {
+ pthread_join(thread_, nullptr);
+ }
return made_the_last_decrement_;
}
@@ -45,6 +48,7 @@ class Thread {
Check(!made_the_last_decrement_);
made_the_last_decrement_ = blocking_counter_->DecrementCount();
}
+ finished_ = true;
}
static void* ThreadFunc(void* ptr) {
@@ -55,6 +59,7 @@ class Thread {
BlockingCounter* const blocking_counter_;
const int number_of_times_to_decrement_;
pthread_t thread_;
+ bool finished_;
bool made_the_last_decrement_;
};