!10150 Bugfix for Ascend device context

From: @jojobugfree
Reviewed-by: @zhoufeng54,@kisnwang
Signed-off-by: @kisnwang
pull/10150/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 92c5548790

@ -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;
}

@ -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