From d4c81b7ae23728c2882c8f5909f070a88fdbf74a Mon Sep 17 00:00:00 2001 From: Wang Jiajun Date: Wed, 17 Jul 2019 20:12:34 +0800 Subject: [PATCH 1/3] fix naive engine --- src/engine/naive_engine.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/engine/naive_engine.cc b/src/engine/naive_engine.cc index 9cfe9b28f862..82f4a4e3b368 100644 --- a/src/engine/naive_engine.cc +++ b/src/engine/naive_engine.cc @@ -238,7 +238,11 @@ class NaiveEngine final : public Engine { static_cast(engine)->req_completed_ = true; } // whether action is completed - bool req_completed_; +#if DMLC_CXX11_THREAD_LOCAL + static thread_local bool req_completed_; +#else + static MX_THREAD_LOCAL bool req_completed_; +#endif /*! \brief whether it is during shutdown phase*/ std::atomic shutdown_phase_{false}; // CPU stream @@ -261,5 +265,12 @@ class NaiveEngine final : public Engine { Engine *CreateNaiveEngine() { return new NaiveEngine(); } + +#if DMLC_CXX11_THREAD_LOCAL +thread_local bool NaiveEngine::req_completed_ = false; +#else +MX_THREAD_LOCAL bool NaiveEngine::req_completed_ = false; +#endif + } // namespace engine } // namespace mxnet From 033f7923934eeb5c43b2aa79ee0e45fc0182e2c2 Mon Sep 17 00:00:00 2001 From: Wang Jiajun Date: Sun, 21 Jul 2019 15:34:49 +0800 Subject: [PATCH 2/3] remove thread local --- src/engine/naive_engine.cc | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/engine/naive_engine.cc b/src/engine/naive_engine.cc index 82f4a4e3b368..6c442181fe99 100644 --- a/src/engine/naive_engine.cc +++ b/src/engine/naive_engine.cc @@ -155,9 +155,9 @@ class NaiveEngine final : public Engine { int priority = 0, const char* opr_name = nullptr, bool wait = false) override { + bool req_completed = false; CallbackOnComplete callback = CreateCallback( - NaiveEngine::OnComplete, nullptr); - this->req_completed_ = false; + NaiveEngine::OnComplete, &req_completed); profiler::Profiler *profiler = profiler::Profiler::Get(); auto opr_deleter = [this](NaiveOpr* p) { this->DeleteOperator(p); @@ -202,7 +202,7 @@ class NaiveEngine final : public Engine { for (auto var : mutable_vars) { ++var->version_; } - CHECK(this->req_completed_) + CHECK(req_completed) << "NaiveEngine only support synchronize Push so far"; if (profiling) { opr->opr_profile->stop(); @@ -235,14 +235,9 @@ class NaiveEngine final : public Engine { // callback to oncomplete static void OnComplete(Engine *engine, void *param, const dmlc::Error* error) { - static_cast(engine)->req_completed_ = true; + bool *req_completed = static_cast(param); + *req_completed = true; } - // whether action is completed -#if DMLC_CXX11_THREAD_LOCAL - static thread_local bool req_completed_; -#else - static MX_THREAD_LOCAL bool req_completed_; -#endif /*! \brief whether it is during shutdown phase*/ std::atomic shutdown_phase_{false}; // CPU stream @@ -266,11 +261,5 @@ Engine *CreateNaiveEngine() { return new NaiveEngine(); } -#if DMLC_CXX11_THREAD_LOCAL -thread_local bool NaiveEngine::req_completed_ = false; -#else -MX_THREAD_LOCAL bool NaiveEngine::req_completed_ = false; -#endif - } // namespace engine } // namespace mxnet From f858c3541af3284e32bf4ebebd23727e7971b94e Mon Sep 17 00:00:00 2001 From: Wang Jiajun Date: Mon, 22 Jul 2019 10:21:54 +0800 Subject: [PATCH 3/3] trigger CI