已合并
CleanCode #826
leihuan1创建于 3月12日
CleanCode #826
已合并
共 12 个文件变更+8-14
| @@ -8,8 +8,8 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | /*! | 10 | /*! |
| 11 | - * This is an empyt file, included for compatibility with old version. | 11 | + * This is an empty file, included for compatibility with old version. |
| 12 | - * If you want to use aclmdl api, please install the corresponding package to overrite this file. | 12 | + * If you want to use aclmdl api, please install the corresponding package to override this file. |
| 13 | * | 13 | * |
| 14 | * 这是一个空文件,是为了兼容老的版本,如果您想用aclmdl接口,请安装对应的包覆盖本文件。 | 14 | * 这是一个空文件,是为了兼容老的版本,如果您想用aclmdl接口,请安装对应的包覆盖本文件。 |
| 15 | * */ | 15 | * */ |
| @@ -22,7 +22,7 @@ public: | |||
| 22 | KernelDfxInfo(const KernelDfxInfo&) = delete; | 22 | KernelDfxInfo(const KernelDfxInfo&) = delete; |
| 23 | KernelDfxInfo& operator=(const KernelDfxInfo&) = delete; | 23 | KernelDfxInfo& operator=(const KernelDfxInfo&) = delete; |
| 24 | 24 | ||
| 25 | - static KernelDfxInfo * Instance() | 25 | + static KernelDfxInfo* Instance() |
| 26 | { | 26 | { |
| 27 | static KernelDfxInfo instance; | 27 | static KernelDfxInfo instance; |
| 28 | return &instance; | 28 | return &instance; |
| @@ -654,7 +654,6 @@ rtError_t Context::TaskReclaimforSyncDevice(const mmTimespec startTime, int32_t | |||
| 654 | "Sync stream timeout=%dms, device_id=%d.", timeout, device_->Id_()); | 654 | "Sync stream timeout=%dms, device_id=%d.", timeout, device_->Id_()); |
| 655 | (void)sched_yield(); | 655 | (void)sched_yield(); |
| 656 | } | 656 | } |
| 657 | - | ||
| 658 | } | 657 | } |
| 659 | return firstError; | 658 | return firstError; |
| 660 | } | 659 | } |
| @@ -1925,8 +1924,6 @@ ERROR_RECYCLE: | |||
| 1925 | return RT_ERROR_DEBUG_UNREGISTER_FAILED; | 1924 | return RT_ERROR_DEBUG_UNREGISTER_FAILED; |
| 1926 | } | 1925 | } |
| 1927 | 1926 | ||
| 1928 | - | ||
| 1929 | - | ||
| 1930 | rtError_t Context::GetDevArgsAddr(Stream * const stm, const rtArgsEx_t * const argsInfo, void ** const devArgsAddr, | 1927 | rtError_t Context::GetDevArgsAddr(Stream * const stm, const rtArgsEx_t * const argsInfo, void ** const devArgsAddr, |
| 1931 | void ** const argsHandle) const | 1928 | void ** const argsHandle) const |
| 1932 | { | 1929 | { |
| @@ -147,7 +147,6 @@ void DeviceSnapshot::RecordFuncCallAddrAndSize(TaskInfo *const task) | |||
| 147 | { | 147 | { |
| 148 | static const auto& handlerMap = GetHandlerMap(); | 148 | static const auto& handlerMap = GetHandlerMap(); |
| 149 | auto it = handlerMap.find(task->type); | 149 | auto it = handlerMap.find(task->type); |
| 150 | - | ||
| 151 | if (it != handlerMap.end()) { | 150 | if (it != handlerMap.end()) { |
| 152 | it->second(task, this); | 151 | it->second(task, this); |
| 153 | } | 152 | } |
| @@ -748,7 +748,7 @@ static void ParseCcuDfxInfo(rtMultiCCUExDetailInfo_t * const multiCcuInfo, const | |||
| 748 | for (uint8_t idx = 0U; idx < multiCcuInfo->ccuMissionNum; idx++) { | 748 | for (uint8_t idx = 0U; idx < multiCcuInfo->ccuMissionNum; idx++) { |
| 749 | uint8_t dieId = multiCcuInfo->missionInfo[idx].dieId; | 749 | uint8_t dieId = multiCcuInfo->missionInfo[idx].dieId; |
| 750 | uint8_t missionId = multiCcuInfo->missionInfo[idx].missionId; | 750 | uint8_t missionId = multiCcuInfo->missionInfo[idx].missionId; |
| 751 | - uint32_t key = dieId << DIE_ID_SHIFT_BITS | missionId; | 751 | + uint32_t key = ((dieId << DIE_ID_SHIFT_BITS) | missionId); |
| 752 | auto it = dfxInfoMap.find(key); | 752 | auto it = dfxInfoMap.find(key); |
| 753 | if (it != dfxInfoMap.end()) { | 753 | if (it != dfxInfoMap.end()) { |
| 754 | const StarsCcuDfxInfo *dfxInfo = it->second; | 754 | const StarsCcuDfxInfo *dfxInfo = it->second; |
| @@ -864,7 +864,7 @@ rtError_t ExecuteKernelDfxInfoFunc(const uint8_t *blockAddr, const uint8_t *dump | |||
| 864 | uint32_t coreType, uint32_t coreId) | 864 | uint32_t coreType, uint32_t coreId) |
| 865 | { | 865 | { |
| 866 | rtKernelDfxInfoType type = RT_KERNEL_DFX_INFO_INVALID; | 866 | rtKernelDfxInfoType type = RT_KERNEL_DFX_INFO_INVALID; |
| 867 | - KernelDfxInfo * kernelDfxInfoInstance = KernelDfxInfo::Instance(); | 867 | + KernelDfxInfo *kernelDfxInfoInstance = KernelDfxInfo::Instance(); |
| 868 | NULL_PTR_RETURN(kernelDfxInfoInstance, RT_ERROR_INSTANCE_NULL); | 868 | NULL_PTR_RETURN(kernelDfxInfoInstance, RT_ERROR_INSTANCE_NULL); |
| 869 | 869 | ||
| 870 | DumpBlockInfo(kernelDfxInfoInstance, blockAddr, coreType, coreId); | 870 | DumpBlockInfo(kernelDfxInfoInstance, blockAddr, coreType, coreId); |
| @@ -496,7 +496,6 @@ rtError_t NpuDriver::GetAvailEventNum(const uint32_t deviceId, const uint32_t ts | |||
| 496 | const drvError_t drvRet = halResourceInfoQuery(deviceId, tsId, | 496 | const drvError_t drvRet = halResourceInfoQuery(deviceId, tsId, |
| 497 | IsSupportFeature(RtOptionalFeatureType::RT_FEATURE_DEVICE_NOTIFY_ONLY) ? DRV_RESOURCE_NOTIFY_ID : DRV_RESOURCE_EVENT_ID, | 497 | IsSupportFeature(RtOptionalFeatureType::RT_FEATURE_DEVICE_NOTIFY_ONLY) ? DRV_RESOURCE_NOTIFY_ID : DRV_RESOURCE_EVENT_ID, |
| 498 | &queryInfoInput); | 498 | &queryInfoInput); |
| 499 | - | ||
| 500 | if (drvRet != DRV_ERROR_NONE) { | 499 | if (drvRet != DRV_ERROR_NONE) { |
| 501 | DRV_ERROR_PROCESS(drvRet, "[driver interface] halResourceInfoQuery sq failed: device_id=%u, " | 500 | DRV_ERROR_PROCESS(drvRet, "[driver interface] halResourceInfoQuery sq failed: device_id=%u, " |
| 502 | "ts_id=%u, drvRetCode=%d!", deviceId, tsId, static_cast<int32_t>(drvRet)); | 501 | "ts_id=%u, drvRetCode=%d!", deviceId, tsId, static_cast<int32_t>(drvRet)); |
| @@ -219,6 +219,7 @@ void StarsEngine::WakeUpRecycleThread(void) | |||
| 219 | { | 219 | { |
| 220 | int32_t val = 0; | 220 | int32_t val = 0; |
| 221 | (void)sem_getvalue(&recycleThreadSem_, &val); | 221 | (void)sem_getvalue(&recycleThreadSem_, &val); |
| 222 | + // < 2的作用是以安全的方式唤醒回收线程,确保信号量值不超过1,避免重复唤醒或计数溢出 | ||
| 222 | if (val < 2) { | 223 | if (val < 2) { |
| 223 | (void)mmSemPost(&recycleThreadSem_); | 224 | (void)mmSemPost(&recycleThreadSem_); |
| 224 | } | 225 | } |
| @@ -1688,7 +1688,7 @@ void Program::SetProgramInvalidToDevice(const uint32_t deviceId) | |||
| 1688 | devValidMutex_[deviceId].unlock(); | 1688 | devValidMutex_[deviceId].unlock(); |
| 1689 | break; | 1689 | break; |
| 1690 | } | 1690 | } |
| 1691 | - Device * dev = devicePtr_[deviceId]; | 1691 | + Device *dev = devicePtr_[deviceId]; |
| 1692 | if (dev->ProgramSetMutexTryLock()) { | 1692 | if (dev->ProgramSetMutexTryLock()) { |
| 1693 | dev->UnRegisterProgram(this); | 1693 | dev->UnRegisterProgram(this); |
| 1694 | devicePtr_[deviceId] = nullptr; | 1694 | devicePtr_[deviceId] = nullptr; |
| @@ -62,7 +62,6 @@ private: | |||
| 62 | std::mutex deviceIdToDeviceMapLock_; | 62 | std::mutex deviceIdToDeviceMapLock_; |
| 63 | std::unordered_map<uint32_t, TprtDevice *> deviceMap_; // key is deviceId, value is device | 63 | std::unordered_map<uint32_t, TprtDevice *> deviceMap_; // key is deviceId, value is device |
| 64 | bool TprtTaskReportEnable_ = true; | 64 | bool TprtTaskReportEnable_ = true; |
| 65 | - | ||
| 66 | }; | 65 | }; |
| 67 | } | 66 | } |
| 68 | } | 67 | } |
| @@ -17,12 +17,10 @@ namespace tprt { | |||
| 17 | 17 | ||
| 18 | TprtProfiling::TprtProfiling() | 18 | TprtProfiling::TprtProfiling() |
| 19 | { | 19 | { |
| 20 | - | ||
| 21 | } | 20 | } |
| 22 | 21 | ||
| 23 | TprtProfiling::~TprtProfiling() | 22 | TprtProfiling::~TprtProfiling() |
| 24 | { | 23 | { |
| 25 | - | ||
| 26 | } | 24 | } |
| 27 | 25 | ||
| 28 | uint32_t TprtProfiling::TprtReportTask(uint64_t startTime, uint64_t endTime, uint32_t devId, TprtSqe_t headTask) const | 26 | uint32_t TprtProfiling::TprtReportTask(uint64_t startTime, uint64_t endTime, uint32_t devId, TprtSqe_t headTask) const |
| @@ -102,6 +102,7 @@ void TprtWorker::WorkerWakeUp() | |||
| 102 | { | 102 | { |
| 103 | int val = 0; | 103 | int val = 0; |
| 104 | sem_getvalue(&workerThreadSem_, &val); | 104 | sem_getvalue(&workerThreadSem_, &val); |
| 105 | + // < 2的作用是以安全的方式唤醒回收线程,确保信号量值不超过1,避免重复唤醒或计数溢出 | ||
| 105 | if (val < 2) { | 106 | if (val < 2) { |
| 106 | (void)mmSemPost(&workerThreadSem_); | 107 | (void)mmSemPost(&workerThreadSem_); |
| 107 | } | 108 | } |