已合并
ccu kernel map add mutex #3119
zhengjinwei_y创建于 6月26日
ccu kernel map add mutex #3119
已合并
从已删除 :master合入到cann/hcommmaster
共 1 个文件变更+4-1
| @@ -507,8 +507,8 @@ CcuResult CcuKernelMgr::Translate(const std::vector<CcuKernelHandle> &kernelHand | |||
| 507 | return CcuResult::CCU_SUCCESS; | 507 | return CcuResult::CCU_SUCCESS; |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | - std::unique_lock<std::mutex> lock(translateMutex_); | ||
| 511 | std::vector<CcuKernel *> kernels{}; | 510 | std::vector<CcuKernel *> kernels{}; |
| 511 | + std::unique_lock<std::mutex> mapLock(kernelMapMutex_); | ||
| 512 | for (const auto kernelHandle : kernelHandles) { | 512 | for (const auto kernelHandle : kernelHandles) { |
| 513 | const auto &iter = kernelMap_.find(kernelHandle); | 513 | const auto &iter = kernelMap_.find(kernelHandle); |
| 514 | if (iter == kernelMap_.end()) { | 514 | if (iter == kernelMap_.end()) { |
| @@ -519,9 +519,11 @@ CcuResult CcuKernelMgr::Translate(const std::vector<CcuKernelHandle> &kernelHand | |||
| 519 | 519 | ||
| 520 | kernels.push_back(iter->second.get()); | 520 | kernels.push_back(iter->second.get()); |
| 521 | } | 521 | } |
| 522 | + mapLock.unlock(); | ||
| 522 | 523 | ||
| 523 | constexpr bool isFuncBlock = false; // 当前不支持MC2 | 524 | constexpr bool isFuncBlock = false; // 当前不支持MC2 |
| 524 | 525 | ||
| 526 | + std::unique_lock<std::mutex> translateLock(translateMutex_); | ||
| 525 | CCU_CHK_RET(TransRepResToPhyRes(kernels, devLogicId_)); | 527 | CCU_CHK_RET(TransRepResToPhyRes(kernels, devLogicId_)); |
| 526 | CCU_CHK_RET(TransRepSequenceToMicrocode(kernels, isFuncBlock)); | 528 | CCU_CHK_RET(TransRepSequenceToMicrocode(kernels, isFuncBlock)); |
| 527 | 529 | ||
| @@ -729,6 +731,7 @@ HcclResult CcuKernelMgr::TransRepSequenceToMicrocode( | |||
| 729 | 731 | ||
| 730 | CcuKernel *CcuKernelMgr::GetKernel(const CcuKernelHandle kernelHandle) | 732 | CcuKernel *CcuKernelMgr::GetKernel(const CcuKernelHandle kernelHandle) |
| 731 | { | 733 | { |
| 734 | + std::unique_lock<std::mutex> lock(kernelMapMutex_); | ||
| 732 | auto it = kernelMap_.find(kernelHandle); | 735 | auto it = kernelMap_.find(kernelHandle); |
| 733 | if (it == kernelMap_.end()) { | 736 | if (it == kernelMap_.end()) { |
| 734 | HCCL_ERROR("[CcuKernelMgr][%s] handle[%llx] is not existed.", | 737 | HCCL_ERROR("[CcuKernelMgr][%s] handle[%llx] is not existed.", |