Closed
[WIP]【PR】: 简要描述 #6
nevermoreAdd on Jul 7Closed at Jul 8
[WIP]【PR】: 简要描述 #6
Closed
Merged fromfeat/aicpu-timeout-unifyintomaster
Total: 10 files changed+33-15
| @@ -45,6 +45,7 @@ bool IsEventIdAndRasCodeMatch(const uint32_t deviceId, const std::vector<EventRa | |||
| 45 | bool HasBlacklistEventOnDevice(const uint32_t deviceId, const std::map<uint32_t, std::string>& eventIdBlkList = g_mulBitEccEventId); | 45 | bool HasBlacklistEventOnDevice(const uint32_t deviceId, const std::map<uint32_t, std::string>& eventIdBlkList = g_mulBitEccEventId); |
| 46 | bool IsSmmuFault(const uint32_t deviceId); | 46 | bool IsSmmuFault(const uint32_t deviceId); |
| 47 | void ProcessSdmaError(TaskInfo *taskInfo); | 47 | void ProcessSdmaError(TaskInfo *taskInfo); |
| 48 | +void ProcAicpuTimeoutStopProcess(Device * const dev); | ||
| 48 | class DeviceErrorProc { | 49 | class DeviceErrorProc { |
| 49 | public: | 50 | public: |
| 50 | explicit DeviceErrorProc(Device *dev); | 51 | explicit DeviceErrorProc(Device *dev); |
| @@ -48,6 +48,9 @@ constexpr uint8_t RT_STARS_TASK_KERNEL_CREDIT_SCALE_UINT8 = 4U; | |||
| 48 | constexpr uint16_t RT_STARS_DEFAULT_HCCL_FFTSPLUS_TIMEOUT = 1770U; | 48 | constexpr uint16_t RT_STARS_DEFAULT_HCCL_FFTSPLUS_TIMEOUT = 1770U; |
| 49 | constexpr float32_t RT_MC_KERNEL_CREDIT_SCALE = 33554.432F; | 49 | constexpr float32_t RT_MC_KERNEL_CREDIT_SCALE = 33554.432F; |
| 50 | extern bool g_isAddrFlatDevice; | 50 | extern bool g_isAddrFlatDevice; |
| 51 | +// Note: RT_STARS_DEFAULT_AICPU_KERNEL_CREDIT is no longer used as AICPU operator default credit | ||
| 52 | +// (GetAicpuKernelCreditInternal now uses GetStarsFftsDefaultKernelCredit to align with AICore). | ||
| 53 | +// It is kept only for timeout_set_task (timeout_set_task_v100.cc / v200_base.cc). | ||
| 51 | #define RT_STARS_DEFAULT_AICPU_KERNEL_CREDIT (!g_isAddrFlatDevice ? RT_STARS_DEFAULT_AICPU_KERNEL_CREDIT_MIN : RT_STARS_DEFAULT_AICPU_KERNEL_CREDIT_MAX) | 54 | #define RT_STARS_DEFAULT_AICPU_KERNEL_CREDIT (!g_isAddrFlatDevice ? RT_STARS_DEFAULT_AICPU_KERNEL_CREDIT_MIN : RT_STARS_DEFAULT_AICPU_KERNEL_CREDIT_MAX) |
| 52 | /* stars send interrupt direction */ | 55 | /* stars send interrupt direction */ |
| 53 | enum RtStarsSqeIntDirType { | 56 | enum RtStarsSqeIntDirType { |
| @@ -27,6 +27,20 @@ | |||
| 27 | namespace cce { | 27 | namespace cce { |
| 28 | namespace runtime { | 28 | namespace runtime { |
| 29 | 29 | ||
| 30 | +void ProcAicpuTimeoutStopProcess(Device * const dev) | ||
| 31 | +{ | ||
| 32 | + if (dev == nullptr) { | ||
| 33 | + return; | ||
| 34 | + } | ||
| 35 | + const uint32_t deviceId = dev->Id_(); | ||
| 36 | + const rtError_t ret = Runtime::Instance()->StopAicpuExecutor(deviceId, 0U, true); | ||
| 37 | + if (ret != RT_ERROR_NONE) { | ||
| 38 | + RT_LOG(RT_LOG_ERROR, "StopAicpuExecutor failed, device_id=%u, ret=%u.", deviceId, ret); | ||
| 39 | + return; | ||
| 40 | + } | ||
| 41 | + RT_LOG(RT_LOG_INFO, "AICPU process stopped after timeout, device_id=%u.", deviceId); | ||
| 42 | +} | ||
| 43 | + | ||
| 30 | // alloc a huge page size | 44 | // alloc a huge page size |
| 31 | 45 | ||
| 32 | const std::map<uint64_t, DeviceErrorProc::ErrorInfoProc> DeviceErrorProc::funcMap_ = { | 46 | const std::map<uint64_t, DeviceErrorProc::ErrorInfoProc> DeviceErrorProc::funcMap_ = { |
| @@ -1579,6 +1579,10 @@ void StarsEngine::ProcLogicCqReport(const rtLogicCqReport_t &logicCq, const bool | |||
| 1579 | if (!reportTask->stream->IsSeparateSendAndRecycle()) { | 1579 | if (!reportTask->stream->IsSeparateSendAndRecycle()) { |
| 1580 | reportTask->stream->EnterFailureAbort(); | 1580 | reportTask->stream->EnterFailureAbort(); |
| 1581 | } | 1581 | } |
| 1582 | + if ((logicCq.sqeType == static_cast<uint8_t>(RT_STARS_SQE_TYPE_AICPU)) && | ||
| 1583 | + ((logicCq.errorType & static_cast<uint8_t>(RT_STARS_CQE_ERR_TYPE_TASK_TIMEOUT)) != 0U)) { | ||
| 1584 | + ProcAicpuTimeoutStopProcess(GetDevice()); | ||
| 1585 | + } | ||
| 1582 | } else { | 1586 | } else { |
| 1583 | (void)GetDevice()->ProcDeviceErrorInfo(); | 1587 | (void)GetDevice()->ProcDeviceErrorInfo(); |
| 1584 | } | 1588 | } |
| @@ -125,19 +125,15 @@ uint64_t ConvertTimeoutToInner(uint64_t timeout) | |||
| 125 | return timeoutTmp; | 125 | return timeoutTmp; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | -static inline bool IsCpuKernelSupportTimeout(const uint32_t flag) | ||
| 129 | -{ | ||
| 130 | - return ((flag & RT_KERNEL_USE_SPECIAL_TIMEOUT) != 0U); | ||
| 131 | -} | ||
| 132 | - | ||
| 133 | uint64_t ConvertAicpuTimeout(const rtAicpuArgsEx_t * const argsInfo, const TaskCfg *taskCfg, | 128 | uint64_t ConvertAicpuTimeout(const rtAicpuArgsEx_t * const argsInfo, const TaskCfg *taskCfg, |
| 134 | const uint32_t flag) | 129 | const uint32_t flag) |
| 135 | { | 130 | { |
| 131 | + (void)flag; // 所有 AICPU 算子均支持设置超时,不再需要 flag 拦截 | ||
| 136 | if ((taskCfg != nullptr) && (taskCfg->isExtendValid == 1U) && (taskCfg->extend.timeout != 0U)) { | 132 | if ((taskCfg != nullptr) && (taskCfg->isExtendValid == 1U) && (taskCfg->extend.timeout != 0U)) { |
| 137 | return taskCfg->extend.timeout; | 133 | return taskCfg->extend.timeout; |
| 138 | } | 134 | } |
| 139 | 135 | ||
| 140 | - if (IsCpuKernelSupportTimeout(flag) && (argsInfo != nullptr) && (argsInfo->timeout != 0U)) { | 136 | + if ((argsInfo != nullptr) && (argsInfo->timeout != 0U)) { |
| 141 | if (argsInfo->timeout == MAX_UINT16_NUM) { | 137 | if (argsInfo->timeout == MAX_UINT16_NUM) { |
| 142 | return MAX_UINT64_NUM; // never timeout | 138 | return MAX_UINT64_NUM; // never timeout |
| 143 | } | 139 | } |
| @@ -111,14 +111,14 @@ uint16_t GetSdmaKernelCredit() | |||
| 111 | static uint16_t GetAicpuKernelCreditInternal(uint64_t timeout, bool defaultNeverTimeout) | 111 | static uint16_t GetAicpuKernelCreditInternal(uint64_t timeout, bool defaultNeverTimeout) |
| 112 | { | 112 | { |
| 113 | uint64_t tmpTimeout = 0UL; | 113 | uint64_t tmpTimeout = 0UL; |
| 114 | - uint16_t kernelCredit = RT_STARS_DEFAULT_AICPU_KERNEL_CREDIT; | 114 | + uint16_t kernelCredit = Runtime::Instance()->GetStarsFftsDefaultKernelCredit(); |
| 115 | const RtTimeoutConfig &timeoutCfg = Runtime::Instance()->GetTimeoutConfig(); | 115 | const RtTimeoutConfig &timeoutCfg = Runtime::Instance()->GetTimeoutConfig(); |
| 116 | if (timeout != 0U) { | 116 | if (timeout != 0U) { |
| 117 | tmpTimeout = timeout; | 117 | tmpTimeout = timeout; |
| 118 | } else if (timeoutCfg.isCfgOpExcTaskTimeout) { | 118 | } else if (timeoutCfg.isCfgOpExcTaskTimeout) { |
| 119 | tmpTimeout = timeoutCfg.opExcTaskTimeout; | 119 | tmpTimeout = timeoutCfg.opExcTaskTimeout; |
| 120 | } else { | 120 | } else { |
| 121 | - // no op | 121 | + return TransKernelCreditCreditByChip(kernelCredit); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | if (defaultNeverTimeout && | 124 | if (defaultNeverTimeout && |
| @@ -202,9 +202,7 @@ void ConstructAICpuSqeForDavinciTask(TaskInfo* taskInfo, rtStarsSqe_t *const com | |||
| 202 | sqe->sqe_index = 0U; // useless | 202 | sqe->sqe_index = 0U; // useless |
| 203 | const uint32_t curVersion = stm->Device_()->GetTschVersion() & 0xFFFFU; // 取低16位作为版本号 | 203 | const uint32_t curVersion = stm->Device_()->GetTschVersion() & 0xFFFFU; // 取低16位作为版本号 |
| 204 | const bool isNewVersion = curVersion >= TS_VERSION_AICPU_SINGLE_TIMEOUT; | 204 | const bool isNewVersion = curVersion >= TS_VERSION_AICPU_SINGLE_TIMEOUT; |
| 205 | - const bool isSupportTimeout = | 205 | + const bool isNeedNoTimeout = (aicpuTaskInfo->timeout > RUNTIME_DAVINCI_MAX_TIMEOUT) || |
| 206 | - ((sqe->kernel_type == KERNEL_TYPE_AICPU_KFC) || (sqe->kernel_type == KERNEL_TYPE_CUSTOM_KFC)); | ||
| 207 | - const bool isNeedNoTimeout = ((aicpuTaskInfo->timeout > RUNTIME_DAVINCI_MAX_TIMEOUT) && isSupportTimeout) || | ||
| 208 | (aicpuTaskInfo->timeout == MAX_UINT64_NUM); | 206 | (aicpuTaskInfo->timeout == MAX_UINT64_NUM); |
| 209 | sqe->kernel_credit = isNeedNoTimeout ? RT_STARS_NEVER_TIMEOUT_KERNEL_CREDIT : static_cast<uint8_t>(GetAicpuKernelCredit(aicpuTaskInfo->timeout)); | 207 | sqe->kernel_credit = isNeedNoTimeout ? RT_STARS_NEVER_TIMEOUT_KERNEL_CREDIT : static_cast<uint8_t>(GetAicpuKernelCredit(aicpuTaskInfo->timeout)); |
| 210 | 208 | ||
| @@ -126,9 +126,7 @@ void ConstructDavidAICpuSqeForDavinciTaskBase(TaskInfo *const taskInfo, rtDavidS | |||
| 126 | 126 | ||
| 127 | /* word3 */ | 127 | /* word3 */ |
| 128 | sqe->sqeIndex = 0U; // useless | 128 | sqe->sqeIndex = 0U; // useless |
| 129 | - const bool isSupportTimeout = | 129 | + const bool isNeedNoTimeout = (aicpuTaskInfo->timeout > RUNTIME_DAVINCI_MAX_TIMEOUT) || |
| 130 | - ((sqe->kernelType == KERNEL_TYPE_AICPU_KFC) || (sqe->kernelType == KERNEL_TYPE_CUSTOM_KFC)); | ||
| 131 | - const bool isNeedNoTimeout = ((aicpuTaskInfo->timeout > RUNTIME_DAVINCI_MAX_TIMEOUT) && isSupportTimeout) || | ||
| 132 | (aicpuTaskInfo->timeout == MAX_UINT64_NUM); | 130 | (aicpuTaskInfo->timeout == MAX_UINT64_NUM); |
| 133 | sqe->kernelCredit = isNeedNoTimeout ? RT_STARS_NEVER_TIMEOUT_KERNEL_CREDIT : | 131 | sqe->kernelCredit = isNeedNoTimeout ? RT_STARS_NEVER_TIMEOUT_KERNEL_CREDIT : |
| 134 | static_cast<uint8_t>(GetAicpuKernelCreditV200(aicpuTaskInfo->timeout)); | 132 | static_cast<uint8_t>(GetAicpuKernelCreditV200(aicpuTaskInfo->timeout)); |
| @@ -273,6 +273,10 @@ void ProcCqReportException(Device * const dev, rtLogicCqReport_t &logicCq, | |||
| 273 | if (!reportTask->stream->IsSeparateSendAndRecycle()) { | 273 | if (!reportTask->stream->IsSeparateSendAndRecycle()) { |
| 274 | reportTask->stream->EnterFailureAbort(); | 274 | reportTask->stream->EnterFailureAbort(); |
| 275 | } | 275 | } |
| 276 | + if ((logicCq.sqeType == RT_DAVID_SQE_TYPE_AICPU_D) && | ||
| 277 | + ((logicCq.errorType & static_cast<uint8_t>(RT_STARS_CQE_ERR_TYPE_TASK_TIMEOUT)) != 0U)) { | ||
| 278 | + ProcAicpuTimeoutStopProcess(dev); | ||
| 279 | + } | ||
| 276 | } else { | 280 | } else { |
| 277 | (void)dev->ProcDeviceErrorInfo(); | 281 | (void)dev->ProcDeviceErrorInfo(); |
| 278 | } | 282 | } |
| @@ -7303,7 +7303,7 @@ TEST_F(ApiTest, RT_SetOpExecuteWithMs_5) | |||
| 7303 | rtInstance->SetSocVersion("AS31XM1X"); | 7303 | rtInstance->SetSocVersion("AS31XM1X"); |
| 7304 | rtInstance->timeoutConfig_.isCfgOpExcTaskTimeout = false; | 7304 | rtInstance->timeoutConfig_.isCfgOpExcTaskTimeout = false; |
| 7305 | uint16_t kernelCredit = GetAicpuKernelCredit(0); | 7305 | uint16_t kernelCredit = GetAicpuKernelCredit(0); |
| 7306 | - EXPECT_EQ(kernelCredit, 254); | 7306 | + EXPECT_EQ(kernelCredit, 3); |
| 7307 | kernelCredit = GetAicoreKernelCredit(0); | 7307 | kernelCredit = GetAicoreKernelCredit(0); |
| 7308 | EXPECT_EQ(kernelCredit, 3); | 7308 | EXPECT_EQ(kernelCredit, 3); |
| 7309 | kernelCredit = GetSdmaKernelCredit(); | 7309 | kernelCredit = GetSdmaKernelCredit(); |