Browse Source

fix asynrun segmentfault

tags/v1.1.0
kswang 5 years ago
parent
commit
64e43c8930
2 changed files with 7 additions and 3 deletions
  1. +6
    -3
      mindspore/ccsrc/backend/session/executor.cc
  2. +1
    -0
      mindspore/ccsrc/backend/session/executor.h

+ 6
- 3
mindspore/ccsrc/backend/session/executor.cc View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "backend/session/executor.h"
#include <algorithm>
#include <exception>
#include "backend/session/executor_manager.h"
#include "runtime/device/kernel_runtime_manager.h"
@@ -169,11 +170,12 @@ void Executor::WorkerLoop() {
} catch (const std::exception &e) {
MsException::GetInstance().SetException();
}
{
std::unique_lock<std::mutex> lock(task_mutex_);
done_tasks_.emplace_back(task);
}
if (task->type_ != kRunGraph || task->sync_run_) {
task = nullptr;
sync_cond_var_.notify_all();
} else {
task = nullptr;
}
}
}
@@ -304,6 +306,7 @@ void Executor::RunGraphAsync(const SessionPtr &session, const GraphId &graph_id,
}
std::unique_lock<std::mutex> lock(task_mutex_);
ready_tasks_.push(task);
done_tasks_.clear();
task_cond_var_.notify_all();
}



+ 1
- 0
mindspore/ccsrc/backend/session/executor.h View File

@@ -183,6 +183,7 @@ class Executor {
std::condition_variable sync_cond_var_;
std::queue<std::shared_ptr<Task>> ready_tasks_;
std::list<std::shared_ptr<RunGraphTask>> pending_tasks_;
std::vector<std::shared_ptr<Task>> done_tasks_;
std::shared_ptr<std::thread> worker_;
};
} // namespace session


Loading…
Cancel
Save