已合并
clean code for get channel #296
Archerls创建于 3月18日
clean code for get channel #296
已合并
共 19 个文件变更+475-87
| @@ -44,6 +44,7 @@ set(INCLUDE_LIST | |||
| 44 | ${CMAKE_CURRENT_SOURCE_DIR}/ops/op_common/template/ccu/kernel | 44 | ${CMAKE_CURRENT_SOURCE_DIR}/ops/op_common/template/ccu/kernel |
| 45 | 45 | ||
| 46 | ${CMAKE_CURRENT_SOURCE_DIR}/ops/op_common/topo | 46 | ${CMAKE_CURRENT_SOURCE_DIR}/ops/op_common/topo |
| 47 | + ${CMAKE_CURRENT_SOURCE_DIR}/ops/interface_graph_mode | ||
| 47 | 48 | ||
| 48 | ${CMAKE_CURRENT_SOURCE_DIR}/ops/reduce_scatter | 49 | ${CMAKE_CURRENT_SOURCE_DIR}/ops/reduce_scatter |
| 49 | ${CMAKE_CURRENT_SOURCE_DIR}/ops/reduce_scatter/executor | 50 | ${CMAKE_CURRENT_SOURCE_DIR}/ops/reduce_scatter/executor |
| @@ -21,3 +21,4 @@ add_subdirectory(reduce_scatter_v) | |||
| 21 | add_subdirectory(all_gather_v) | 21 | add_subdirectory(all_gather_v) |
| 22 | add_subdirectory(reduce) | 22 | add_subdirectory(reduce) |
| 23 | add_subdirectory(batch_send_recv) | 23 | add_subdirectory(batch_send_recv) |
| 24 | +add_subdirectory(interface_graph_mode) | ||
| @@ -15,10 +15,12 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | + | ||
| 18 | using namespace std; | 19 | using namespace std; |
| 19 | using namespace ops_hccl; | 20 | using namespace ops_hccl; |
| 20 | extern "C" unsigned int LaunchAicpuKernel(OpParam *param); | 21 | extern "C" unsigned int LaunchAicpuKernel(OpParam *param); |
| 21 | 22 | ||
| 23 | + | ||
| 22 | HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | 24 | HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, |
| 23 | aclrtStream stream) | 25 | aclrtStream stream) |
| 24 | { | 26 | { |
| @@ -35,6 +37,56 @@ HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclD | |||
| 35 | if (GetWorkflowMode() != HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) { | 37 | if (GetWorkflowMode() != HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) { |
| 36 | return HcclAllGatherInner(sendBuf, recvBuf, sendCount, dataType, comm, stream); | 38 | return HcclAllGatherInner(sendBuf, recvBuf, sendCount, dataType, comm, stream); |
| 37 | } | 39 | } |
| 40 | + | ||
| 41 | + std::string opTag; | ||
| 42 | + CHK_RET(AllGatherInitAndCheck(comm, sendBuf, recvBuf, sendCount, dataType, stream, opTag)); | ||
| 43 | + | ||
| 44 | + // 执行AllGather | ||
| 45 | + CHK_RET_AND_PRINT_IDE(AllGatherOutPlace(sendBuf, recvBuf, sendCount, dataType, comm, stream, opTag), opTag.c_str()); | ||
| 46 | + | ||
| 47 | + return HCCL_SUCCESS; | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +HcclResult HcclAllGatherGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, const char* group, aclrtStream stream, const char* tag, void** streams, size_t streamCount, void* scratchMemAddr, uint64_t scratchMemSize) | ||
| 51 | +{ | ||
| 52 | + HCCL_INFO("Start to run execute HcclAllGatherGraphMode"); | ||
| 53 | + // 根据group获取通信域 | ||
| 54 | + HcclComm comm = nullptr; | ||
| 55 | + HCCL_INFO("[HcclAllGatherGraphMode] get group name: %s", group); | ||
| 56 | + CHK_RET(HcomGetCommHandleByGroup(group, &comm)); | ||
| 57 | + | ||
| 58 | + std::string opTag; | ||
| 59 | + CHK_RET(AllGatherInitAndCheck(comm, sendBuf, recvBuf, sendCount, dataType, stream, opTag)); | ||
| 60 | + | ||
| 61 | + // 检查tag有效性 | ||
| 62 | + CHK_RET(HcclCheckTag(tag)); | ||
| 63 | + | ||
| 64 | + // 拼装ResPackGraphMode | ||
| 65 | + ResPackGraphMode resPack; | ||
| 66 | + // 设置tag | ||
| 67 | + if (strncpy_s(resPack.tag, sizeof(resPack.tag), tag, sizeof(resPack.tag) - 1) != 0) { | ||
| 68 | + HCCL_ERROR("failed to fill resPack.tag"); | ||
| 69 | + return HCCL_E_INTERNAL; | ||
| 70 | + } | ||
| 71 | + // 设置streams | ||
| 72 | + if (streams != nullptr && streamCount > 0) { | ||
| 73 | + for (size_t i = 0; i < streamCount; i++) { | ||
| 74 | + resPack.streams.push_back(static_cast<aclrtStream>(streams[i])); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + // 设置scratchMem | ||
| 78 | + resPack.scratchMemAddr = scratchMemAddr; | ||
| 79 | + resPack.scratchMemSize = scratchMemSize; | ||
| 80 | + std::string tagStr = tag; | ||
| 81 | + // 执行AllGather | ||
| 82 | + CHK_RET_AND_PRINT_IDE(AllGatherOutPlaceGraphMode(sendBuf, recvBuf, sendCount, dataType, comm, stream, tagStr, resPack), tagStr.c_str()); | ||
| 83 | + | ||
| 84 | + return HCCL_SUCCESS; | ||
| 85 | +} | ||
| 86 | +namespace ops_hccl { | ||
| 87 | + | ||
| 88 | +HcclResult AllGatherInitAndCheck(HcclComm comm, void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, aclrtStream stream, std::string &opTag) | ||
| 89 | +{ | ||
| 38 | // 入口的地方先解析环境变量,在初始化环境变量的时候需要设置为AICPU展开 | 90 | // 入口的地方先解析环境变量,在初始化环境变量的时候需要设置为AICPU展开 |
| 39 | CHK_RET(InitEnvConfig()); | 91 | CHK_RET(InitEnvConfig()); |
| 40 | // 参数校验等工作 | 92 | // 参数校验等工作 |
| @@ -44,8 +96,8 @@ HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclD | |||
| 44 | // tag有效性,是否过长 | 96 | // tag有效性,是否过长 |
| 45 | char commName[COMM_INDENTIFIER_MAX_LENGTH]; | 97 | char commName[COMM_INDENTIFIER_MAX_LENGTH]; |
| 46 | CHK_RET(HcclGetCommName(comm, commName)); | 98 | CHK_RET(HcclGetCommName(comm, commName)); |
| 47 | - const string tag = "AllGather_" + string(commName); | 99 | + opTag = "AllGather_" + string(commName); |
| 48 | - CHK_RET(HcclCheckTag(tag.c_str())); | 100 | + CHK_RET(HcclCheckTag(opTag.c_str())); |
| 49 | // 检查sendCount是否合法(超出系统上限) | 101 | // 检查sendCount是否合法(超出系统上限) |
| 50 | CHK_RET(CheckCount(sendCount)); | 102 | CHK_RET(CheckCount(sendCount)); |
| 51 | // 检查数据类型是否支持 | 103 | // 检查数据类型是否支持 |
| @@ -55,15 +107,10 @@ HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclD | |||
| 55 | CHK_RET(HcclGetRankSize(comm, &rankSize)); | 107 | CHK_RET(HcclGetRankSize(comm, &rankSize)); |
| 56 | u32 userRank = INVALID_VALUE_RANKID; | 108 | u32 userRank = INVALID_VALUE_RANKID; |
| 57 | CHK_RET(HcclGetRankId(comm, &userRank)); | 109 | CHK_RET(HcclGetRankId(comm, &userRank)); |
| 58 | - CHK_RET_AND_PRINT_IDE(HcomCheckUserRank(rankSize, userRank), tag.c_str()); | 110 | + CHK_RET_AND_PRINT_IDE(HcomCheckUserRank(rankSize, userRank), opTag.c_str()); |
| 59 | - | ||
| 60 | - // 执行AllGather | ||
| 61 | - CHK_RET_AND_PRINT_IDE(AllGatherOutPlace(sendBuf, recvBuf, sendCount, dataType, comm, stream, tag), tag.c_str()); | ||
| 62 | - | ||
| 63 | return HCCL_SUCCESS; | 111 | return HCCL_SUCCESS; |
| 64 | } | 112 | } |
| 65 | 113 | ||
| 66 | -namespace ops_hccl { | ||
| 67 | HcclResult CheckAllGatherInputPara(const HcclComm comm, const void* sendBuf, const void* recvBuf, const aclrtStream stream) | 114 | HcclResult CheckAllGatherInputPara(const HcclComm comm, const void* sendBuf, const void* recvBuf, const aclrtStream stream) |
| 68 | { | 115 | { |
| 69 | // 入参合法性校验 | 116 | // 入参合法性校验 |
| @@ -83,21 +130,21 @@ HcclResult CheckAllGatherInputPara(const HcclComm comm, const void* sendBuf, con | |||
| 83 | return HCCL_SUCCESS; | 130 | return HCCL_SUCCESS; |
| 84 | } | 131 | } |
| 85 | 132 | ||
| 86 | -HcclResult AllGatherOutPlace(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | 133 | +HcclResult AllGatherOutPlaceCommon(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, |
| 87 | - aclrtStream stream, const std::string &tag) | 134 | + aclrtStream stream, const std::string &tag, OpMode opMode, const ResPackGraphMode &resPack) |
| 88 | { | 135 | { |
| 89 | - HCCL_INFO("Start to execute AllGatherOutPlace"); | 136 | + HCCL_INFO("Start to execute AllGatherOutPlaceCommon"); |
| 90 | u32 userRankSize; | 137 | u32 userRankSize; |
| 91 | CHK_RET(HcclGetRankSize(comm, &userRankSize)); | 138 | CHK_RET(HcclGetRankSize(comm, &userRankSize)); |
| 92 | 139 | ||
| 93 | - u32 perDataSize = SIZE_TABLE[dataType]; | 140 | + u32 perDataSize = DATATYPE_SIZE_TABLE[dataType]; |
| 94 | u64 inputSize = sendCount * perDataSize; // all gather 每个rank上一份数据 | 141 | u64 inputSize = sendCount * perDataSize; // all gather 每个rank上一份数据 |
| 95 | u64 outputSize = inputSize * userRankSize; // 每个卡上结果为rankSize份数据 | 142 | u64 outputSize = inputSize * userRankSize; // 每个卡上结果为rankSize份数据 |
| 96 | 143 | ||
| 97 | OpParam param; | 144 | OpParam param; |
| 98 | CHK_RET(HcclGetCommName(comm, param.commName)); | 145 | CHK_RET(HcclGetCommName(comm, param.commName)); |
| 99 | param.stream = stream; | 146 | param.stream = stream; |
| 100 | - param.opMode = OpMode::OPBASE; | 147 | + param.opMode = opMode; |
| 101 | 148 | ||
| 102 | DevType deviceType = DevType::DEV_TYPE_COUNT; | 149 | DevType deviceType = DevType::DEV_TYPE_COUNT; |
| 103 | CHK_RET(hrtGetDeviceType(deviceType)); | 150 | CHK_RET(hrtGetDeviceType(deviceType)); |
| @@ -131,7 +178,26 @@ HcclResult AllGatherOutPlace(void *sendBuf, void *recvBuf, uint64_t sendCount, H | |||
| 131 | CHK_RET(SingleRankProc(param)); | 178 | CHK_RET(SingleRankProc(param)); |
| 132 | return HcclResult::HCCL_SUCCESS; | 179 | return HcclResult::HCCL_SUCCESS; |
| 133 | } | 180 | } |
| 134 | - CHK_RET(HcclExecOp(comm, param, topoInfo, algName)); | 181 | + CHK_RET(HcclExecOp(comm, param, topoInfo, algName, resPack)); |
| 182 | + HCCL_INFO("Execute AllGatherOutPlace success."); | ||
| 183 | + return HCCL_SUCCESS; | ||
| 184 | +} | ||
| 185 | + | ||
| 186 | +HcclResult AllGatherOutPlaceGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | ||
| 187 | + aclrtStream stream, const std::string &tag, const ResPackGraphMode &resPack) | ||
| 188 | +{ | ||
| 189 | + HCCL_INFO("Start to execute AllGatherOutPlaceGraphMode"); | ||
| 190 | + CHK_RET(AllGatherOutPlaceCommon(sendBuf, recvBuf, sendCount, dataType, comm, stream, tag, OpMode::OFFLOAD, resPack)); | ||
| 191 | + HCCL_INFO("Execute AllGatherOutPlaceGraphMode success."); | ||
| 192 | + return HCCL_SUCCESS; | ||
| 193 | +} | ||
| 194 | + | ||
| 195 | + | ||
| 196 | +HcclResult AllGatherOutPlace(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | ||
| 197 | + aclrtStream stream, const std::string &tag) | ||
| 198 | +{ | ||
| 199 | + HCCL_INFO("Start to execute AllGatherOutPlace"); | ||
| 200 | + CHK_RET(AllGatherOutPlaceCommon(sendBuf, recvBuf, sendCount, dataType, comm, stream, tag, OpMode::OPBASE, ResPackGraphMode())); | ||
| 135 | HCCL_INFO("Execute AllGatherOutPlace success."); | 201 | HCCL_INFO("Execute AllGatherOutPlace success."); |
| 136 | return HCCL_SUCCESS; | 202 | return HCCL_SUCCESS; |
| 137 | } | 203 | } |
| @@ -13,7 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | - | ||
| 17 | 16 | ||
| 18 | 17 | ||
| 19 | 18 | ||
| @@ -25,7 +24,8 @@ extern "C" { | |||
| 25 | 24 | ||
| 26 | HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | 25 | HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, |
| 27 | aclrtStream stream); | 26 | aclrtStream stream); |
| 28 | - | 27 | +HcclResult HcclAllGatherGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, const char* group, |
| 28 | + aclrtStream stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 29 | 29 | ||
| 30 | } | 30 | } |
| 31 | 31 | ||
| @@ -33,8 +33,14 @@ HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclD | |||
| 33 | namespace ops_hccl { | 33 | namespace ops_hccl { |
| 34 | HcclResult AllGatherOutPlace(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | 34 | HcclResult AllGatherOutPlace(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, |
| 35 | aclrtStream stream, const std::string &tag); | 35 | aclrtStream stream, const std::string &tag); |
| 36 | +HcclResult AllGatherOutPlaceGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | ||
| 37 | + aclrtStream stream, const std::string &tag, const ResPackGraphMode &resPack); | ||
| 38 | +HcclResult AllGatherOutPlaceCommon(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | ||
| 39 | + aclrtStream stream, const std::string &tag, OpMode opMode, const ResPackGraphMode &resPack); | ||
| 36 | 40 | ||
| 37 | HcclResult CheckAllGatherInputPara(const HcclComm comm, const void* sendBuf, const void* recvBuf, const aclrtStream stream); | 41 | HcclResult CheckAllGatherInputPara(const HcclComm comm, const void* sendBuf, const void* recvBuf, const aclrtStream stream); |
| 38 | 42 | ||
| 43 | +HcclResult AllGatherInitAndCheck(HcclComm comm, void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, aclrtStream stream, std::string &opTag); | ||
| 44 | + | ||
| 39 | } | 45 | } |
| 40 | 46 | ||
| @@ -64,7 +64,7 @@ HcclResult InsV2AllGatherParallelExecutor<AlgTopoMatch, InsAlgTemplate0, InsAlgT | |||
| 64 | } | 64 | } |
| 65 | InsAlgTemplate0 intraTempAlg(param, topoInfo->userRank, intraHierarchyInfo); | 65 | InsAlgTemplate0 intraTempAlg(param, topoInfo->userRank, intraHierarchyInfo); |
| 66 | InsAlgTemplate1 interTempAlg(param, topoInfo->userRank, interHierarchyInfo); | 66 | InsAlgTemplate1 interTempAlg(param, topoInfo->userRank, interHierarchyInfo); |
| 67 | - | 67 | + |
| 68 | // 调用计算资源的函数 | 68 | // 调用计算资源的函数 |
| 69 | AlgResourceRequest intraTempRequest; | 69 | AlgResourceRequest intraTempRequest; |
| 70 | AlgResourceRequest interTempRequest; | 70 | AlgResourceRequest interTempRequest; |
| @@ -134,6 +134,7 @@ void InsV2AllGatherParallelExecutor<AlgTopoMatch, InsAlgTemplate0, InsAlgTemplat | |||
| 134 | tempAlgParamsIntra0.repeatNum = 1; | 134 | tempAlgParamsIntra0.repeatNum = 1; |
| 135 | tempAlgParamsIntra0.inputRepeatStride = 0; | 135 | tempAlgParamsIntra0.inputRepeatStride = 0; |
| 136 | tempAlgParamsIntra0.outputRepeatStride = 0; | 136 | tempAlgParamsIntra0.outputRepeatStride = 0; |
| 137 | + tempAlgParamsIntra0.enableRemoteMemAccess = param.opMode == OpMode::OFFLOAD; | ||
| 137 | 138 | ||
| 138 | HCCL_DEBUG( | 139 | HCCL_DEBUG( |
| 139 | "[InsV2AllGatherParallelExecutor][GenTemplateAlgParamsIntra0] rank[%d] inBuffBaseOff[%llu] " | 140 | "[InsV2AllGatherParallelExecutor][GenTemplateAlgParamsIntra0] rank[%d] inBuffBaseOff[%llu] " |
| @@ -169,6 +170,7 @@ void InsV2AllGatherParallelExecutor<AlgTopoMatch, InsAlgTemplate0, InsAlgTemplat | |||
| 169 | tempAlgParamsInter0.repeatNum = rankSizeLevel0_; | 170 | tempAlgParamsInter0.repeatNum = rankSizeLevel0_; |
| 170 | tempAlgParamsInter0.inputRepeatStride = dataSize_; | 171 | tempAlgParamsInter0.inputRepeatStride = dataSize_; |
| 171 | tempAlgParamsInter0.outputRepeatStride = dataSize_; | 172 | tempAlgParamsInter0.outputRepeatStride = dataSize_; |
| 173 | + tempAlgParamsInter0.enableRemoteMemAccess = param.opMode == OpMode::OFFLOAD; | ||
| 172 | HCCL_DEBUG("[InsV2AllGatherParallelExecutor][GenTemplateAlgParamsInter0] rank[%u] inBuffBaseOff[%llu] " | 174 | HCCL_DEBUG("[InsV2AllGatherParallelExecutor][GenTemplateAlgParamsInter0] rank[%u] inBuffBaseOff[%llu] " |
| 173 | "outBuffBaseOff[%llu] scratchBuffBaseOff[%llu] sliceSize[%llu] outputSliceStride[%llu] " | 175 | "outBuffBaseOff[%llu] scratchBuffBaseOff[%llu] sliceSize[%llu] outputSliceStride[%llu] " |
| 174 | "outputRepeatStride[%llu]", | 176 | "outputRepeatStride[%llu]", |
| @@ -202,6 +204,7 @@ void InsV2AllGatherParallelExecutor<AlgTopoMatch, InsAlgTemplate0, InsAlgTemplat | |||
| 202 | tempAlgParamsInter1.repeatNum = 1; | 204 | tempAlgParamsInter1.repeatNum = 1; |
| 203 | tempAlgParamsInter1.inputRepeatStride = 0; | 205 | tempAlgParamsInter1.inputRepeatStride = 0; |
| 204 | tempAlgParamsInter1.outputRepeatStride = 0; | 206 | tempAlgParamsInter1.outputRepeatStride = 0; |
| 207 | + tempAlgParamsInter1.enableRemoteMemAccess = param.opMode == OpMode::OFFLOAD; | ||
| 205 | HCCL_DEBUG("[InsV2AllGatherParallelExecutor][GenTemplateAlgParamsInter1] rank[%u] inBuffBaseOff[%llu] " | 208 | HCCL_DEBUG("[InsV2AllGatherParallelExecutor][GenTemplateAlgParamsInter1] rank[%u] inBuffBaseOff[%llu] " |
| 206 | "outBuffBaseOff[%llu] scratchBuffBaseOff[%llu] sliceSize[%llu] outputSliceStride[%llu]", | 209 | "outBuffBaseOff[%llu] scratchBuffBaseOff[%llu] sliceSize[%llu] outputSliceStride[%llu]", |
| 207 | myRank_, tempAlgParamsInter1.buffInfo.inBuffBaseOff, tempAlgParamsInter1.buffInfo.outBuffBaseOff, | 210 | myRank_, tempAlgParamsInter1.buffInfo.inBuffBaseOff, tempAlgParamsInter1.buffInfo.outBuffBaseOff, |
| @@ -234,6 +237,7 @@ void InsV2AllGatherParallelExecutor<AlgTopoMatch, InsAlgTemplate0, InsAlgTemplat | |||
| 234 | tempAlgParamsIntra1.repeatNum = rankSizeLevel1_; | 237 | tempAlgParamsIntra1.repeatNum = rankSizeLevel1_; |
| 235 | tempAlgParamsIntra1.inputRepeatStride = dataSize_ * rankSizeLevel0_; | 238 | tempAlgParamsIntra1.inputRepeatStride = dataSize_ * rankSizeLevel0_; |
| 236 | tempAlgParamsIntra1.outputRepeatStride = dataSize_ * rankSizeLevel0_; | 239 | tempAlgParamsIntra1.outputRepeatStride = dataSize_ * rankSizeLevel0_; |
| 240 | + tempAlgParamsIntra1.enableRemoteMemAccess = param.opMode == OpMode::OFFLOAD; | ||
| 237 | HCCL_DEBUG("[InsV2AllGatherParallelExecutor][GenTemplateAlgParamsIntra1] rank[%u] inBuffBaseOff[%llu] " | 241 | HCCL_DEBUG("[InsV2AllGatherParallelExecutor][GenTemplateAlgParamsIntra1] rank[%u] inBuffBaseOff[%llu] " |
| 238 | "outBuffBaseOff[%llu] scratchBuffBaseOff[%llu] sliceSize[%llu] outputSliceStride[%llu] " | 242 | "outBuffBaseOff[%llu] scratchBuffBaseOff[%llu] sliceSize[%llu] outputSliceStride[%llu] " |
| 239 | "outputRepeatStride[%llu]", | 243 | "outputRepeatStride[%llu]", |
| @@ -48,6 +48,7 @@ HcclResult InsV2AllGatherSoleExecutor<AlgTopoMatch, InsAlgTemplate>::CalcRes( | |||
| 48 | std::make_shared<InsAlgTemplate>(param, topoInfo->userRank, algHierarchyInfo.infos[0]); | 48 | std::make_shared<InsAlgTemplate>(param, topoInfo->userRank, algHierarchyInfo.infos[0]); |
| 49 | // 调用计算资源的函数 | 49 | // 调用计算资源的函数 |
| 50 | algTemplate->CalcRes(comm, param, topoInfo, resourceRequest); | 50 | algTemplate->CalcRes(comm, param, topoInfo, resourceRequest); |
| 51 | + myRank_ = topoInfo->userRank; | ||
| 51 | HCCL_DEBUG("[InsV2AllGatherSoleExecutor][CalcRes] myRank[%u], notifyNumOnMainThread[%u], slaveThreadNum[%u], " | 52 | HCCL_DEBUG("[InsV2AllGatherSoleExecutor][CalcRes] myRank[%u], notifyNumOnMainThread[%u], slaveThreadNum[%u], " |
| 52 | "channels[%u]", | 53 | "channels[%u]", |
| 53 | myRank_, resourceRequest.notifyNumOnMainThread, resourceRequest.slaveThreadNum, | 54 | myRank_, resourceRequest.notifyNumOnMainThread, resourceRequest.slaveThreadNum, |
| @@ -112,6 +113,7 @@ HcclResult InsV2AllGatherSoleExecutor<AlgTopoMatch, InsAlgTemplate>::Orchestrate | |||
| 112 | tempAlgParams.buffInfo.hcclBuffType = BufferType::HCCL_BUFFER; | 113 | tempAlgParams.buffInfo.hcclBuffType = BufferType::HCCL_BUFFER; |
| 113 | tempAlgParams.buffInfo.inputSize = param.inputSize; | 114 | tempAlgParams.buffInfo.inputSize = param.inputSize; |
| 114 | tempAlgParams.buffInfo.outputSize = param.outputSize; | 115 | tempAlgParams.buffInfo.outputSize = param.outputSize; |
| 116 | + tempAlgParams.enableRemoteMemAccess = param.opMode == OpMode::OFFLOAD; | ||
| 115 | // 不需要重复 | 117 | // 不需要重复 |
| 116 | tempAlgParams.repeatNum = 1; | 118 | tempAlgParams.repeatNum = 1; |
| 117 | tempAlgParams.inputRepeatStride = 0; | 119 | tempAlgParams.inputRepeatStride = 0; |
| @@ -122,7 +124,6 @@ HcclResult InsV2AllGatherSoleExecutor<AlgTopoMatch, InsAlgTemplate>::Orchestrate | |||
| 122 | templateAlgRes.channels.size(), templateAlgRes.threads.size()); | 124 | templateAlgRes.channels.size(), templateAlgRes.threads.size()); |
| 123 | // 构建template | 125 | // 构建template |
| 124 | InsAlgTemplate algTemplate(param, resCtx.topoInfo.userRank, resCtx.algHierarchyInfo.infos[0]); | 126 | InsAlgTemplate algTemplate(param, resCtx.topoInfo.userRank, resCtx.algHierarchyInfo.infos[0]); |
| 125 | - | ||
| 126 | u32 templateScratchMultiplier = | 127 | u32 templateScratchMultiplier = |
| 127 | algTemplate.CalcScratchMultiple(tempAlgParams.buffInfo.inBuffType, tempAlgParams.buffInfo.outBuffType); | 128 | algTemplate.CalcScratchMultiple(tempAlgParams.buffInfo.inBuffType, tempAlgParams.buffInfo.outBuffType); |
| 128 | maxTmpMemSize_ = tempAlgParams.buffInfo.hcclBuff.size; | 129 | maxTmpMemSize_ = tempAlgParams.buffInfo.hcclBuff.size; |
| @@ -47,13 +47,17 @@ u64 InsTempAllGatherMesh1D::CalcScratchMultiple(BufferType inBuffType, BufferTyp | |||
| 47 | { | 47 | { |
| 48 | (void)inBuffType; | 48 | (void)inBuffType; |
| 49 | (void)outBuffType; | 49 | (void)outBuffType; |
| 50 | - u64 scratchMultiple = templateRankSize_; | 50 | + u64 scratchMultiple = 0; |
| 51 | + if (opMode_ == OpMode::OPBASE){ | ||
| 52 | + scratchMultiple = templateRankSize_; | ||
| 53 | + } | ||
| 51 | return scratchMultiple; | 54 | return scratchMultiple; |
| 52 | } | 55 | } |
| 53 | 56 | ||
| 54 | HcclResult InsTempAllGatherMesh1D::KernelRun(const OpParam ¶m, const TemplateDataParams &tempAlgParams, | 57 | HcclResult InsTempAllGatherMesh1D::KernelRun(const OpParam ¶m, const TemplateDataParams &tempAlgParams, |
| 55 | const TemplateResource &templateResource) | 58 | const TemplateResource &templateResource) |
| 56 | { | 59 | { |
| 60 | + enableRemoteMemAccess_ = tempAlgParams.enableRemoteMemAccess; | ||
| 57 | HCCL_INFO("[InsTempAllGatherMesh1D] Run start"); | 61 | HCCL_INFO("[InsTempAllGatherMesh1D] Run start"); |
| 58 | if (tempAlgParams.sliceSize == 0) { | 62 | if (tempAlgParams.sliceSize == 0) { |
| 59 | HCCL_INFO("[InsTempAllGatherMesh1D] Rank [%d], get slicesize zero.", myRank_); | 63 | HCCL_INFO("[InsTempAllGatherMesh1D] Rank [%d], get slicesize zero.", myRank_); |
| @@ -79,7 +83,9 @@ HcclResult InsTempAllGatherMesh1D::KernelRun(const OpParam ¶m, const Templat | |||
| 79 | GetNotifyIdxSubToMain(notifyIdxSubToMain_); | 83 | GetNotifyIdxSubToMain(notifyIdxSubToMain_); |
| 80 | CHK_RET(PostSyncInterThreads(templateResource.threads[0], subThreads, notifyIdxSubToMain_)); | 84 | CHK_RET(PostSyncInterThreads(templateResource.threads[0], subThreads, notifyIdxSubToMain_)); |
| 81 | } | 85 | } |
| 82 | - CHK_RET(PostLocalCopy(templateResource.threads)); | 86 | + if (opMode_ == OpMode::OPBASE) { |
| 87 | + CHK_RET(PostLocalCopy(templateResource.threads)); | ||
| 88 | + } | ||
| 83 | HCCL_INFO("[InsTempAllGatherMesh1D] Run End"); | 89 | HCCL_INFO("[InsTempAllGatherMesh1D] Run End"); |
| 84 | return HcclResult::HCCL_SUCCESS; | 90 | return HcclResult::HCCL_SUCCESS; |
| 85 | } | 91 | } |
| @@ -117,17 +123,17 @@ HcclResult InsTempAllGatherMesh1D::RunAllGatherMesh(const std::vector<ThreadHand | |||
| 117 | 123 | ||
| 118 | u64 txOutOffset = tempAlgParams_.outputSliceStride * myAlgRank + outBaseOff; | 124 | u64 txOutOffset = tempAlgParams_.outputSliceStride * myAlgRank + outBaseOff; |
| 119 | u64 txScratchOffset = scratchBase + tempAlgParams_.sliceSize * myAlgRank; | 125 | u64 txScratchOffset = scratchBase + tempAlgParams_.sliceSize * myAlgRank; |
| 120 | - u64 txDstOffset = txScratchOffset; | 126 | + u64 txDstOffset = (!enableRemoteMemAccess_) ? txScratchOffset : txOutOffset; |
| 121 | 127 | ||
| 122 | u64 rxOutOffset = tempAlgParams_.outputSliceStride * connectedAlgRank + outBaseOff; | 128 | u64 rxOutOffset = tempAlgParams_.outputSliceStride * connectedAlgRank + outBaseOff; |
| 123 | u64 rxScratchOffset = scratchBase + tempAlgParams_.sliceSize * connectedAlgRank; | 129 | u64 rxScratchOffset = scratchBase + tempAlgParams_.sliceSize * connectedAlgRank; |
| 124 | - u64 rxSrcOffset = rxScratchOffset; | 130 | + u64 rxSrcOffset = (!enableRemoteMemAccess_) ? rxScratchOffset : rxOutOffset; |
| 125 | 131 | ||
| 126 | void *txSrcPtr = tempAlgParams_.buffInfo.outputPtr; | 132 | void *txSrcPtr = tempAlgParams_.buffInfo.outputPtr; |
| 127 | - void *txDstPtr = remoteCclBuffAddr; | 133 | + void *txDstPtr = (!enableRemoteMemAccess_) ? remoteCclBuffAddr : linkRemote.remoteOutputGraphMode.addr; |
| 128 | - void *rxSrcPtr = remoteCclBuffAddr; | 134 | + void *rxSrcPtr = (!enableRemoteMemAccess_) ? remoteCclBuffAddr : linkRemote.remoteOutputGraphMode.addr; |
| 129 | void *rxDstPtr = tempAlgParams_.buffInfo.outputPtr; | 135 | void *rxDstPtr = tempAlgParams_.buffInfo.outputPtr; |
| 130 | - // write模式使用tx,rx地址不生效,仅使用对端link做Post/Wait | 136 | + // write模式使用tx, rx地址不生效,仅使用对端link做Post/Wait |
| 131 | // read 模式使用rx, tx地址不生效,仅使用对端link做Post/Wait | 137 | // read 模式使用rx, tx地址不生效,仅使用对端link做Post/Wait |
| 132 | std::vector<DataSlice> txSrcSlices{ | 138 | std::vector<DataSlice> txSrcSlices{ |
| 133 | DataSlice(txSrcPtr, txOutOffset, tempAlgParams_.sliceSize, tempAlgParams_.count)}; // 本地(send) | 139 | DataSlice(txSrcPtr, txOutOffset, tempAlgParams_.sliceSize, tempAlgParams_.count)}; // 本地(send) |
| @@ -135,9 +141,9 @@ HcclResult InsTempAllGatherMesh1D::RunAllGatherMesh(const std::vector<ThreadHand | |||
| 135 | DataSlice(txDstPtr, txDstOffset, tempAlgParams_.sliceSize, tempAlgParams_.count)}; // 远程(send) | 141 | DataSlice(txDstPtr, txDstOffset, tempAlgParams_.sliceSize, tempAlgParams_.count)}; // 远程(send) |
| 136 | // read模式使用rx | 142 | // read模式使用rx |
| 137 | std::vector<DataSlice> rxDstSlices{ | 143 | std::vector<DataSlice> rxDstSlices{ |
| 138 | - DataSlice(rxDstPtr, rxSrcOffset, tempAlgParams_.sliceSize, tempAlgParams_.count)}; // 本地(recv) | 144 | + DataSlice(rxDstPtr, rxOutOffset, tempAlgParams_.sliceSize, tempAlgParams_.count)}; // 本地(recv) |
| 139 | std::vector<DataSlice> rxSrcSlices{ | 145 | std::vector<DataSlice> rxSrcSlices{ |
| 140 | - DataSlice(rxSrcPtr, rxOutOffset, tempAlgParams_.sliceSize, tempAlgParams_.count)}; // 远程(recv) | 146 | + DataSlice(rxSrcPtr, rxSrcOffset, tempAlgParams_.sliceSize, tempAlgParams_.count)}; // 远程(recv) |
| 141 | 147 | ||
| 142 | HCCL_DEBUG("[InsTempAllGatherMesh1D][RunAllGatherMesh] rankId [%d] connectedRank [%d] txSrcSlices: " | 148 | HCCL_DEBUG("[InsTempAllGatherMesh1D][RunAllGatherMesh] rankId [%d] connectedRank [%d] txSrcSlices: " |
| 143 | "offset[%d] sliceSize[%d] count[%d].", | 149 | "offset[%d] sliceSize[%d] count[%d].", |
| @@ -62,6 +62,7 @@ HcclResult InsTempAllGatherNHR::KernelRun(const OpParam ¶m, const TemplateDa | |||
| 62 | } | 62 | } |
| 63 | threadNum_ = 1; | 63 | threadNum_ = 1; |
| 64 | tempAlgParams_ = tempAlgParams; | 64 | tempAlgParams_ = tempAlgParams; |
| 65 | + enableRemoteMemAccess_ = tempAlgParams.enableRemoteMemAccess; | ||
| 65 | CHK_PRT_RET(threadNum_ != templateResource.threads.size(), | 66 | CHK_PRT_RET(threadNum_ != templateResource.threads.size(), |
| 66 | HCCL_ERROR("[InsTempAllGatherNHR] Rank [%d], requiredQueNum [%u] not equals templateQueNum [%zu].", | 67 | HCCL_ERROR("[InsTempAllGatherNHR] Rank [%d], requiredQueNum [%u] not equals templateQueNum [%zu].", |
| 67 | myRank_, threadNum_, templateResource.threads.size()), | 68 | myRank_, threadNum_, templateResource.threads.size()), |
| @@ -0,0 +1,16 @@ | |||
| 1 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 2 | +# Copyright (c) 2025 Huawei Technologies Co., Ltd. | ||
| 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | +# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | +# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 10 | +set(src_list | ||
| 11 | + ${CMAKE_CURRENT_SOURCE_DIR}/calc_resource_graph_mode.cc | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +target_sources(hccl PRIVATE | ||
| 15 | + ${src_list} | ||
| 16 | +) | ||
| @@ -0,0 +1,129 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2025 Huawei Technologies Co., Ltd. | ||
| 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | + * See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +HcclResult HcclCreateOpParamGraphMode(OpParamGraphMode **opParam) | ||
| 16 | +{ | ||
| 17 | + if (opParam == nullptr) { | ||
| 18 | + return HCCL_E_PARA; | ||
| 19 | + } | ||
| 20 | + // 将void**转换为OpParamGraphMode** | ||
| 21 | + OpParamGraphMode **paramPtr = reinterpret_cast<OpParamGraphMode **>(opParam); | ||
| 22 | + *paramPtr = new OpParamGraphMode(); | ||
| 23 | + if (*paramPtr == nullptr) { | ||
| 24 | + return HCCL_E_MEMORY; | ||
| 25 | + } | ||
| 26 | + return HCCL_SUCCESS; | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +HcclResult HcclDestroyOpParamGraphMode(OpParamGraphMode *opParam) | ||
| 30 | +{ | ||
| 31 | + if (opParam == nullptr) { | ||
| 32 | + return HCCL_E_PARA; | ||
| 33 | + } | ||
| 34 | + // 将void*转换为OpParamGraphMode* | ||
| 35 | + OpParamGraphMode *paramPtr = reinterpret_cast<OpParamGraphMode *>(opParam); | ||
| 36 | + delete paramPtr; | ||
| 37 | + return HCCL_SUCCESS; | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +HcclResult HcclSetOpParamGraphModeOpType(OpParamGraphMode *opParam, const char *opType) | ||
| 41 | +{ | ||
| 42 | + if (opParam == nullptr || opType == nullptr) { | ||
| 43 | + return HCCL_E_PARA; | ||
| 44 | + } | ||
| 45 | + // 将void*转换为OpParamGraphMode* | ||
| 46 | + OpParamGraphMode *paramPtr = reinterpret_cast<OpParamGraphMode *>(opParam); | ||
| 47 | + strncpy_s(paramPtr->opType, sizeof(paramPtr->opType), opType, sizeof(paramPtr->opType) - 1); | ||
| 48 | + return HCCL_SUCCESS; | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +HcclResult HcclCalcOpResOnlineGraphMode(OpParamGraphMode *opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum) | ||
| 52 | +{ | ||
| 53 | + HCCL_INFO("Enter HcclCalcOpResOnlineGraphMode."); | ||
| 54 | + CHK_RET(CheckCalcResInputGraphMode(opParam, opMemSize, streamNum, taskNum, aivCoreNum)); | ||
| 55 | + // 将void**转换为OpParamGraphMode** | ||
| 56 | + OpParamGraphMode *paramPtr = reinterpret_cast<OpParamGraphMode *>(opParam); | ||
| 57 | + if (paramPtr == nullptr) { | ||
| 58 | + return HCCL_E_PARA; | ||
| 59 | + } | ||
| 60 | + // 为了兼容,创建临时的 ResResponseGraphMode 结构 | ||
| 61 | + ResResponseGraphMode resResponse = {0, 0, 0, 0}; | ||
| 62 | + HCCL_INFO("Start to calc op resource online."); | ||
| 63 | + // aicpu引擎计算资源 | ||
| 64 | + ops_hccl::HcclCalcAicpuResOffline(&resResponse); | ||
| 65 | + | ||
| 66 | + // 其他引擎补充在下面 | ||
| 67 | + | ||
| 68 | + // 将结果复制到输出参数 | ||
| 69 | + *opMemSize = resResponse.opMemSize; | ||
| 70 | + *streamNum = resResponse.streamNum; | ||
| 71 | + *taskNum = resResponse.taskNum; | ||
| 72 | + *aivCoreNum = resResponse.aivCoreNum; | ||
| 73 | + | ||
| 74 | + return HCCL_SUCCESS; | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | +HcclResult HcclCalcOpResOfflineGraphMode(OpParamGraphMode *opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum) | ||
| 78 | +{ | ||
| 79 | + HCCL_INFO("Enter HcclCalcOpResOfflineGraphMode."); | ||
| 80 | + CHK_RET(CheckCalcResInputGraphMode(opParam, opMemSize, streamNum, taskNum, aivCoreNum)); | ||
| 81 | + // 将void**转换为OpParamGraphMode** | ||
| 82 | + OpParamGraphMode *paramPtr = reinterpret_cast<OpParamGraphMode *>(opParam); | ||
| 83 | + if (paramPtr == nullptr) { | ||
| 84 | + return HCCL_E_PARA; | ||
| 85 | + } | ||
| 86 | + // 为了兼容,创建临时的 ResResponseGraphMode 结构 | ||
| 87 | + ResResponseGraphMode resResponse = {0, 0, 0, 0}; | ||
| 88 | + HCCL_INFO("Start to calc op resource offline."); | ||
| 89 | + // aicpu引擎计算资源 | ||
| 90 | + ops_hccl::HcclCalcAicpuResOffline(&resResponse); | ||
| 91 | + | ||
| 92 | + // 其他引擎补充在下面 | ||
| 93 | + | ||
| 94 | + // 将结果复制到输出参数 | ||
| 95 | + *opMemSize = resResponse.opMemSize; | ||
| 96 | + *streamNum = resResponse.streamNum; | ||
| 97 | + *taskNum = resResponse.taskNum; | ||
| 98 | + *aivCoreNum = resResponse.aivCoreNum; | ||
| 99 | + | ||
| 100 | + return HCCL_SUCCESS; | ||
| 101 | +} | ||
| 102 | + | ||
| 103 | +namespace ops_hccl { | ||
| 104 | +HcclResult HcclCalcAicpuResOffline(ResResponseGraphMode *resResponse) | ||
| 105 | +{ | ||
| 106 | + if (resResponse == nullptr) { | ||
| 107 | + return HCCL_E_PARA; | ||
| 108 | + } | ||
| 109 | + u64 aicpuOpMemSize = 0; | ||
| 110 | + u32 aicpuStreamNum = 0; | ||
| 111 | + u32 aicpuTaskNum = 3; | ||
| 112 | + | ||
| 113 | + resResponse->opMemSize = std::max(resResponse->opMemSize, aicpuOpMemSize); | ||
| 114 | + resResponse->streamNum = std::max(resResponse->streamNum, aicpuStreamNum); | ||
| 115 | + resResponse->taskNum = std::max(resResponse->taskNum, aicpuTaskNum); | ||
| 116 | + return HCCL_SUCCESS; | ||
| 117 | +} | ||
| 118 | + | ||
| 119 | +HcclResult CheckCalcResInputGraphMode(const OpParamGraphMode *opParam, const u64 *opMemSize, const u32 *streamNum, | ||
| 120 | + const u32 *taskNum, const u32 *aivCoreNum) | ||
| 121 | +{ | ||
| 122 | + CHK_PTR_NULL(opParam); | ||
| 123 | + CHK_PTR_NULL(opMemSize); | ||
| 124 | + CHK_PTR_NULL(streamNum); | ||
| 125 | + CHK_PTR_NULL(taskNum); | ||
| 126 | + CHK_PTR_NULL(aivCoreNum); | ||
| 127 | + return HCCL_SUCCESS; | ||
| 128 | +} | ||
| 129 | +} // namespace ops_hccl | ||
| @@ -0,0 +1,30 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2025 Huawei Technologies Co., Ltd. | ||
| 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | + * See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +extern "C" { | ||
| 15 | + | ||
| 16 | +using namespace ops_hccl; | ||
| 17 | +HcclResult HcclCreateOpParamGraphMode(OpParamGraphMode **opParam); | ||
| 18 | +HcclResult HcclDestroyOpParamGraphMode(OpParamGraphMode *opParam); | ||
| 19 | +HcclResult HcclSetOpParamGraphModeOpType(OpParamGraphMode *opParam, const char *opType); | ||
| 20 | +HcclResult HcclCalcOpResOnlineGraphMode(OpParamGraphMode *opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum); | ||
| 21 | +HcclResult HcclCalcOpResOfflineGraphMode(OpParamGraphMode *opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum); | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +namespace ops_hccl { | ||
| 27 | +HcclResult CheckCalcResInputGraphMode(const OpParamGraphMode *opParam, const u64 *opMemSize, const u32 *streamNum, const u32 *taskNum, const u32 *aivCoreNum); | ||
| 28 | +HcclResult HcclCalcAicpuResOffline(ResResponseGraphMode *resResponse); | ||
| 29 | + | ||
| 30 | +} // namespace ops_hccl | ||
| @@ -14,6 +14,7 @@ add_subdirectory(topo) | |||
| 14 | 14 | ||
| 15 | set(src_list | 15 | set(src_list |
| 16 | ${CMAKE_CURRENT_SOURCE_DIR}/op_common.cc | 16 | ${CMAKE_CURRENT_SOURCE_DIR}/op_common.cc |
| 17 | + | ||
| 17 | ) | 18 | ) |
| 18 | 19 | ||
| 19 | target_sources(hccl PRIVATE | 20 | target_sources(hccl PRIVATE |
| @@ -41,6 +41,8 @@ constexpr uint32_t OP_ALG_LENGTH = 128; // 存放算法 + host/device标记 | |||
| 41 | constexpr uint32_t ALG_TAG_LENGTH = TAG_LENGTH + OP_ALG_LENGTH; | 41 | constexpr uint32_t ALG_TAG_LENGTH = TAG_LENGTH + OP_ALG_LENGTH; |
| 42 | constexpr uint32_t MAX_TAG_LENGTH = 255; | 42 | constexpr uint32_t MAX_TAG_LENGTH = 255; |
| 43 | constexpr uint32_t AICPU_CONTROL_NOTIFY_NUM = 2; | 43 | constexpr uint32_t AICPU_CONTROL_NOTIFY_NUM = 2; |
| 44 | +constexpr uint32_t MAX_MEM_TAG_LENGTH = OP_ALG_LENGTH + 32; | ||
| 45 | +constexpr uint32_t RES_PACK_TAG_LENGTH = 255; | ||
| 44 | 46 | ||
| 45 | // 是否再拆分一个comm头文件 | 47 | // 是否再拆分一个comm头文件 |
| 46 | constexpr u32 LOCAL_NOTIFY_IDX_ZERO = 0; | 48 | constexpr u32 LOCAL_NOTIFY_IDX_ZERO = 0; |
| @@ -281,8 +283,10 @@ struct ChannelInfo { | |||
| 281 | u32 notifyNum; | 283 | u32 notifyNum; |
| 282 | ChannelHandle handle; | 284 | ChannelHandle handle; |
| 283 | HcclMem remoteCclMem; // A5用的 | 285 | HcclMem remoteCclMem; // A5用的 |
| 284 | - HcclMem remoteInput; // A3用的 | 286 | + HcclMem remoteInputGraphMode; // A5用的, 图模式下远端sendBuf地址 |
| 285 | - HcclMem remoteOutput; // A3用的 | 287 | + HcclMem remoteOutputGraphMode; // A5用的,图模式下远端recvBuf地址 |
| 288 | + HcclMem remoteInput; // A3用的,cclIn | ||
| 289 | + HcclMem remoteOutput; // A3用的, cclOut | ||
| 286 | }; | 290 | }; |
| 287 | 291 | ||
| 288 | // 算法ctx,key为通信域id+算法名,提前在device上 | 292 | // 算法ctx,key为通信域id+算法名,提前在device上 |
| @@ -492,5 +496,28 @@ struct HcomProInfo { | |||
| 492 | bool isAiv = false; | 496 | bool isAiv = false; |
| 493 | uint8_t reserved[MAX_LENGTH]; | 497 | uint8_t reserved[MAX_LENGTH]; |
| 494 | }; | 498 | }; |
| 495 | -} | 499 | + |
| 500 | +// 图模式相关定义 | ||
| 501 | +// 图模式编译阶段资源计算入参 | ||
| 502 | +struct OpParamGraphMode { | ||
| 503 | + char opType[64]; // 算子类型 | ||
| 504 | +}; | ||
| 505 | + | ||
| 506 | +// 图模式编译阶段申请资源 | ||
| 507 | +struct ResResponseGraphMode { | ||
| 508 | + u64 opMemSize = 0; // 额外申请的scratch数量(不包括cclBuff) | ||
| 509 | + u32 streamNum = 0; // 除用户流以外,额外申请的流(不包括算子device展开申请的流) | ||
| 510 | + u32 taskNum = 0; // task数量,一般为前同步 + kernel + 后同步 | ||
| 511 | + u32 aivCoreNum = 0; | ||
| 512 | +}; | ||
| 513 | + | ||
| 514 | +// 图模式执行阶段传入的资源 | ||
| 515 | +struct ResPackGraphMode { | ||
| 516 | + char tag[RES_PACK_TAG_LENGTH]; | ||
| 517 | + std::vector<aclrtStream> streams; | ||
| 518 | + void* scratchMemAddr; | ||
| 519 | + u64 scratchMemSize; | ||
| 520 | +}; | ||
| 521 | + | ||
| 522 | +} | ||
| 496 | 523 | ||
| @@ -148,7 +148,7 @@ uint32_t GetHcclDfxOpInfoDataType(const OpParam ¶m) { | |||
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | HcclResult HcclExecOp(HcclComm comm, OpParam ¶m, | 150 | HcclResult HcclExecOp(HcclComm comm, OpParam ¶m, |
| 151 | - std::unique_ptr<TopoInfoWithNetLayerDetails> &topoInfo, std::string &algName) | 151 | + std::unique_ptr<TopoInfoWithNetLayerDetails> &topoInfo, std::string &algName, const ResPackGraphMode &resPack) |
| 152 | { | 152 | { |
| 153 | uint64_t beginTime = HcommGetProfilingSysCycleTime(); | 153 | uint64_t beginTime = HcommGetProfilingSysCycleTime(); |
| 154 | HCCL_INFO("[HcclExecOp]Start to execute HcclExecOp.HcommGetProfilingSysCycleTime.%llu", beginTime); | 154 | HCCL_INFO("[HcclExecOp]Start to execute HcclExecOp.HcommGetProfilingSysCycleTime.%llu", beginTime); |
| @@ -391,12 +391,13 @@ HcclResult HcclGetAlgRes(HcclComm comm, OpParam& param, std::shared_ptr<InsCollA | |||
| 391 | 391 | ||
| 392 | void *ctx = nullptr; | 392 | void *ctx = nullptr; |
| 393 | bool increCreateChannelFlag = false; | 393 | bool increCreateChannelFlag = false; |
| 394 | - if (param.opType == HcclCMDType::HCCL_CMD_BATCH_SEND_RECV) { | 394 | + if (param.opType == HcclCMDType::HCCL_CMD_BATCH_SEND_RECV && param.opMode == OpMode::OPBASE) { |
| 395 | // 增量建链模式 | 395 | // 增量建链模式 |
| 396 | increCreateChannelFlag = true; | 396 | increCreateChannelFlag = true; |
| 397 | } | 397 | } |
| 398 | uint64_t size = 0; | 398 | uint64_t size = 0; |
| 399 | - if (!increCreateChannelFlag) { | 399 | + // 图模式不支持资源复用,且不存在增量建链场景 |
| 400 | + if (!increCreateChannelFlag && param.opMode == OpMode::OPBASE) { | ||
| 400 | void *ctx = nullptr; | 401 | void *ctx = nullptr; |
| 401 | // 这种情况下资源已经有了 | 402 | // 这种情况下资源已经有了 |
| 402 | CommEngine ctxEngine = param.engine; | 403 | CommEngine ctxEngine = param.engine; |
| @@ -628,6 +629,7 @@ HcclResult GetMainThreadInfo(HcclComm comm, const OpParam ¶m, ThreadHandle & | |||
| 628 | HcclResult HcclGetChannel(HcclComm comm, const OpParam ¶m, AlgResourceRequest &resRequest, | 629 | HcclResult HcclGetChannel(HcclComm comm, const OpParam ¶m, AlgResourceRequest &resRequest, |
| 629 | std::unique_ptr<AlgResourceCtxSerializable>& resCtxHost) | 630 | std::unique_ptr<AlgResourceCtxSerializable>& resCtxHost) |
| 630 | { | 631 | { |
| 632 | + | ||
| 631 | resCtxHost->channels.resize(resRequest.channels.size()); | 633 | resCtxHost->channels.resize(resRequest.channels.size()); |
| 632 | for (u32 level = 0; level < resRequest.channels.size(); level++) { | 634 | for (u32 level = 0; level < resRequest.channels.size(); level++) { |
| 633 | // 获取子通信域的建链请求 | 635 | // 获取子通信域的建链请求 |
| @@ -641,61 +643,112 @@ HcclResult HcclGetChannel(HcclComm comm, const OpParam ¶m, AlgResourceReques | |||
| 641 | hostChannelRequest.emplace_back(channelRequest); | 643 | hostChannelRequest.emplace_back(channelRequest); |
| 642 | } | 644 | } |
| 643 | } | 645 | } |
| 644 | - // 获取子通信域的建链数量 | 646 | + // device建链 |
| 645 | - u32 channelNum = deviceChannelRequest.size(); | 647 | + CHK_RET(HcclGetChannelImpl(level, comm, param, deviceChannelRequest, COMM_ENGINE_AICPU_TS, resCtxHost)); |
| 646 | - std::vector<ChannelHandle> levelNDeviceChannels; | 648 | + // host建链 |
| 647 | - levelNDeviceChannels.resize(channelNum); | 649 | + CHK_RET(HcclGetChannelImpl(level, comm, param, hostChannelRequest, COMM_ENGINE_CPU, resCtxHost)); |
| 650 | + | ||
| 651 | + } | ||
| 652 | + return HCCL_SUCCESS; | ||
| 653 | +} | ||
| 648 | 654 | ||
| 649 | - if (channelNum > 0) { | 655 | +HcclResult HcclGetChannelImpl(const u32 level, HcclComm comm, const OpParam ¶m, std::vector<HcclChannelDesc>& channelRequest, |
| 650 | - CHK_RET(HcclChannelAcquire(comm, COMM_ENGINE_AICPU_TS, deviceChannelRequest.data(), | 656 | + const CommEngine commEngine, std::unique_ptr<AlgResourceCtxSerializable>& resCtxHost) { |
| 651 | - channelNum, levelNDeviceChannels.data())); | 657 | + // 获取子通信域的建链数量 |
| 658 | + if (channelRequest.empty()) { | ||
| 659 | + HCCL_INFO("[HcclGetChannelImpl] channelRequest is empty"); | ||
| 660 | + return HCCL_SUCCESS; | ||
| 661 | + } | ||
| 662 | + u32 channelNum = channelRequest.size(); | ||
| 663 | + std::vector<ChannelHandle> levelNChannels; | ||
| 664 | + levelNChannels.resize(channelNum); | ||
| 665 | + char inputBuffTag[MAX_MEM_TAG_LENGTH]; | ||
| 666 | + char outputBuffTag[MAX_MEM_TAG_LENGTH]; | ||
| 667 | + std::vector<HcclMemHandle> memHandles; | ||
| 668 | + if (param.opMode == OpMode::OFFLOAD) { | ||
| 669 | + HCCL_INFO("[HcclGetChannelImpl] start to RegGraphModeBuffers"); | ||
| 670 | + CHK_RET(RegGraphModeBuffers(comm, param, channelRequest, inputBuffTag, outputBuffTag, memHandles)); | ||
| 671 | + for (auto &channelDesc : channelRequest) { | ||
| 672 | + channelDesc.memHandles = memHandles.data(); | ||
| 673 | + channelDesc.memHandleNum = memHandles.size(); | ||
| 674 | + } | ||
| 675 | + } | ||
| 676 | + if (channelNum > 0) { | ||
| 677 | + CHK_RET(HcclChannelAcquire(comm, commEngine, channelRequest.data(), | ||
| 678 | + channelNum, levelNChannels.data())); | ||
| 679 | + } | ||
| 680 | + | ||
| 681 | + for (u32 idx = 0; idx < channelNum; idx++) { | ||
| 682 | + ChannelInfo channel; | ||
| 683 | + // 对于真实建链的链路进行填充 | ||
| 684 | + const HcclChannelDesc &channelDescNew = channelRequest[idx]; | ||
| 685 | + channel.isValid = true; | ||
| 686 | + channel.remoteRank = channelDescNew.remoteRank; | ||
| 687 | + channel.protocol = channelDescNew.channelProtocol; | ||
| 688 | + channel.locationType = channelDescNew.remoteEndpoint.loc.locType; | ||
| 689 | + channel.notifyNum = channelDescNew.notifyNum; | ||
| 690 | + channel.handle = levelNChannels[idx]; | ||
| 691 | + | ||
| 692 | + void* remoteCclBufferAddr; | ||
| 693 | + uint64_t remoteCclBufferSize; | ||
| 694 | + CHK_RET(HcclChannelGetHcclBuffer(comm, levelNChannels[idx], &remoteCclBufferAddr, &remoteCclBufferSize)); | ||
| 695 | + channel.remoteCclMem = HcclMem{HCCL_MEM_TYPE_DEVICE, remoteCclBufferAddr, remoteCclBufferSize}; | ||
| 696 | + | ||
| 697 | + if (param.opMode == OpMode::OFFLOAD) { | ||
| 698 | + CHK_RET(GetGraphModeBuffers(comm, levelNChannels[idx], inputBuffTag, outputBuffTag, channel)); | ||
| 652 | } | 699 | } |
| 653 | 700 | ||
| 654 | - for (u32 idx = 0; idx < channelNum; idx++) { | ||
| 655 | - ChannelInfo channel; | ||
| 656 | - // 对于真实建链的链路进行填充 | ||
| 657 | - HcclChannelDesc &channelDescNew = deviceChannelRequest[idx]; | ||
| 658 | - channel.isValid = true; | ||
| 659 | - channel.remoteRank = channelDescNew.remoteRank; | ||
| 660 | - channel.protocol = channelDescNew.channelProtocol; | ||
| 661 | - channel.locationType = channelDescNew.remoteEndpoint.loc.locType; | ||
| 662 | - channel.notifyNum = channelDescNew.notifyNum; | ||
| 663 | - channel.handle = levelNDeviceChannels[idx]; | ||
| 664 | 701 | ||
| 665 | - void* remoteBufferAddr; | 702 | + resCtxHost->channels[level].push_back(channel); |
| 666 | - uint64_t remoteBufferSize; | 703 | + } |
| 667 | - CHK_RET(HcclChannelGetHcclBuffer(comm, levelNDeviceChannels[idx], &remoteBufferAddr, &remoteBufferSize)); | 704 | + return HCCL_SUCCESS; |
| 668 | - channel.remoteCclMem = HcclMem{HCCL_MEM_TYPE_DEVICE, remoteBufferAddr, remoteBufferSize}; | 705 | +} |
| 669 | - resCtxHost->channels[level].push_back(channel); | ||
| 670 | - } | ||
| 671 | 706 | ||
| 672 | - // 获取子通信域的建链数量 | ||
| 673 | - channelNum = hostChannelRequest.size(); | ||
| 674 | - std::vector<ChannelHandle> levelNHostChannels; | ||
| 675 | - levelNHostChannels.resize(channelNum); | ||
| 676 | 707 | ||
| 677 | - if (channelNum > 0) { | 708 | +HcclResult RegGraphModeBuffers(HcclComm comm, const OpParam ¶m, std::vector<HcclChannelDesc>& channelRequest, char* inputBuffTag, char* outputBuffTag, std::vector<HcclMemHandle>& memHandles) { |
| 678 | - CHK_RET(HcclChannelAcquire(comm, COMM_ENGINE_CPU, hostChannelRequest.data(), | 709 | + HCCL_INFO("[RegGraphModeBuffers] param.algTag[%s]", param.algTag); |
| 679 | - channelNum, levelNHostChannels.data())); | 710 | + if (channelRequest.empty()) { |
| 680 | - } | 711 | + HCCL_INFO("[RegGraphModeBuffers]channelRequest is empty"); |
| 712 | + return HCCL_SUCCESS; | ||
| 713 | + } | ||
| 681 | 714 | ||
| 682 | - for (u32 idx = 0; idx < channelNum; idx++) { | 715 | + auto retIn = sprintf_s(inputBuffTag, MAX_MEM_TAG_LENGTH, "%s_%s", param.algTag, "InputBuffer"); |
| 683 | - ChannelInfo channel; | 716 | + auto retOut = sprintf_s(outputBuffTag, MAX_MEM_TAG_LENGTH, "%s_%s", param.algTag, "OutputBuffer"); |
| 684 | - // 对于真实建链的链路进行填充 | 717 | + if (retIn <= 0 || retOut <= 0){ |
| 685 | - HcclChannelDesc &channelDescNew = hostChannelRequest[idx]; | 718 | + HCCL_ERROR("[RegGraphModeBuffers]faled to fill BuffTag"); |
| 686 | - channel.isValid = true; | 719 | + return HcclResult::HCCL_E_INTERNAL; |
| 687 | - channel.remoteRank = channelDescNew.remoteRank; | 720 | + } |
| 688 | - channel.protocol = channelDescNew.channelProtocol; | ||
| 689 | - channel.locationType = channelDescNew.remoteEndpoint.loc.locType; | ||
| 690 | - channel.notifyNum = channelDescNew.notifyNum; | ||
| 691 | - channel.handle = levelNHostChannels[idx]; | ||
| 692 | 721 | ||
| 693 | - void* remoteBufferAddr; | 722 | + HCCL_INFO("[RegGraphModeBuffers] graph mode regstry remote buuffer"); |
| 694 | - uint64_t remoteBufferSize; | 723 | + if (param.inputPtr != nullptr) { |
| 695 | - CHK_RET(HcclChannelGetHcclBuffer(comm, levelNHostChannels[idx], &remoteBufferAddr, &remoteBufferSize)); | 724 | + HcclMemHandle inputHandle = nullptr; |
| 696 | - channel.remoteCclMem = HcclMem{HCCL_MEM_TYPE_DEVICE, remoteBufferAddr, remoteBufferSize}; | 725 | + CHK_RET(HcclRegstryBuff(comm, inputBuffTag, param.inputPtr, param.inputSize, &inputHandle)); |
| 697 | - resCtxHost->channels[level].push_back(channel); | 726 | + CHK_PTR_NULL(inputHandle); |
| 698 | - } | 727 | + memHandles.emplace_back(inputHandle); |
| 728 | + } | ||
| 729 | + if (param.outputPtr != nullptr) { | ||
| 730 | + HcclMemHandle outputHandle = nullptr; | ||
| 731 | + CHK_RET(HcclRegstryBuff(comm, outputBuffTag, param.outputPtr, param.outputSize, &outputHandle)); | ||
| 732 | + CHK_PTR_NULL(outputHandle); | ||
| 733 | + memHandles.emplace_back(outputHandle); | ||
| 734 | + } | ||
| 735 | + HCCL_INFO("[RegGraphModeBuffers]memHandles size[%d]", memHandles.size()); | ||
| 736 | + return HCCL_SUCCESS; | ||
| 737 | +} | ||
| 738 | + | ||
| 739 | +HcclResult GetGraphModeBuffers(HcclComm comm, ChannelHandle channelHandle, const char* inputBuffTag, const char* outputBuffTag, ChannelInfo& channel) { | ||
| 740 | + void* remoteInputBufferAddr = nullptr; | ||
| 741 | + uint64_t remoteInputBufferSize = 0; | ||
| 742 | + CHK_RET(HcclGetRemoteBuff(comm, channelHandle, inputBuffTag, &remoteInputBufferAddr, &remoteInputBufferSize)); | ||
| 743 | + if (remoteInputBufferAddr != nullptr && remoteInputBufferSize > 0) { | ||
| 744 | + channel.remoteInputGraphMode = HcclMem{HCCL_MEM_TYPE_DEVICE, remoteInputBufferAddr, remoteInputBufferSize}; | ||
| 745 | + } | ||
| 746 | + | ||
| 747 | + void* remoteOutputBufferAddr = nullptr; | ||
| 748 | + uint64_t remoteOutputBufferSize = 0; | ||
| 749 | + CHK_RET(HcclGetRemoteBuff(comm, channelHandle, outputBuffTag, &remoteOutputBufferAddr, &remoteOutputBufferSize)); | ||
| 750 | + if (remoteOutputBufferAddr != nullptr && remoteOutputBufferSize > 0) { | ||
| 751 | + channel.remoteOutputGraphMode = HcclMem{HCCL_MEM_TYPE_DEVICE, remoteOutputBufferAddr, remoteOutputBufferSize}; | ||
| 699 | } | 752 | } |
| 700 | return HCCL_SUCCESS; | 753 | return HCCL_SUCCESS; |
| 701 | } | 754 | } |
| @@ -1199,6 +1252,43 @@ bool HcclCheckAicpuEnableOpen() | |||
| 1199 | return false; | 1252 | return false; |
| 1200 | } | 1253 | } |
| 1201 | 1254 | ||
| 1255 | +HcclResult HcclRegstryBuff(HcclComm comm, const char *memTag, void *bufferPtr, uint64_t bufferSize, HcclMemHandle *memHandle) | ||
| 1256 | +{ | ||
| 1257 | + CHK_PTR_NULL(memHandle); | ||
| 1258 | + CommMem regMem{COMM_MEM_TYPE_DEVICE, bufferPtr, bufferSize}; | ||
| 1259 | + CHK_RET(HcclCommMemReg(comm, memTag, ®Mem, memHandle)); | ||
| 1260 | + HCCL_INFO("[%s] regMemAddr[%p] regMemSize[%llu]", __func__, regMem.addr, regMem.size); | ||
| 1261 | + CHK_PTR_NULL(*memHandle); | ||
| 1262 | + return HCCL_SUCCESS; | ||
| 1263 | +} | ||
| 1264 | + | ||
| 1265 | +HcclResult HcclGetRemoteBuff(HcclComm comm, ChannelHandle channel, const char *memTag, void **bufferPtr, uint64_t *bufferSize) | ||
| 1266 | +{ | ||
| 1267 | + CHK_PTR_NULL(bufferPtr); | ||
| 1268 | + CHK_PTR_NULL(bufferSize); | ||
| 1269 | + | ||
| 1270 | + u32 memNum; | ||
| 1271 | + CommMem *remoteMemList; | ||
| 1272 | + char **memTags; | ||
| 1273 | + CHK_RET(HcclChannelGetRemoteMems(comm, channel, &memNum, &remoteMemList, &memTags)); | ||
| 1274 | + HCCL_INFO("[%s] HcclChannelGetRemoteMems memNum[%u]", __func__, memNum); | ||
| 1275 | + for (u32 i=0; i< memNum; i++) { | ||
| 1276 | + HCCL_INFO("[%s] memNum[%u/%u] memTags[%s]", __func__, i, memNum, memTags[i]); | ||
| 1277 | + if (strcmp(memTags[i], memTag) == 0) { | ||
| 1278 | + *bufferPtr = remoteMemList[i].addr; | ||
| 1279 | + *bufferSize = remoteMemList[i].size; | ||
| 1280 | + HCCL_INFO("[%s] Found %u memNum[%u/%u] is %u at index %u: addr=%p, size=%llu", __func__, *memTag, | ||
| 1281 | + memNum, i, remoteMemList[i].addr, remoteMemList[i].size); | ||
| 1282 | + break; | ||
| 1283 | + } | ||
| 1284 | + } | ||
| 1285 | + if (*bufferPtr == nullptr) { | ||
| 1286 | + HCCL_WARNING("[%s] Failed to find %s in remote mem list", __func__, memTag); | ||
| 1287 | + } | ||
| 1288 | + return HCCL_SUCCESS; | ||
| 1289 | +} | ||
| 1290 | + | ||
| 1291 | + | ||
| 1202 | bool HcclCheckCcuEnableOpen() | 1292 | bool HcclCheckCcuEnableOpen() |
| 1203 | { | 1293 | { |
| 1204 | const char* envValue = std::getenv("HCCL_ENABLE_OPEN_CCU"); | 1294 | const char* envValue = std::getenv("HCCL_ENABLE_OPEN_CCU"); |
| @@ -30,7 +30,7 @@ extern "C" { | |||
| 30 | 30 | ||
| 31 | namespace ops_hccl { | 31 | namespace ops_hccl { |
| 32 | 32 | ||
| 33 | -HcclResult HcclExecOp(HcclComm comm, OpParam ¶m, std::unique_ptr<TopoInfoWithNetLayerDetails> &topoInfo, std::string &algName); | 33 | +HcclResult HcclExecOp(HcclComm comm, OpParam ¶m, std::unique_ptr<TopoInfoWithNetLayerDetails> &topoInfo, std::string &algName, const ResPackGraphMode &resPack = ResPackGraphMode()); |
| 34 | 34 | ||
| 35 | HcclResult HcclCalcTopoInfo(HcclComm comm, OpParam ¶m, std::unique_ptr<TopoInfoWithNetLayerDetails> &topoInfo); | 35 | HcclResult HcclCalcTopoInfo(HcclComm comm, OpParam ¶m, std::unique_ptr<TopoInfoWithNetLayerDetails> &topoInfo); |
| 36 | 36 | ||
| @@ -51,7 +51,10 @@ HcclResult HcclGetThread(HcclComm comm, const OpParam ¶m, | |||
| 51 | 51 | ||
| 52 | HcclResult HcclGetChannel(HcclComm comm, const OpParam ¶m, AlgResourceRequest &resRequest, | 52 | HcclResult HcclGetChannel(HcclComm comm, const OpParam ¶m, AlgResourceRequest &resRequest, |
| 53 | std::unique_ptr<AlgResourceCtxSerializable>& resCtxHost); | 53 | std::unique_ptr<AlgResourceCtxSerializable>& resCtxHost); |
| 54 | - | 54 | +HcclResult HcclGetChannelImpl(const u32 level, HcclComm comm, const OpParam ¶m, std::vector<HcclChannelDesc>& channelRequest, |
| 55 | + const CommEngine commEngine, std::unique_ptr<AlgResourceCtxSerializable>& resCtxHost); | ||
| 56 | +HcclResult RegGraphModeBuffers(HcclComm comm, const OpParam ¶m, std::vector<HcclChannelDesc>& channelRequest, char* inputBuffTag, char* outputBuffTag, std::vector<HcclMemHandle>& memHandles); | ||
| 57 | +HcclResult GetGraphModeBuffers(HcclComm comm, ChannelHandle channelHandle, const char* inputBuffTag, const char* outputBuffTag, ChannelInfo& channel); | ||
| 55 | HcclResult HcclGetCcuKernel(HcclComm comm, AlgResourceRequest &resRequest, | 58 | HcclResult HcclGetCcuKernel(HcclComm comm, AlgResourceRequest &resRequest, |
| 56 | std::unique_ptr<AlgResourceCtxSerializable>& resCtxHost); | 59 | std::unique_ptr<AlgResourceCtxSerializable>& resCtxHost); |
| 57 | 60 | ||
| @@ -120,6 +123,10 @@ bool HcclCheckCcuEnableOpen(); | |||
| 120 | bool HcclCheckAivEnableOpen(); | 123 | bool HcclCheckAivEnableOpen(); |
| 121 | bool ShouldUseInnerOp(OpExecuteConfig opExecuteConfig); | 124 | bool ShouldUseInnerOp(OpExecuteConfig opExecuteConfig); |
| 122 | 125 | ||
| 126 | +HcclResult HcclRegstryBuff(HcclComm comm, const char *memTag, void *bufferPtr, uint64_t bufferSize, HcclMemHandle *memHandle); | ||
| 127 | + | ||
| 128 | +HcclResult HcclGetRemoteBuff(HcclComm comm, ChannelHandle channel, const char *memTag, void **bufferPtr, uint64_t *bufferSize); | ||
| 129 | + | ||
| 123 | } // namespace ops_hccl | 130 | } // namespace ops_hccl |
| 124 | 131 | ||
| 125 | 132 | ||
| @@ -24,5 +24,6 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | + | ||
| 27 | 28 | ||
| 28 | 29 | ||
| @@ -52,11 +52,7 @@ SelectorStatus AutoSelectorBase::Select(OpParam &opParam, TopoInfoWithNetLayerDe | |||
| 52 | if (IsStarsState(opParam.opExecuteConfig)) { | 52 | if (IsStarsState(opParam.opExecuteConfig)) { |
| 53 | ret = SelectAicpuAlgo(topoInfo, opParam, configAlgMap, selectAlgName); | 53 | ret = SelectAicpuAlgo(topoInfo, opParam, configAlgMap, selectAlgName); |
| 54 | if (ret == SelectorStatus::MATCH) { | 54 | if (ret == SelectorStatus::MATCH) { |
| 55 | - if (opParam.opMode == OpMode::OPBASE) { | 55 | + opParam.opExecuteConfig = OpExecuteConfig::AICPU_TS; |
| 56 | - opParam.opExecuteConfig = OpExecuteConfig::AICPU_TS; | ||
| 57 | - } else { | ||
| 58 | - opParam.opExecuteConfig = OpExecuteConfig::HOSTCPU_TS; | ||
| 59 | - } | ||
| 60 | } | 56 | } |
| 61 | } | 57 | } |
| 62 | HCCL_INFO("[Algo][AutoSelectorBase] The selected algo is %s, OpExecuteConfig is %d.", | 58 | HCCL_INFO("[Algo][AutoSelectorBase] The selected algo is %s, OpExecuteConfig is %d.", |
| @@ -78,6 +78,8 @@ protected: | |||
| 78 | std::vector<u32> notifyIdxMainToSub_; | 78 | std::vector<u32> notifyIdxMainToSub_; |
| 79 | // 用于记录从thread向主thread发送record的时候使用主thread的哪个notify | 79 | // 用于记录从thread向主thread发送record的时候使用主thread的哪个notify |
| 80 | std::vector<u32> notifyIdxSubToMain_; | 80 | std::vector<u32> notifyIdxSubToMain_; |
| 81 | + // 是否可以直接访问对端input/output memory | ||
| 82 | + bool enableRemoteMemAccess_ = false; | ||
| 81 | }; | 83 | }; |
| 82 | } // namespace Hccl | 84 | } // namespace Hccl |
| 83 | 85 | ||
| @@ -178,6 +178,7 @@ struct TemplateDataParams { | |||
| 178 | u64 inputRepeatStride{0}; | 178 | u64 inputRepeatStride{0}; |
| 179 | u64 outputRepeatStride{0}; | 179 | u64 outputRepeatStride{0}; |
| 180 | u64 tailSize{0}; | 180 | u64 tailSize{0}; |
| 181 | + bool enableRemoteMemAccess{false}; | ||
| 181 | u64 processedDataCount{0}; | 182 | u64 processedDataCount{0}; |
| 182 | u64 root{0}; | 183 | u64 root{0}; |
| 183 | HcclDataType dataType{HCCL_DATA_TYPE_INT8}; | 184 | HcclDataType dataType{HCCL_DATA_TYPE_INT8}; |
| @@ -202,6 +203,7 @@ struct TemplateDataParams { | |||
| 202 | binaryStream << inputRepeatStride; | 203 | binaryStream << inputRepeatStride; |
| 203 | binaryStream << outputRepeatStride; | 204 | binaryStream << outputRepeatStride; |
| 204 | binaryStream << tailSize; | 205 | binaryStream << tailSize; |
| 206 | + binaryStream << enableRemoteMemAccess; | ||
| 205 | binaryStream << allRankSliceSize; | 207 | binaryStream << allRankSliceSize; |
| 206 | binaryStream << allRankDispls; | 208 | binaryStream << allRankDispls; |
| 207 | binaryStream << sendCounts; | 209 | binaryStream << sendCounts; |
| @@ -228,6 +230,7 @@ struct TemplateDataParams { | |||
| 228 | binaryStream >> inputRepeatStride; | 230 | binaryStream >> inputRepeatStride; |
| 229 | binaryStream >> outputRepeatStride; | 231 | binaryStream >> outputRepeatStride; |
| 230 | binaryStream >> tailSize; | 232 | binaryStream >> tailSize; |
| 233 | + binaryStream >> enableRemoteMemAccess; | ||
| 231 | binaryStream >> allRankSliceSize; | 234 | binaryStream >> allRankSliceSize; |
| 232 | binaryStream >> allRankDispls; | 235 | binaryStream >> allRankDispls; |
| 233 | binaryStream >> sendCounts; | 236 | binaryStream >> sendCounts; |