|
|
|
@ -109,6 +109,43 @@ bool MsContext::set_backend_policy(const std::string &policy) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_TDTQUE
|
|
|
|
|
namespace py = pybind11;
|
|
|
|
|
acltdtChannelHandle *MsContext::CreateAclTdtChannelHandle() {
|
|
|
|
|
uint32_t device_id = get_param<uint32_t>(MS_CTX_DEVICE_ID);
|
|
|
|
|
std::string kReceivePrefix = "TF_RECEIVE_";
|
|
|
|
|
std::string channel_name = "_npu_log";
|
|
|
|
|
acltdtChannelHandle *acl_handle = acltdtCreateChannel(device_id, (kReceivePrefix + channel_name).c_str());
|
|
|
|
|
if (acl_handle != nullptr) {
|
|
|
|
|
MS_LOG(INFO) << "Success to create acltdt handle.";
|
|
|
|
|
acl_handle_ = acl_handle;
|
|
|
|
|
TdtHandle::AddHandle(&acl_handle_);
|
|
|
|
|
}
|
|
|
|
|
return acl_handle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MsContext::DestroyAclTdtChannelHandle() {
|
|
|
|
|
if (acl_handle_ == nullptr) {
|
|
|
|
|
MS_LOG(INFO) << "The acl handle has been destroyed and the point is nullptr";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
aclError stopStatus = acltdtStopChannel(acl_handle_);
|
|
|
|
|
if (stopStatus != ACL_SUCCESS) {
|
|
|
|
|
MS_LOG(ERROR) << "Failed stop acl data channel and the stopStatus is " << stopStatus << std::endl;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MS_LOG(INFO) << "Succeed stop acl data channel for host queue ";
|
|
|
|
|
|
|
|
|
|
aclError destroydStatus = acltdtDestroyChannel(acl_handle_);
|
|
|
|
|
if (destroydStatus != ACL_SUCCESS) {
|
|
|
|
|
MS_LOG(ERROR) << "Failed destroy acl channel and the destroyStatus is " << destroydStatus << std::endl;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
TdtHandle::DelHandle(&acl_handle_);
|
|
|
|
|
MS_LOG(INFO) << "Succeed destroy acl channel";
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
std::string MsContext::backend_policy() const {
|
|
|
|
|
auto res = std::find_if(
|
|
|
|
|
policy_map_.begin(), policy_map_.end(),
|
|
|
|
@ -127,21 +164,4 @@ bool MsContext::enable_dump_ir() const {
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_TDTQUE
|
|
|
|
|
acltdtChannelHandle *MsContext::get_acl_tdt_channel_handle() {
|
|
|
|
|
if (acl_handle == nullptr) {
|
|
|
|
|
std::string kReceivePrefix = "TF_RECEIVE_";
|
|
|
|
|
std::string channel_name = "_npu_log";
|
|
|
|
|
uint32_t device_id = get_param<uint32_t>(MS_CTX_DEVICE_ID);
|
|
|
|
|
acl_handle = acltdtCreateChannel(device_id, (kReceivePrefix + channel_name).c_str());
|
|
|
|
|
if (acl_handle == nullptr) {
|
|
|
|
|
MS_LOG(ERROR) << "Failed to create acltdt handle : " << channel_name;
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
MS_LOG(INFO) << "Success to create acltdt handle: " << channel_name;
|
|
|
|
|
return acl_handle;
|
|
|
|
|
}
|
|
|
|
|
return acl_handle;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
} // namespace mindspore
|
|
|
|
|