Browse Source

fix bug of Ascend context

tags/v1.1.0
caifubi 5 years ago
parent
commit
0e266beb6f
2 changed files with 5 additions and 25 deletions
  1. +5
    -24
      mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc
  2. +0
    -1
      mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.h

+ 5
- 24
mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc View File

@@ -335,16 +335,6 @@ bool AscendKernelRuntime::Load(session::KernelGraph *graph, bool is_task_sink) {
return true;
}

// Bind hccl context to current thread
if (graph->is_dynamic_shape()) {
if (rt_context_hccl_ != nullptr) {
auto ret = rtCtxSetCurrent(rt_context_hccl_);
if (ret != RT_ERROR_NONE) {
MS_LOG(EXCEPTION) << "Call rtCtxSetCurrent failed, ret[" << ret << "]";
}
}
}

// Do HcomExecutorInitialize
if (graph->is_dynamic_shape() && !HcclExecutorManager::GetInstance().Initialize()) {
MS_LOG(ERROR) << "Init Hccl Executor Failed";
@@ -712,17 +702,17 @@ bool AscendKernelRuntime::InitDevice() {
}
}

ret = rtCtxGetCurrent(&rt_context_hccl_);
if (ret != RT_ERROR_NONE || rt_context_hccl_ == nullptr) {
// Context will be created by rtSetDevice
ret = rtCtxGetCurrent(&rt_context_);
if (ret != RT_ERROR_NONE || rt_context_ == nullptr) {
MS_LOG(ERROR) << "Call rtCtxGetCurrent failed, ret[" << ret << "]";
return false;
}
CreateContext();
ret = rtStreamCreate(&stream_, 0);
if (ret != RT_ERROR_NONE) {
MS_LOG(EXCEPTION) << "Call rtStreamCreate, ret[" << ret << "]";
}

return true;
}

@@ -736,21 +726,12 @@ bool AscendKernelRuntime::ResetDevice(uint32_t device_id) {
stream_ = nullptr;
}

if (rt_context_ != nullptr) {
auto ret = rtCtxDestroy(rt_context_);
if (ret != RT_ERROR_NONE) {
MS_EXCEPTION(DeviceProcessError) << "Call rtCtxDestroy, ret[" << ret << "]";
}
rt_context_ = nullptr;
}

auto ret = rtDeviceReset(device_id);
if (ret != RT_ERROR_NONE) {
MS_EXCEPTION(DeviceProcessError) << "Call rtDeviceReset, ret[" << ret << "]";
}
// set to nullptr as its not created, only bounded to existing context
rt_context_hccl_ = nullptr;

rt_context_ = nullptr;
return true;
}



+ 0
- 1
mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.h View File

@@ -85,7 +85,6 @@ class AscendKernelRuntime : public KernelRuntime {
void ReportProfilingData();

rtContext_t rt_context_{nullptr};
rtContext_t rt_context_hccl_{nullptr};
bool initialized_{false};
unordered_map<GraphId, vector<std::shared_ptr<TaskInfo>>> task_map_;
unordered_map<GraphId, std::shared_ptr<ge::model_runner::DavinciModel>> graph_model_map_;


Loading…
Cancel
Save