From d225074c53b39ebf109056c8135cca5a2ee6926e Mon Sep 17 00:00:00 2001 From: Wang Jiajun Date: Tue, 20 Aug 2019 19:26:47 -0500 Subject: [PATCH] fix naive engine for multi-threaded inference (#15574) * fix naive engine * remove thread local * trigger CI --- src/engine/naive_engine.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/naive_engine.cc b/src/engine/naive_engine.cc index 92b38a8ea368..a7a9e992db7b 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,10 +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 - bool req_completed_; /*! \brief whether it is during shutdown phase*/ std::atomic shutdown_phase_{false}; // CPU stream @@ -261,5 +260,6 @@ class NaiveEngine final : public Engine { Engine *CreateNaiveEngine() { return new NaiveEngine(); } + } // namespace engine } // namespace mxnet