Merged
adapter aclgraph mode for ccu #7438
jjc1600307376Add on 11 days ago
adapter aclgraph mode for ccu #7438
Merged
Merged fromjjc1600307376/asc-devkitonly_ghintocann/asc-devkitmaster
Total: 7 files changed+174-23
| @@ -207,4 +207,64 @@ HcclResult haclrtMemcpy(void* dst, size_t destMax, const void* src, size_t count | |||
| 207 | return HCCL_SUCCESS; | 207 | return HCCL_SUCCESS; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | +HcclResult haclrtMemset(void* dst, size_t destMax, int32_t value, size_t count) | ||
| 211 | +{ | ||
| 212 | +#ifndef AICPU_COMPILE | ||
| 213 | + CHK_PTR_NULL(dst); | ||
| 214 | + CHK_PRT_RET(count == 0, HCCL_WARNING("[haclrtMemset] count is zero"), HCCL_SUCCESS); | ||
| 215 | + | ||
| 216 | + // 图捕获场景下 runtime 只允许 RELAXED 模式下做同步 memset,这里临时切换线程捕获模式 | ||
| 217 | + aclmdlRICaptureMode mode = aclmdlRICaptureMode::ACL_MODEL_RI_CAPTURE_MODE_RELAXED; | ||
| 218 | + aclError ret = aclmdlRICaptureThreadExchangeMode(&mode); | ||
| 219 | + HCCL_DEBUG("Call aclmdlRICaptureThreadExchangeMode mode before: %d, ret: %d", mode, ret); | ||
| 220 | + if (ret == ACL_ERROR_RT_FEATURE_NOT_SUPPORT) { | ||
| 221 | + HCCL_WARNING("[haclrtMemset]aclmdlRICaptureThreadExchangeMode not support!"); | ||
| 222 | + } else { | ||
| 223 | + CHK_PRT_RET( | ||
| 224 | + ret != ACL_SUCCESS, | ||
| 225 | + HCCL_ERROR( | ||
| 226 | + "[haclrtMemset]aclmdlRICaptureThreadExchangeMode " | ||
| 227 | + "failed mode:%d, return value[%d].", | ||
| 228 | + mode, ret), | ||
| 229 | + HCCL_E_RUNTIME); | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + ret = aclrtMemset(dst, destMax, value, count); | ||
| 233 | + HCCL_DEBUG( | ||
| 234 | + "Call aclrtMemset, return[%d], para: dstAddr[%p], destMax[%llu], value[%d], count[%llu]", ret, dst, | ||
| 235 | + static_cast<unsigned long long>(destMax), value, static_cast<unsigned long long>(count)); | ||
| 236 | + if (ret != ACL_SUCCESS) { | ||
| 237 | + HCCL_ERROR( | ||
| 238 | + "[SyncSet][Mem]errNo[0x%016llx] aclrtMemset failed, " | ||
| 239 | + "return[%d], para: dstAddr[%p], destMax[%llu], value[%d], count[%llu].", | ||
| 240 | + HCCL_ERROR_CODE(HCCL_E_RUNTIME), ret, dst, static_cast<unsigned long long>(destMax), value, | ||
| 241 | + static_cast<unsigned long long>(count)); | ||
| 242 | + ret = aclmdlRICaptureThreadExchangeMode(&mode); | ||
| 243 | + CHK_PRT_RET( | ||
| 244 | + ret != ACL_SUCCESS && ret != ACL_ERROR_RT_FEATURE_NOT_SUPPORT, | ||
| 245 | + HCCL_ERROR( | ||
| 246 | + "[haclrtMemset]aclmdlRICaptureThreadExchangeMode " | ||
| 247 | + "failed mode:%d, return value[%d].", | ||
| 248 | + mode, ret), | ||
| 249 | + HCCL_E_RUNTIME); | ||
| 250 | + return HCCL_E_RUNTIME; | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + ret = aclmdlRICaptureThreadExchangeMode(&mode); | ||
| 254 | + HCCL_DEBUG("Call aclmdlRICaptureThreadExchangeMode mode before: %d, ret: %d", mode, ret); | ||
| 255 | + if (ret == ACL_ERROR_RT_FEATURE_NOT_SUPPORT) { | ||
| 256 | + HCCL_WARNING("[haclrtMemset]aclmdlRICaptureThreadExchangeMode not support!"); | ||
| 257 | + } else { | ||
| 258 | + CHK_PRT_RET( | ||
| 259 | + ret != ACL_SUCCESS, | ||
| 260 | + HCCL_ERROR( | ||
| 261 | + "[haclrtMemset]aclmdlRICaptureThreadExchangeMode " | ||
| 262 | + "failed mode:%d, return value[%d].", | ||
| 263 | + mode, ret), | ||
| 264 | + HCCL_E_RUNTIME); | ||
| 265 | + } | ||
| 266 | +#endif | ||
| 267 | + return HCCL_SUCCESS; | ||
| 268 | +} | ||
| 269 | + | ||
| 210 | } // namespace mc2_ops_hccl | 270 | } // namespace mc2_ops_hccl |
| @@ -44,6 +44,8 @@ HcclResult LoadBinaryFromFile( | |||
| 44 | const char* binPath, aclrtBinaryLoadOptionType optionType, uint32_t cpuKernelMode, aclrtBinHandle& binHandle); | 44 | const char* binPath, aclrtBinaryLoadOptionType optionType, uint32_t cpuKernelMode, aclrtBinHandle& binHandle); |
| 45 | 45 | ||
| 46 | HcclResult haclrtMemcpy(void* dst, size_t destMax, const void* src, size_t count, aclrtMemcpyKind kind); | 46 | HcclResult haclrtMemcpy(void* dst, size_t destMax, const void* src, size_t count, aclrtMemcpyKind kind); |
| 47 | + | ||
| 48 | +HcclResult haclrtMemset(void* dst, size_t destMax, int32_t value, size_t count); | ||
| 47 | } // namespace mc2_ops_hccl | 49 | } // namespace mc2_ops_hccl |
| 48 | 50 | ||
| 49 | #endif // ADAPTER_ACL_H | 51 | #endif // ADAPTER_ACL_H |
| @@ -8,6 +8,7 @@ | |||
| 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 | #include "hccl_alloc_ctx_res.h" | 10 | #include "hccl_alloc_ctx_res.h" |
| 11 | +#include "adapter_acl.h" | ||
| 11 | #include "mc2_server_debug_config.h" | 12 | #include "mc2_server_debug_config.h" |
| 12 | #include "external_alg_resolver.h" | 13 | #include "external_alg_resolver.h" |
| 13 | #include "kfc_server_protocol.h" | 14 | #include "kfc_server_protocol.h" |
| @@ -1249,8 +1250,7 @@ HcclResult CopyCcuOpParamToDevice( | |||
| 1249 | void* opParamPtr = nullptr; | 1250 | void* opParamPtr = nullptr; |
| 1250 | uint64_t opParamSize = sizeof(OpParam); | 1251 | uint64_t opParamSize = sizeof(OpParam); |
| 1251 | CHK_RET(GetOrCreateCcuCtx(comm, tagParam, opParamSize, &opParamPtr)); | 1252 | CHK_RET(GetOrCreateCcuCtx(comm, tagParam, opParamSize, &opParamPtr)); |
| 1252 | - aclError aclRet = aclrtMemcpy(opParamPtr, opParamSize, &opParam, opParamSize, ACL_MEMCPY_HOST_TO_DEVICE); | 1253 | + CHK_RET(haclrtMemcpy(opParamPtr, opParamSize, &opParam, opParamSize, ACL_MEMCPY_HOST_TO_DEVICE)); |
| 1253 | - CHK_RET(aclRet == ACL_SUCCESS ? HCCL_SUCCESS : HCCL_E_RUNTIME); | ||
| 1254 | opResCtx.algInfo[tilingIndex].opParam = reinterpret_cast<uint64_t>(opParamPtr); | 1254 | opResCtx.algInfo[tilingIndex].opParam = reinterpret_cast<uint64_t>(opParamPtr); |
| 1255 | opResCtx.algInfo[tilingIndex].offset = initTiling->offset[tilingIndex]; | 1255 | opResCtx.algInfo[tilingIndex].offset = initTiling->offset[tilingIndex]; |
| 1256 | opResCtx.opParamSize[tilingIndex] = opParamSize; | 1256 | opResCtx.opParamSize[tilingIndex] = opParamSize; |
| @@ -540,13 +540,15 @@ HcclResult AllocComResourceByTilingCcu( | |||
| 540 | std::string tagOpResCtx = ctxTag + "_opResCtx"; | 540 | std::string tagOpResCtx = ctxTag + "_opResCtx"; |
| 541 | uint64_t opResCtxSize = sizeof(OpResCtx); | 541 | uint64_t opResCtxSize = sizeof(OpResCtx); |
| 542 | CHK_RET(GetOrCreateCcuCtx(comm, tagOpResCtx, opResCtxSize, opResCtx)); | 542 | CHK_RET(GetOrCreateCcuCtx(comm, tagOpResCtx, opResCtxSize, opResCtx)); |
| 543 | - aclError aclRet = aclrtMemcpy(*opResCtx, opResCtxSize, &resCtx, opResCtxSize, ACL_MEMCPY_HOST_TO_DEVICE); | 543 | + HcclResult hcclRet = haclrtMemcpy(*opResCtx, opResCtxSize, &resCtx, opResCtxSize, ACL_MEMCPY_HOST_TO_DEVICE); |
| 544 | HCCL_INFO( | 544 | HCCL_INFO( |
| 545 | "[CCU_DEBUG] opResCtxPtr=%p, *opResCtx=%p, size=%llu ws=0x%llx wsSize=0x%llx xn=0x%llx cke=0x%llx rankId=%llu " | 545 | "[CCU_DEBUG] opResCtxPtr=%p, *opResCtx=%p, size=%llu ws=0x%llx wsSize=0x%llx xn=0x%llx cke=0x%llx rankId=%llu " |
| 546 | "rankSize=%llu", | 546 | "rankSize=%llu", |
| 547 | opResCtx, *opResCtx, opResCtxSize, resCtx.workSpace, resCtx.workSpaceSize, resCtx.xnAddr, resCtx.ckeAddr, | 547 | opResCtx, *opResCtx, opResCtxSize, resCtx.workSpace, resCtx.workSpaceSize, resCtx.xnAddr, resCtx.ckeAddr, |
| 548 | resCtx.rankId, resCtx.rankSize); | 548 | resCtx.rankId, resCtx.rankSize); |
| 549 | - CHK_RET(aclRet == ACL_SUCCESS ? HCCL_SUCCESS : HCCL_E_RUNTIME); | 549 | + CHK_PRT_RET( |
| 550 | + hcclRet != HCCL_SUCCESS, HCCL_ERROR("[AllocComResourceByTilingCcu] haclrtMemcpy failed, ret[%d].", hcclRet), | ||
| 551 | + hcclRet); | ||
| 550 | HCCL_INFO("[AllocComResourceByTilingCcu]end AllocComResourceByTilingCcu!"); | 552 | HCCL_INFO("[AllocComResourceByTilingCcu]end AllocComResourceByTilingCcu!"); |
| 551 | return HCCL_SUCCESS; | 553 | return HCCL_SUCCESS; |
| 552 | } | 554 | } |
| @@ -943,6 +945,7 @@ void LogKernelLaunchArgs( | |||
| 943 | } | 945 | } |
| 944 | } // namespace | 946 | } // namespace |
| 945 | 947 | ||
| 948 | +namespace { | ||
| 946 | static CcuResult ResolveStreamFromCcuThread(HcclComm comm, ThreadHandle threadHandle, aclrtStream& stream) | 949 | static CcuResult ResolveStreamFromCcuThread(HcclComm comm, ThreadHandle threadHandle, aclrtStream& stream) |
| 947 | { | 950 | { |
| 948 | ThreadResTypeStream streamRes = nullptr; | 951 | ThreadResTypeStream streamRes = nullptr; |
| @@ -968,7 +971,7 @@ CcuResult LaunchCcuKernel(const HcclComm comm, aclrtStream stream, const OpParam | |||
| 968 | { | 971 | { |
| 969 | CHK_PRT_RET(comm == nullptr, HCCL_ERROR("[%s] comm is nullptr.", __func__), CCU_E_PTR); | 972 | CHK_PRT_RET(comm == nullptr, HCCL_ERROR("[%s] comm is nullptr.", __func__), CCU_E_PTR); |
| 970 | // stream 非空:用 HcclThreadAcquireWithStream 将用户 stream 封装为通信 thread; | 973 | // stream 非空:用 HcclThreadAcquireWithStream 将用户 stream 封装为通信 thread; |
| 971 | - // stream 为空:兼容老样例,走资源上下文中预分配 threads 的旧流程。 | 974 | + // stream 为空:走资源上下文中预分配 threads 的流程。 |
| 972 | const bool useLegacyThread = (stream == nullptr); | 975 | const bool useLegacyThread = (stream == nullptr); |
| 973 | AlgResourceCtxSerializable resourceCtx; | 976 | AlgResourceCtxSerializable resourceCtx; |
| 974 | CcuResult ret = LoadResourceCtx(opParamHost, resourceCtx); | 977 | CcuResult ret = LoadResourceCtx(opParamHost, resourceCtx); |
| @@ -1030,6 +1033,66 @@ CcuResult LaunchCcuKernel(const HcclComm comm, aclrtStream stream, const OpParam | |||
| 1030 | return CCU_SUCCESS; | 1033 | return CCU_SUCCESS; |
| 1031 | } | 1034 | } |
| 1032 | 1035 | ||
| 1036 | +CcuResult LaunchCcuKernelCapture(const HcclComm comm, aclrtStream stream, const OpParam& opParamHost) | ||
| 1037 | +{ | ||
| 1038 | + AlgResourceCtxSerializable resourceCtx; | ||
| 1039 | + CcuResult ret = LoadResourceCtx(opParamHost, resourceCtx); | ||
| 1040 | + if (ret != CCU_SUCCESS) { | ||
| 1041 | + return ret; | ||
| 1042 | + } | ||
| 1043 | + uint32_t missionNum = 0; | ||
| 1044 | + // capture 复用资源准备阶段的预分配 threads,不在用户主流上重新申请通信 thread, | ||
| 1045 | + // 因此按 legacy 线程布局校验 launch 输入。 | ||
| 1046 | + ret = GetLaunchMissionNum(resourceCtx, missionNum, true); | ||
| 1047 | + if (ret != CCU_SUCCESS) { | ||
| 1048 | + return ret; | ||
| 1049 | + } | ||
| 1050 | + // threads[0] 为主流线程,[1..] 为 CCU 从线程。capture 场景按主流捕获状态把 CCU 从流加入 capture | ||
| 1051 | + // model(aclmdlRICaptureGetInfo + rtStreamAddToModel),与 op_common.cc 中 CCU 分支的调用一致; | ||
| 1052 | + // 只有主线程时无从流需要纳管,跳过该步骤。 | ||
| 1053 | + if (resourceCtx.threads.size() > 1U) { | ||
| 1054 | + HcclResult captureRet = CaptureSlaveStreams(comm, stream, resourceCtx.threads); | ||
| 1055 | + if (captureRet != HCCL_SUCCESS) { | ||
| 1056 | + HCCL_ERROR("[CcuKernelLaunch] CaptureSlaveStreams failed, ret[%d], stream[%p].", captureRet, stream); | ||
| 1057 | + return static_cast<CcuResult>(captureRet); | ||
| 1058 | + } | ||
| 1059 | + } | ||
| 1060 | + HCCL_INFO( | ||
| 1061 | + "[CcuKernelLaunch] start [%u] KFC server missions, stream[%p], mode[capture-preallocated-thread].", missionNum, | ||
| 1062 | + stream); | ||
| 1063 | + for (uint32_t missionIndex = 0; missionIndex < missionNum; ++missionIndex) { | ||
| 1064 | + const ThreadHandle threadHandle = resourceCtx.threads[missionIndex]; | ||
| 1065 | + const CcuKernelHandle kernelHandle = resourceCtx.ccuKernels[missionIndex]; | ||
| 1066 | + CHK_PRT_RET( | ||
| 1067 | + threadHandle == 0 || kernelHandle == 0, HCCL_ERROR("invalid launch handles for mission[%u]", missionIndex), | ||
| 1068 | + CCU_E_PARA); | ||
| 1069 | + LogKernelLaunchArgs(resourceCtx, missionIndex, threadHandle, kernelHandle); | ||
| 1070 | + const void* kfcArgs = | ||
| 1071 | + static_cast<const void*>(resourceCtx.kfcServerArgs.data() + missionIndex * KFC_SERVER_ARG_NUM); | ||
| 1072 | + ret = HcommCcuKernelLaunch(threadHandle, kernelHandle, kfcArgs, resourceCtx.kfcServerArgSize); | ||
| 1073 | + if (ret != CCU_SUCCESS) { | ||
| 1074 | + HCCL_ERROR("[CcuKernelLaunch] mission[%u] launch failed, ret[%d]", missionIndex, ret); | ||
| 1075 | + return ret; | ||
| 1076 | + } | ||
| 1077 | + } | ||
| 1078 | + return CCU_SUCCESS; | ||
| 1079 | +} | ||
| 1080 | +bool IsCcuGraphCapture(aclrtStream stream, CcuResult& ret) | ||
| 1081 | +{ | ||
| 1082 | + aclmdlRICaptureStatus captureStatus = ACL_MODEL_RI_CAPTURE_STATUS_NONE; | ||
| 1083 | + u64 modelId = 0; | ||
| 1084 | + bool isCapture = false; | ||
| 1085 | + const HcclResult captureRet = haclrtGetCaptureInfo(stream, captureStatus, modelId, isCapture); | ||
| 1086 | + if (captureRet != HCCL_SUCCESS) { | ||
| 1087 | + HCCL_ERROR("[%s] haclrtGetCaptureInfo failed, ret[%d], stream[%p].", __func__, captureRet, stream); | ||
| 1088 | + ret = static_cast<CcuResult>(captureRet); | ||
| 1089 | + return false; | ||
| 1090 | + } | ||
| 1091 | + ret = CCU_SUCCESS; | ||
| 1092 | + return isCapture; | ||
| 1093 | +} | ||
| 1094 | +} // namespace | ||
| 1095 | + | ||
| 1033 | namespace { | 1096 | namespace { |
| 1034 | constexpr uint16_t MC2_AICPU_HCCL_DEFAULT_TIME = 1836U; | 1097 | constexpr uint16_t MC2_AICPU_HCCL_DEFAULT_TIME = 1836U; |
| 1035 | constexpr uint32_t MC2_AICPU_PARAM_LEN = 32U; | 1098 | constexpr uint32_t MC2_AICPU_PARAM_LEN = 32U; |
| @@ -1155,8 +1218,17 @@ CcuResult CcuKernelLaunch(const HcclComm comm, void* opResCtx) | |||
| 1155 | if (ret != CCU_SUCCESS) { | 1218 | if (ret != CCU_SUCCESS) { |
| 1156 | return ret; | 1219 | return ret; |
| 1157 | } | 1220 | } |
| 1158 | - // 传入空的 stream,默认走资源上下文中预分配 threads 的旧流程。 | 1221 | + const bool isCapture = IsCcuGraphCapture(opParamHost.stream, ret); |
| 1159 | - return LaunchCcuKernel(comm, nullptr, opParamHost); | 1222 | + if (ret != CCU_SUCCESS) { |
| 1223 | + return ret; | ||
| 1224 | + } | ||
| 1225 | + if (isCapture) { | ||
| 1226 | + // 图捕获时传入用户主流,把 CCU 从流加入主流对应的捕获图中。 | ||
| 1227 | + return LaunchCcuKernelCapture(comm, opParamHost.stream, opParamHost); | ||
| 1228 | + } else { | ||
| 1229 | + // 传入空的 stream,默认走资源上下文中预分配 threads 的旧流程。 | ||
| 1230 | + return LaunchCcuKernel(comm, nullptr, opParamHost); | ||
| 1231 | + } | ||
| 1160 | } | 1232 | } |
| 1161 | 1233 | ||
| 1162 | HcclResult __attribute__((visibility("default"))) CheckOpResSufficient(HcclComm comm, uint8_t ccType, void* ccArgs) | 1234 | HcclResult __attribute__((visibility("default"))) CheckOpResSufficient(HcclComm comm, uint8_t ccType, void* ccArgs) |
| @@ -128,13 +128,7 @@ HcclResult GetOrCreateCcuCtx(HcclComm comm, const std::string& tag, uint64_t ctx | |||
| 128 | return HCCL_SUCCESS; | 128 | return HCCL_SUCCESS; |
| 129 | } | 129 | } |
| 130 | CHK_RET(HcclEngineCtxCreate(comm, tag.c_str(), COMM_ENGINE_AIV, ctxSize, ctx)); | 130 | CHK_RET(HcclEngineCtxCreate(comm, tag.c_str(), COMM_ENGINE_AIV, ctxSize, ctx)); |
| 131 | - aclError aclRet = aclrtMemset(*ctx, ctxSize, 0, ctxSize); | 131 | + CHK_RET(haclrtMemset(*ctx, static_cast<size_t>(ctxSize), 0, static_cast<size_t>(ctxSize))); |
| 132 | - CHK_PRT_RET( | ||
| 133 | - aclRet != ACL_SUCCESS, | ||
| 134 | - HCCL_ERROR( | ||
| 135 | - "[GetOrCreateCcuCtx] aclrtMemset failed, ret[%d], tag[%s], addr[%p], size[%llu].", aclRet, tag.c_str(), | ||
| 136 | - *ctx, static_cast<unsigned long long>(ctxSize)), | ||
| 137 | - HCCL_E_RUNTIME); | ||
| 138 | return HCCL_SUCCESS; | 132 | return HCCL_SUCCESS; |
| 139 | } | 133 | } |
| 140 | 134 | ||
| @@ -160,12 +154,13 @@ static HcclResult UpdateCcuCtxTokenOnReuse( | |||
| 160 | CHK_PTR_NULL(ctx); | 154 | CHK_PTR_NULL(ctx); |
| 161 | CHK_PTR_NULL(resCtxHost); | 155 | CHK_PTR_NULL(resCtxHost); |
| 162 | 156 | ||
| 157 | + const size_t copySize = static_cast<size_t>(ctxSize); | ||
| 163 | std::vector<char> seq(ctxSize); | 158 | std::vector<char> seq(ctxSize); |
| 164 | - aclError aclRet = aclrtMemcpy(seq.data(), ctxSize, ctx, ctxSize, ACL_MEMCPY_DEVICE_TO_HOST); | 159 | + HcclResult copyRet = haclrtMemcpy(seq.data(), copySize, ctx, copySize, ACL_MEMCPY_DEVICE_TO_HOST); |
| 165 | CHK_PRT_RET( | 160 | CHK_PRT_RET( |
| 166 | - aclRet != ACL_SUCCESS, | 161 | + copyRet != HCCL_SUCCESS, |
| 167 | HCCL_ERROR( | 162 | HCCL_ERROR( |
| 168 | - "[UpdateCcuCtxTokenOnReuse] aclrtMemcpy D2H failed, ret[%d], dst[%p], src[%p], size[%llu].", aclRet, | 163 | + "[UpdateCcuCtxTokenOnReuse] haclrtMemcpy D2H failed, ret[%d], dst[%p], src[%p], size[%llu].", copyRet, |
| 169 | seq.data(), ctx, static_cast<unsigned long long>(ctxSize)), | 164 | seq.data(), ctx, static_cast<unsigned long long>(ctxSize)), |
| 170 | HCCL_E_RUNTIME); | 165 | HCCL_E_RUNTIME); |
| 171 | 166 | ||
| @@ -208,11 +203,11 @@ static HcclResult UpdateCcuCtxTokenOnReuse( | |||
| 208 | "[UpdateCcuCtxTokenOnReuse] serialized ctx size changed, oldSize[%llu], newSize[%zu].", | 203 | "[UpdateCcuCtxTokenOnReuse] serialized ctx size changed, oldSize[%llu], newSize[%zu].", |
| 209 | static_cast<unsigned long long>(ctxSize), updatedSeq.size()), | 204 | static_cast<unsigned long long>(ctxSize), updatedSeq.size()), |
| 210 | HCCL_E_INTERNAL); | 205 | HCCL_E_INTERNAL); |
| 211 | - aclRet = aclrtMemcpy(ctx, ctxSize, updatedSeq.data(), updatedSeq.size(), ACL_MEMCPY_HOST_TO_DEVICE); | 206 | + copyRet = haclrtMemcpy(ctx, copySize, updatedSeq.data(), updatedSeq.size(), ACL_MEMCPY_HOST_TO_DEVICE); |
| 212 | CHK_PRT_RET( | 207 | CHK_PRT_RET( |
| 213 | - aclRet != ACL_SUCCESS, | 208 | + copyRet != HCCL_SUCCESS, |
| 214 | HCCL_ERROR( | 209 | HCCL_ERROR( |
| 215 | - "[UpdateCcuCtxTokenOnReuse] aclrtMemcpy H2D failed, ret[%d], dst[%p], src[%p], size[%zu].", aclRet, ctx, | 210 | + "[UpdateCcuCtxTokenOnReuse] haclrtMemcpy H2D failed, ret[%d], dst[%p], src[%p], size[%zu].", copyRet, ctx, |
| 216 | updatedSeq.data(), updatedSeq.size()), | 211 | updatedSeq.data(), updatedSeq.size()), |
| 217 | HCCL_E_RUNTIME); | 212 | HCCL_E_RUNTIME); |
| 218 | return HCCL_SUCCESS; | 213 | return HCCL_SUCCESS; |
| @@ -1473,10 +1468,11 @@ HcclResult GetAlgResCcu( | |||
| 1473 | 1468 | ||
| 1474 | void* ctx = nullptr; | 1469 | void* ctx = nullptr; |
| 1475 | CHK_RET(GetOrCreateCcuCtx(comm, param.algTag, size, &ctx)); | 1470 | CHK_RET(GetOrCreateCcuCtx(comm, param.algTag, size, &ctx)); |
| 1476 | - aclError aclRet = aclrtMemcpy(ctx, size, seq.data(), size, ACL_MEMCPY_HOST_TO_DEVICE); | 1471 | + const size_t copySize = static_cast<size_t>(size); |
| 1477 | - if (aclRet != ACL_SUCCESS) { | 1472 | + HcclResult copyRet = haclrtMemcpy(ctx, copySize, seq.data(), copySize, ACL_MEMCPY_HOST_TO_DEVICE); |
| 1473 | + if (copyRet != HCCL_SUCCESS) { | ||
| 1478 | HCCL_ERROR( | 1474 | HCCL_ERROR( |
| 1479 | - "[GetAlgResCcu] aclrtMemcpy H2D failed, ret[%d], dst[%p], src[%p], size[%llu].", aclRet, ctx, seq.data(), | 1475 | + "[GetAlgResCcu] haclrtMemcpy H2D failed, ret[%d], dst[%p], src[%p], size[%llu].", copyRet, ctx, seq.data(), |
| 1480 | size); | 1476 | size); |
| 1481 | return HCCL_E_RUNTIME; | 1477 | return HCCL_E_RUNTIME; |
| 1482 | } | 1478 | } |
| @@ -45,6 +45,21 @@ HcclResult haclrtMemcpy(void* dst, size_t destMax, const void* src, size_t count | |||
| 45 | return HCCL_SUCCESS; | 45 | return HCCL_SUCCESS; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | +HcclResult haclrtMemset(void* dst, size_t destMax, int32_t value, size_t count) | ||
| 49 | +{ | ||
| 50 | + if (dst == nullptr) { | ||
| 51 | + return HCCL_E_PTR; | ||
| 52 | + } | ||
| 53 | + if (count == 0) { | ||
| 54 | + return HCCL_SUCCESS; | ||
| 55 | + } | ||
| 56 | + aclError aclRet = aclrtMemset(dst, destMax, value, count); | ||
| 57 | + if (aclRet != ACL_SUCCESS) { | ||
| 58 | + return HCCL_E_RUNTIME; | ||
| 59 | + } | ||
| 60 | + return HCCL_SUCCESS; | ||
| 61 | +} | ||
| 62 | + | ||
| 48 | HcclResult haclrtGetCaptureInfo(aclrtStream stream, aclmdlRICaptureStatus& captureStatus, u64& modelId, bool& isCapture) | 63 | HcclResult haclrtGetCaptureInfo(aclrtStream stream, aclmdlRICaptureStatus& captureStatus, u64& modelId, bool& isCapture) |
| 49 | { | 64 | { |
| 50 | static_cast<void>(stream); | 65 | static_cast<void>(stream); |
| @@ -77,6 +77,12 @@ HcclResult GetOrCreateCcuCtx(HcclComm comm, const std::string& tag, uint64_t ctx | |||
| 77 | return aclrtMemset(*ctx, ctxSize, 0, ctxSize) == ACL_SUCCESS ? HCCL_SUCCESS : HCCL_E_RUNTIME; | 77 | return aclrtMemset(*ctx, ctxSize, 0, ctxSize) == ACL_SUCCESS ? HCCL_SUCCESS : HCCL_E_RUNTIME; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | +// 当前 CCU UT 不覆盖图捕获,桩件仅补齐 launch 链上的符号定义。 | ||
| 81 | +HcclResult CaptureSlaveStreams(HcclComm comm, aclrtStream mainStream, const std::vector<ThreadHandle>& threads) | ||
| 82 | +{ | ||
| 83 | + return HCCL_SUCCESS; | ||
| 84 | +} | ||
| 85 | + | ||
| 80 | InsCollAlgBase::InsCollAlgBase() {} | 86 | InsCollAlgBase::InsCollAlgBase() {} |
| 81 | InsCollAlgBase::~InsCollAlgBase() {} | 87 | InsCollAlgBase::~InsCollAlgBase() {} |
| 82 | std::string InsCollAlgBase::Describe() const { return "InsCollAlgBase"; } | 88 | std::string InsCollAlgBase::Describe() const { return "InsCollAlgBase"; } |
1168-1182再抽取一个函数,判断是否走图模式