From d8366a67fa91586f93d737a0af78422074914829 Mon Sep 17 00:00:00 2001 From: liaogang Date: Wed, 14 Sep 2016 11:30:30 +0800 Subject: [PATCH] fix bug on thread barrier --- paddle/math/tests/test_perturbation.cpp | 6 ++++++ paddle/utils/arch/osx/Locks.cpp | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/paddle/math/tests/test_perturbation.cpp b/paddle/math/tests/test_perturbation.cpp index 51e346fef91..050f2ca9ced 100644 --- a/paddle/math/tests/test_perturbation.cpp +++ b/paddle/math/tests/test_perturbation.cpp @@ -254,4 +254,10 @@ int main(int argc, char** argv) { return RUN_ALL_TESTS(); } +#else + +int main(int argc, char const* argv[]) { + return 0; +} + #endif diff --git a/paddle/utils/arch/osx/Locks.cpp b/paddle/utils/arch/osx/Locks.cpp index 5e0411624fd..8fe482ddddd 100644 --- a/paddle/utils/arch/osx/Locks.cpp +++ b/paddle/utils/arch/osx/Locks.cpp @@ -49,7 +49,7 @@ void Semaphore::post() { class SpinLockPrivate { public: - SpinLockPrivate(): lock_(0) {} + SpinLockPrivate(): lock_(OS_SPINLOCK_INIT) {} OSSpinLock lock_; char padding_[64 - sizeof(OSSpinLock)]; // Padding to cache line size @@ -92,7 +92,7 @@ public: inline bool wait() { pthread_mutex_lock(&mutex); ++count; - if (count > tripCount) { + if (count >= tripCount) { count = 0; pthread_cond_broadcast(&cond); pthread_mutex_unlock(&mutex); -- GitLab