Browse Source

!6287 fix exit core dump

Merge pull request !6287 from kisnwang/fix-exit-core-dump
tags/v1.0.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
61c00fc4e7
2 changed files with 12 additions and 11 deletions
  1. +11
    -9
      mindspore/ccsrc/backend/session/executor.cc
  2. +1
    -2
      mindspore/ccsrc/backend/session/executor.h

+ 11
- 9
mindspore/ccsrc/backend/session/executor.cc View File

@@ -91,6 +91,8 @@ Executor::Executor(const std::string &device_name, uint32_t device_id) {
worker_ = std::make_shared<std::thread>(&Executor::WorkerLoop, this);
}

Executor::~Executor() { WorkerJoin(); }

void Executor::CheckException() {
if (exception_ptr_ != nullptr) {
auto exception_ptr = exception_ptr_;
@@ -100,8 +102,15 @@ void Executor::CheckException() {
}

void Executor::WorkerJoin() {
StopWorker();
worker_->join();
if (worker_->joinable()) {
{
std::unique_lock<std::mutex> lock(task_mutex_);
auto task = std::make_shared<ExitTask>();
ready_tasks_.push(task);
task_cond_var_.notify_all();
}
worker_->join();
}
}

void Executor::WorkerLoop() {
@@ -282,13 +291,6 @@ bool Executor::DestroyCommGroup(const std::string &group_name) {
return task->result_;
}

void Executor::StopWorker() {
std::unique_lock<std::mutex> lock(task_mutex_);
auto task = std::make_shared<ExitTask>();
ready_tasks_.push(task);
task_cond_var_.notify_all();
}

void Executor::OnWorkerExit() {
if (device_name_ == kAscendDevice) {
device::KernelRuntimeManager::Instance().ReleaseKernelRuntime(kAscendDevice, device_id_);


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

@@ -146,7 +146,7 @@ class ExitTask : public Task {
class Executor {
public:
Executor(const std::string &device_name, uint32_t device_id);
~Executor() = default;
~Executor();
void WorkerLoop();
void WorkerJoin();
GraphId CompileGraphAsync(const SessionPtr &session, const AnfNodePtrList &lst, const AnfNodePtrList &outputs);
@@ -168,7 +168,6 @@ class Executor {
std::vector<std::shared_ptr<RunGraphTask>> GetNewReadyTasks();
bool IsAllInputsReady(const std::vector<tensor::TensorPtr> &inputs);
void CheckException();
void StopWorker();
void OnWorkerExit();

uint32_t device_id_;


Loading…
Cancel
Save