Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

fix naive engine for multi-threaded inference #15574

Merged
merged 3 commits into from
Aug 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/engine/naive_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<NaiveEngine*>(engine)->req_completed_ = true;
bool *req_completed = static_cast<bool*>(param);
*req_completed = true;
}
// whether action is completed
bool req_completed_;
/*! \brief whether it is during shutdown phase*/
std::atomic<bool> shutdown_phase_{false};
// CPU stream
Expand All @@ -261,5 +260,6 @@ class NaiveEngine final : public Engine {
Engine *CreateNaiveEngine() {
return new NaiveEngine();
}

} // namespace engine
} // namespace mxnet