已合并
【PR】: hcce support call hccl op #1620
Archerls创建于 3月30日
【PR】: hcce support call hccl op #1620
已合并
共 17 个文件变更+2271-259
| @@ -119,3 +119,184 @@ HcclResult HcceGetandClearOverFlowTasks(const char *group, hccl::HcclDumpInfo ** | |||
| 119 | 119 | ||
| 120 | return DlHcclFunction::get_instance().dlHcomGetandClearOverFlowTasks(group, hcclDumpInfo, len); | 120 | return DlHcclFunction::get_instance().dlHcomGetandClearOverFlowTasks(group, hcclDumpInfo, len); |
| 121 | } | 121 | } |
| 122 | + | ||
| 123 | +// 图模式相关函数实现 | ||
| 124 | +HcclResult HcceIsHcclGraphModeValid(bool &isValid) { | ||
| 125 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 126 | + HCCL_E_PARA); | ||
| 127 | + | ||
| 128 | + isValid = DlHcclFunction::get_instance().isLoadHcclGraphModeFunctions(); | ||
| 129 | + return HCCL_SUCCESS; | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +HcclResult HcceCreateOpParamGraphMode(OpParamGraphModePtr *opParam) { | ||
| 133 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 134 | + HCCL_E_PARA); | ||
| 135 | + | ||
| 136 | + return DlHcclFunction::get_instance().dlHcclCreateOpParamGraphMode(opParam); | ||
| 137 | +} | ||
| 138 | + | ||
| 139 | +HcclResult HcceDestroyOpParamGraphMode(OpParamGraphModePtr opParam) { | ||
| 140 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 141 | + HCCL_E_PARA); | ||
| 142 | + | ||
| 143 | + return DlHcclFunction::get_instance().dlHcclDestroyOpParamGraphMode(opParam); | ||
| 144 | +} | ||
| 145 | + | ||
| 146 | +HcclResult HcceSetOpParamGraphModeOpType(OpParamGraphModePtr opParam, const char *opType) { | ||
| 147 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 148 | + HCCL_E_PARA); | ||
| 149 | + | ||
| 150 | + return DlHcclFunction::get_instance().dlHcclSetOpParamGraphModeOpType(opParam, opType); | ||
| 151 | +} | ||
| 152 | + | ||
| 153 | +HcclResult HcceSetOpParamGraphModeDataCount(OpParamGraphModePtr opParam, const u64 *dataCount) { | ||
| 154 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 155 | + HCCL_E_PARA); | ||
| 156 | + | ||
| 157 | + return DlHcclFunction::get_instance().dlHcclSetOpParamGraphModeDataCount(opParam, dataCount); | ||
| 158 | +} | ||
| 159 | + | ||
| 160 | +HcclResult HcceSetOpParamGraphModeRankSize(OpParamGraphModePtr opParam, const u32 *rankSize) { | ||
| 161 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 162 | + HCCL_E_PARA); | ||
| 163 | + | ||
| 164 | + return DlHcclFunction::get_instance().dlHcclSetOpParamGraphModeRankSize(opParam, rankSize); | ||
| 165 | +} | ||
| 166 | + | ||
| 167 | +HcclResult HcceSetOpParamGraphModeHCCLBufferSize(OpParamGraphModePtr opParam, const u64 *hcclBufferSize) { | ||
| 168 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 169 | + HCCL_E_PARA); | ||
| 170 | + | ||
| 171 | + return DlHcclFunction::get_instance().dlHcclSetOpParamGraphModeHCCLBufferSize(opParam, hcclBufferSize); | ||
| 172 | +} | ||
| 173 | + | ||
| 174 | +HcclResult HcceSetOpParamGraphModeDataType(OpParamGraphModePtr opParam, HcclDataType dataType) { | ||
| 175 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 176 | + HCCL_E_PARA); | ||
| 177 | + | ||
| 178 | + return DlHcclFunction::get_instance().dlHcclSetOpParamGraphModeDataType(opParam, dataType); | ||
| 179 | +} | ||
| 180 | + | ||
| 181 | +HcclResult HcceSetAivSelectOpParamGraphMode(OpParamGraphModePtr opParam, const char *group, u64 count, void *counts, | ||
| 182 | + HcclDataType dataType, HcclReduceOp op, HcclCMDType opTypeAiv, u32 aivCoreLimit, bool ifAiv) { | ||
| 183 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 184 | + HCCL_E_PARA); | ||
| 185 | + | ||
| 186 | + return DlHcclFunction::get_instance().dlHcclSetAivSelectOpParamGraphMode(opParam, group, count, counts, dataType, op, opTypeAiv, aivCoreLimit, ifAiv); | ||
| 187 | +} | ||
| 188 | + | ||
| 189 | +HcclResult HcceCalcOpResOfflineGraphMode(OpParamGraphModePtr opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum) { | ||
| 190 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 191 | + HCCL_E_PARA); | ||
| 192 | + | ||
| 193 | + return DlHcclFunction::get_instance().dlHcclCalcOpResOfflineGraphMode(opParam, opMemSize, streamNum, taskNum, aivCoreNum); | ||
| 194 | +} | ||
| 195 | + | ||
| 196 | +HcclResult HcceCalcOpResOnlineGraphMode(OpParamGraphModePtr opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum) { | ||
| 197 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 198 | + HCCL_E_PARA); | ||
| 199 | + | ||
| 200 | + return DlHcclFunction::get_instance().dlHcclCalcOpResOnlineGraphMode(opParam, opMemSize, streamNum, taskNum, aivCoreNum); | ||
| 201 | +} | ||
| 202 | + | ||
| 203 | +HcclResult HcceAllGatherGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 204 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 205 | + HCCL_E_PARA); | ||
| 206 | + return DlHcclFunction::get_instance().dlHcclAllGatherGraphMode(sendBuf, recvBuf, sendCount, dataType, group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 207 | +} | ||
| 208 | + | ||
| 209 | +HcclResult HcceBroadcastGraphMode(void *buf, uint64_t count, HcclDataType dataType, uint32_t root, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 210 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 211 | + HCCL_E_PARA); | ||
| 212 | + return DlHcclFunction::get_instance().dlHcclBroadcastGraphMode(buf, count, dataType, root, group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 213 | +} | ||
| 214 | + | ||
| 215 | +HcclResult HcceReduceScatterVGraphMode(void *sendBuf, const void *sendCounts, const void *sendDispls, void *recvBuf, uint64_t recvCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 216 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 217 | + HCCL_E_PARA); | ||
| 218 | + return DlHcclFunction::get_instance().dlHcclReduceScatterVGraphMode(sendBuf, sendCounts, sendDispls, recvBuf, recvCount, dataType, op, group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 219 | +} | ||
| 220 | + | ||
| 221 | +HcclResult HcceAllGatherVGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, const void *recvCounts, const void *recvDispls, HcclDataType dataType, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 222 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 223 | + HCCL_E_PARA); | ||
| 224 | + return DlHcclFunction::get_instance().dlHcclAllGatherVGraphMode(sendBuf, recvBuf, sendCount, recvCounts, recvDispls, dataType, group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 225 | +} | ||
| 226 | + | ||
| 227 | +HcclResult HcceAlltoAllGraphMode(const void *sendBuf, uint64_t sendCount, HcclDataType sendType, const void *recvBuf, uint64_t recvCount, HcclDataType recvType, | ||
| 228 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 229 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 230 | + HCCL_E_PARA); | ||
| 231 | + return DlHcclFunction::get_instance().dlHcclAlltoAllGraphMode(sendBuf, sendCount, sendType, recvBuf, recvCount, recvType, | ||
| 232 | + group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 233 | +} | ||
| 234 | + | ||
| 235 | +HcclResult HcceAlltoAllVGraphMode(const void *sendBuf, const void *sendCounts, const void *sdispls, HcclDataType sendType, | ||
| 236 | + const void *recvBuf, const void *recvCounts, const void *rdispls, HcclDataType recvType, | ||
| 237 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 238 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 239 | + HCCL_E_PARA); | ||
| 240 | + return DlHcclFunction::get_instance().dlHcclAlltoAllVGraphMode(sendBuf, sendCounts, sdispls, sendType, recvBuf, recvCounts, rdispls, recvType, | ||
| 241 | + group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 242 | +} | ||
| 243 | + | ||
| 244 | +HcclResult HcceAlltoAllVCGraphMode(const void *sendBuf, const void *sendCountMatrix, HcclDataType sendType, const void *recvBuf, HcclDataType recvType, | ||
| 245 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 246 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 247 | + HCCL_E_PARA); | ||
| 248 | + return DlHcclFunction::get_instance().dlHcclAlltoAllVCGraphMode(sendBuf, sendCountMatrix, sendType, recvBuf, recvType, | ||
| 249 | + group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 250 | +} | ||
| 251 | + | ||
| 252 | +HcclResult HcceSendGraphMode( | ||
| 253 | + void *sendBuf, uint64_t count, HcclDataType dataType, uint32_t destRank, const char* group, aclrtStream stream, | ||
| 254 | + const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) | ||
| 255 | +{ | ||
| 256 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 257 | + HCCL_E_PARA); | ||
| 258 | + return DlHcclFunction::get_instance().dlHcclSendGraphMode(sendBuf, count, dataType, destRank, group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 259 | +} | ||
| 260 | + | ||
| 261 | +HcclResult HcceRecvGraphMode( | ||
| 262 | + void *recvBuf, uint64_t count, HcclDataType dataType, uint32_t srcRank, const char* group, aclrtStream stream, | ||
| 263 | + const char* tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) | ||
| 264 | +{ | ||
| 265 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 266 | + HCCL_E_PARA); | ||
| 267 | + return DlHcclFunction::get_instance().dlHcclRecvGraphMode(recvBuf, count, dataType, srcRank, group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 268 | +} | ||
| 269 | + | ||
| 270 | +HcclResult HcceAllReduceGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, | ||
| 271 | + HcclReduceOp op, const char *group, void *stream, const char *tag, void **streams, | ||
| 272 | + size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) | ||
| 273 | +{ | ||
| 274 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 275 | + HCCL_E_PARA); | ||
| 276 | + return DlHcclFunction::get_instance().dlHcclAllReduceGraphMode(sendBuf, recvBuf, sendCount, dataType, op, group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 277 | +} | ||
| 278 | + | ||
| 279 | +HcclResult HcceReduceGraphMode(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op, uint32_t root, | ||
| 280 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, | ||
| 281 | + void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 282 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 283 | + HCCL_E_PARA); | ||
| 284 | + return DlHcclFunction::get_instance().dlHcclReduceGraphMode(sendBuf, recvBuf, count, dataType, op, root, group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 285 | +} | ||
| 286 | + | ||
| 287 | +HcclResult HcceReduceScatterGraphMode(void *sendBuf, void *recvBuf, uint64_t recvCount, HcclDataType dataType, | ||
| 288 | + HcclReduceOp op, const char *group, void *stream, const char *tag, void **streams, | ||
| 289 | + size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) | ||
| 290 | +{ | ||
| 291 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 292 | + HCCL_E_PARA); | ||
| 293 | + return DlHcclFunction::get_instance().dlHcclReduceScatterGraphMode(sendBuf, recvBuf, recvCount, dataType, op, | ||
| 294 | + group, stream, tag, streams, streamCount, | ||
| 295 | + scratchMemAddr, scratchMemSize); | ||
| 296 | +} | ||
| 297 | +HcclResult HcceSetAivCoreLimitGraphMode(const char *group, u32 aivCoreLimit) | ||
| 298 | +{ | ||
| 299 | + CHK_PRT_RET(DlHcclFunction::get_instance().init() != HCCL_SUCCESS, HCCL_ERROR("DlHcclFunction::get_instance().init() fail \n"), | ||
| 300 | + HCCL_E_PARA); | ||
| 301 | + return DlHcclFunction::get_instance().dlHcclSetAivCoreLimitGraphMode(group, aivCoreLimit); | ||
| 302 | +} | ||
| @@ -59,6 +59,62 @@ HcclResult HcceReduce(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType | |||
| 59 | 59 | ||
| 60 | HcclResult HcceGetandClearOverFlowTasks(const char *group, hccl::HcclDumpInfo **hcclDumpInfo, s32 *len); | 60 | HcclResult HcceGetandClearOverFlowTasks(const char *group, hccl::HcclDumpInfo **hcclDumpInfo, s32 *len); |
| 61 | 61 | ||
| 62 | +// 图模式相关函数 | ||
| 63 | +// OpParamGraphModePtr 操作函数 | ||
| 64 | +HcclResult HcceIsHcclGraphModeValid(bool &isValid); | ||
| 65 | +HcclResult HcceCreateOpParamGraphMode(OpParamGraphModePtr *opParam); | ||
| 66 | +HcclResult HcceDestroyOpParamGraphMode(OpParamGraphModePtr opParam); | ||
| 67 | +HcclResult HcceSetOpParamGraphModeOpType(OpParamGraphModePtr opParam, const char *opType); | ||
| 68 | +// RAII 工具类,用于管理 OpParamGraphModePtr 资源 | ||
| 69 | +struct OpParamGraphModeDeleter { | ||
| 70 | + void operator()(OpParamGraphModePtr ptr) { | ||
| 71 | + if (ptr != nullptr) { | ||
| 72 | + HcceDestroyOpParamGraphMode(ptr); | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | +}; | ||
| 76 | +// 用于管理 OpParamGraphModePtr 资源的智能指针类型 | ||
| 77 | +using OpParamGraphModeGuard = std::unique_ptr<void, OpParamGraphModeDeleter>; | ||
| 78 | +HcclResult HcceSetAivSelectOpParamGraphMode(OpParamGraphModePtr opParam, const char *group, u64 count, void *counts, | ||
| 79 | + HcclDataType dataType, HcclReduceOp op, HcclCMDType opTypeAiv, u32 aivCoreLimit, bool ifAiv); | ||
| 80 | + | ||
| 81 | +// 资源计算函数 | ||
| 82 | +HcclResult HcceCalcOpResOfflineGraphMode(OpParamGraphModePtr opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum); | ||
| 83 | +HcclResult HcceCalcOpResOnlineGraphMode(OpParamGraphModePtr opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum); | ||
| 84 | +HcclResult HcceSetOpParamGraphModeDataCount(OpParamGraphModePtr opParam, const u64 *dataCount); | ||
| 85 | +HcclResult HcceSetOpParamGraphModeDataType(OpParamGraphModePtr opParam, HcclDataType dataType); | ||
| 86 | +HcclResult HcceSetOpParamGraphModeRankSize(OpParamGraphModePtr opParam, const u32 *rankSize); | ||
| 87 | +HcclResult HcceSetOpParamGraphModeHCCLBufferSize(OpParamGraphModePtr opParam, const u64 *hcclBufferSize); | ||
| 88 | + | ||
| 89 | +// 图模式算子函数 | ||
| 90 | +HcclResult HcceAllGatherGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 91 | +HcclResult HcceBroadcastGraphMode(void *buf, uint64_t count, HcclDataType dataType, uint32_t root, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 92 | +HcclResult HcceAllGatherVGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, const void *recvCounts, const void *recvDispls, HcclDataType dataType, const char* group, aclrtStream stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSiz); | ||
| 93 | +HcclResult HcceAlltoAllGraphMode(const void *sendBuf, uint64_t sendCount, HcclDataType sendType, const void *recvBuf, uint64_t recvCount, HcclDataType recvType, | ||
| 94 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 95 | +HcclResult HcceAlltoAllVGraphMode(const void *sendBuf, const void *sendCounts, const void *sdispls, HcclDataType sendType, | ||
| 96 | + const void *recvBuf, const void *recvCounts, const void *rdispls, HcclDataType recvType, | ||
| 97 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 98 | +HcclResult HcceAlltoAllVCGraphMode(const void *sendBuf, const void *sendCountMatrix, HcclDataType sendType, const void *recvBuf, HcclDataType recvType, | ||
| 99 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 100 | + | ||
| 101 | +HcclResult HcceReduceScatterVGraphMode(void *sendBuf, const void *sendCounts, const void *sendDispls, void *recvBuf, uint64_t recvCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 102 | +HcclResult HcceSendGraphMode( | ||
| 103 | + void *sendBuf, uint64_t count, HcclDataType dataType, uint32_t destRank, const char* group, aclrtStream stream, | ||
| 104 | + const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 105 | +HcclResult HcceRecvGraphMode( | ||
| 106 | + void *recvBuf, uint64_t count, HcclDataType dataType, uint32_t srcRank, const char* group, aclrtStream stream, | ||
| 107 | + const char* tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 108 | +HcclResult HcceAllReduceGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclReduceOp op, | ||
| 109 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, | ||
| 110 | + void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 111 | +HcclResult HcceReduceGraphMode(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op, uint32_t root, | ||
| 112 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, | ||
| 113 | + void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 114 | +HcclResult HcceReduceScatterGraphMode(void *sendBuf, void *recvBuf, uint64_t recvCount, HcclDataType dataType, | ||
| 115 | + HcclReduceOp op, const char *group, void *stream, const char *tag, void **streams, | ||
| 116 | + size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 117 | +HcclResult HcceSetAivCoreLimitGraphMode(const char *group, u32 aivCoreLimit); | ||
| 62 | 118 | ||
| 63 | } | 119 | } |
| 64 | 120 | ||
| @@ -102,10 +102,128 @@ HcclResult DlHcclFunction::init() { | |||
| 102 | dlHcomGetandClearOverFlowTasksFunc = (HcclResult (*)(const char *group, hccl::HcclDumpInfo **hcclDumpInfoPtr, | 102 | dlHcomGetandClearOverFlowTasksFunc = (HcclResult (*)(const char *group, hccl::HcclDumpInfo **hcclDumpInfoPtr, |
| 103 | s32 *len))dlsym(dl_hcomm_handle, "HcomGetandClearOverFlowTasks"); | 103 | s32 *len))dlsym(dl_hcomm_handle, "HcomGetandClearOverFlowTasks"); |
| 104 | CHK_PTR_NULL(dlHcomGetandClearOverFlowTasksFunc); | 104 | CHK_PTR_NULL(dlHcomGetandClearOverFlowTasksFunc); |
| 105 | - | 105 | + |
| 106 | + auto ret = initHcclGraphModeFunctions(); | ||
| 107 | + if(ret != HCCL_SUCCESS) { | ||
| 108 | + isHcclGraphModeFunctionsLoaded_ = false; | ||
| 109 | + HCCL_WARNING("[DlHcclFunction]load hccl graph mode functions fail\n"); | ||
| 110 | + } else { | ||
| 111 | + isHcclGraphModeFunctionsLoaded_ = true; | ||
| 112 | + } | ||
| 106 | return HCCL_SUCCESS; | 113 | return HCCL_SUCCESS; |
| 107 | } | 114 | } |
| 108 | 115 | ||
| 116 | +HcclResult DlHcclFunction::initHcclGraphModeFunctions() { | ||
| 117 | + // 图模式相关函数 | ||
| 118 | + dlHcclCreateOpParamGraphModeFunc = (HcclResult (*)(OpParamGraphModePtr *opParam))dlsym(dl_hccl_handle, "HcclCreateOpParamGraphMode"); | ||
| 119 | + CHK_PTR_NULL(dlHcclCreateOpParamGraphModeFunc); | ||
| 120 | + | ||
| 121 | + dlHcclDestroyOpParamGraphModeFunc = (HcclResult (*)(OpParamGraphModePtr opParam))dlsym(dl_hccl_handle, "HcclDestroyOpParamGraphMode"); | ||
| 122 | + CHK_PTR_NULL(dlHcclDestroyOpParamGraphModeFunc); | ||
| 123 | + | ||
| 124 | + dlHcclSetOpParamGraphModeOpTypeFunc = (HcclResult (*)(OpParamGraphModePtr opParam, const char *opType))dlsym(dl_hccl_handle, "HcclSetOpParamGraphModeOpType"); | ||
| 125 | + CHK_PTR_NULL(dlHcclSetOpParamGraphModeOpTypeFunc); | ||
| 126 | + | ||
| 127 | + dlHcclSetOpParamGraphModeDataCountFunc = (HcclResult (*)(OpParamGraphModePtr opParam, const u64 *count))dlsym(dl_hccl_handle, "HcclSetOpParamGraphModeDataCount"); | ||
| 128 | + CHK_PTR_NULL(dlHcclSetOpParamGraphModeDataCountFunc); | ||
| 129 | + | ||
| 130 | + dlHcclSetOpParamGraphModeRankSizeFunc = (HcclResult (*)(OpParamGraphModePtr opParam, const u32 *rankSize))dlsym(dl_hccl_handle, "HcclSetOpParamGraphModeRankSize"); | ||
| 131 | + CHK_PTR_NULL(dlHcclSetOpParamGraphModeRankSizeFunc); | ||
| 132 | + | ||
| 133 | + dlHcclSetOpParamGraphModeHCCLBufferSizeFunc = (HcclResult (*)(OpParamGraphModePtr opParam, const u64 *cclBufferSize))dlsym(dl_hccl_handle, "HcclSetOpParamGraphModeHCCLBufferSize"); | ||
| 134 | + CHK_PTR_NULL(dlHcclSetOpParamGraphModeHCCLBufferSizeFunc); | ||
| 135 | + | ||
| 136 | + dlHcclSetOpParamGraphModeDataTypeFunc = (HcclResult (*)(OpParamGraphModePtr opParam, const HcclDataType dataType))dlsym(dl_hccl_handle, "HcclSetOpParamGraphModeDataType"); | ||
| 137 | + CHK_PTR_NULL(dlHcclSetOpParamGraphModeDataTypeFunc); | ||
| 138 | + | ||
| 139 | + dlHcclSetAivSelectOpParamGraphModeFunc = (HcclResult (*)(OpParamGraphModePtr opParam, const char *group, u64 count, | ||
| 140 | + void *counts, HcclDataType dataType, HcclReduceOp reduction, | ||
| 141 | + HcclCMDType opType, u32 aivCoreLimit, bool ifAiv))dlsym(dl_hccl_handle, "HcclSetAivSelectOpParamGraphMode"); | ||
| 142 | + CHK_PTR_NULL(dlHcclSetAivSelectOpParamGraphModeFunc); | ||
| 143 | + | ||
| 144 | + dlHcclCalcOpResOfflineGraphModeFunc = (HcclResult (*)(OpParamGraphModePtr opParam, u64 *opMemSize, | ||
| 145 | + u32 *streamNum, u32 *taskNum, u32 *aivCoreNum))dlsym(dl_hccl_handle, "HcclCalcOpResOfflineGraphMode"); | ||
| 146 | + CHK_PTR_NULL(dlHcclCalcOpResOfflineGraphModeFunc); | ||
| 147 | + | ||
| 148 | + dlHcclCalcOpResOnlineGraphModeFunc = (HcclResult (*)(OpParamGraphModePtr opParam, u64 *opMemSize, | ||
| 149 | + u32 *streamNum, u32 *taskNum, u32 *aivCoreNum))dlsym(dl_hccl_handle, "HcclCalcOpResOnlineGraphMode"); | ||
| 150 | + CHK_PTR_NULL(dlHcclCalcOpResOnlineGraphModeFunc); | ||
| 151 | + | ||
| 152 | + dlHcclAllGatherGraphModeFunc = (HcclResult (*)(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, | ||
| 153 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, | ||
| 154 | + void *scratchMemAddr, uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclAllGatherGraphMode"); | ||
| 155 | + CHK_PTR_NULL(dlHcclAllGatherGraphModeFunc); | ||
| 156 | + | ||
| 157 | + dlHcclBroadcastGraphModeFunc = (HcclResult (*)(void *sendBuf, uint64_t count, HcclDataType dataType, uint32_t root, | ||
| 158 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, | ||
| 159 | + void *scratchMemAddr, uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclBroadcastGraphMode"); | ||
| 160 | + CHK_PTR_NULL(dlHcclBroadcastGraphModeFunc); | ||
| 161 | + | ||
| 162 | + dlHcclReduceScatterVGraphModeFunc = (HcclResult (*)(void *sendBuf, const void *sendCounts, const void *sendDispls, | ||
| 163 | + void *recvBuf, uint64_t recvCount, HcclDataType dataType, HcclReduceOp reduceOp, | ||
| 164 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, | ||
| 165 | + void *scratchMemAddr, uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclReduceScatterVGraphMode"); | ||
| 166 | + CHK_PTR_NULL(dlHcclReduceScatterVGraphModeFunc); | ||
| 167 | + | ||
| 168 | + dlHcclAllGatherVGraphModeFunc = (HcclResult (*)(void *sendBuf, void *recvBuf, uint64_t sendCount, | ||
| 169 | + const void *recvCounts, const void *recvDispls, HcclDataType dataType, | ||
| 170 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, | ||
| 171 | + void *scratchMemAddr, uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclAllGatherVGraphMode"); | ||
| 172 | + CHK_PTR_NULL(dlHcclAllGatherVGraphModeFunc); | ||
| 173 | + | ||
| 174 | + dlHcclAlltoAllGraphModeFunc = (HcclResult (*)(const void *sendBuf, uint64_t sendCount, HcclDataType sendType, | ||
| 175 | + const void *recvBuf, uint64_t recvCount, HcclDataType recvType, | ||
| 176 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, | ||
| 177 | + void *scratchMemAddr, uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclAlltoAllGraphMode"); | ||
| 178 | + CHK_PTR_NULL(dlHcclAlltoAllGraphModeFunc); | ||
| 179 | + | ||
| 180 | + dlHcclAlltoAllVGraphModeFunc = (HcclResult (*)(const void *sendBuf, const void *sendCounts, const void *sendDispls, | ||
| 181 | + HcclDataType sendType, const void *recvBuf, const void *recvCounts, const void *recvDispls, | ||
| 182 | + HcclDataType recvType, const char *group, void *stream, const char *tag, void **streams, | ||
| 183 | + size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclAlltoAllVGraphMode"); | ||
| 184 | + CHK_PTR_NULL(dlHcclAlltoAllVGraphModeFunc); | ||
| 185 | + | ||
| 186 | + dlHcclAlltoAllVCGraphModeFunc = (HcclResult (*)(const void *sendBuf, const void *sendCountMatrix, HcclDataType sendType, | ||
| 187 | + const void *recvBuf, HcclDataType recvType, const char *group, void *stream, | ||
| 188 | + const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, | ||
| 189 | + uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclAlltoAllVCGraphMode"); | ||
| 190 | + CHK_PTR_NULL(dlHcclAlltoAllVCGraphModeFunc); | ||
| 191 | + | ||
| 192 | + dlHcclSendGraphModeFunc = (HcclResult (*)(void *sendBuf, uint64_t count, HcclDataType dataType, uint32_t destRank, | ||
| 193 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, | ||
| 194 | + void *scratchMemAddr, uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclSendGraphMode"); | ||
| 195 | + CHK_PTR_NULL(dlHcclSendGraphModeFunc); | ||
| 196 | + | ||
| 197 | + dlHcclRecvGraphModeFunc = (HcclResult (*)(void *recvBuf, uint64_t count, HcclDataType dataType, uint32_t srcRank, | ||
| 198 | + const char *group, void *stream, const char *tag, void **streams, size_t streamCount, | ||
| 199 | + void *scratchMemAddr, uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclRecvGraphMode"); | ||
| 200 | + CHK_PTR_NULL(dlHcclRecvGraphModeFunc); | ||
| 201 | + | ||
| 202 | + dlHcclAllReduceGraphModeFunc = (HcclResult (*)(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, | ||
| 203 | + HcclReduceOp reduceOp, const char *group, void *stream, const char *tag, | ||
| 204 | + void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclAllReduceGraphMode"); | ||
| 205 | + CHK_PTR_NULL(dlHcclAllReduceGraphModeFunc); | ||
| 206 | + | ||
| 207 | + dlHcclReduceGraphModeFunc = (HcclResult (*)(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, | ||
| 208 | + HcclReduceOp reduceOp, uint32_t root, const char *group, void *stream, | ||
| 209 | + const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, | ||
| 210 | + uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclReduceGraphMode"); | ||
| 211 | + CHK_PTR_NULL(dlHcclReduceGraphModeFunc); | ||
| 212 | + | ||
| 213 | + dlHcclReduceScatterGraphModeFunc = (HcclResult (*)(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, | ||
| 214 | + HcclReduceOp reduceOp, const char *group, void *stream, const char *tag, | ||
| 215 | + void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize))dlsym(dl_hccl_handle, "HcclReduceScatterGraphMode"); | ||
| 216 | + CHK_PTR_NULL(dlHcclReduceScatterGraphModeFunc); | ||
| 217 | + | ||
| 218 | + dlHcclSetAivCoreLimitGraphModeFunc = (HcclResult (*)(const char *group, u32 aivCoreLimit))dlsym(dl_hccl_handle, "HcclSetAivCoreLimitGraphMode"); | ||
| 219 | + CHK_PTR_NULL(dlHcclSetAivCoreLimitGraphModeFunc); | ||
| 220 | + return HCCL_SUCCESS; | ||
| 221 | +} | ||
| 222 | + | ||
| 223 | +bool DlHcclFunction::isLoadHcclGraphModeFunctions() { | ||
| 224 | + return isHcclGraphModeFunctionsLoaded_; | ||
| 225 | +}; | ||
| 226 | + | ||
| 109 | void DlHcclFunction::deinit() { | 227 | void DlHcclFunction::deinit() { |
| 110 | if (dl_hccl_handle != nullptr) { | 228 | if (dl_hccl_handle != nullptr) { |
| 111 | dlclose(dl_hccl_handle); | 229 | dlclose(dl_hccl_handle); |
| @@ -188,4 +306,107 @@ HcclResult DlHcclFunction::dlHcclReduce(void *sendBuf, void *recvBuf, uint64_t c | |||
| 188 | HcclResult DlHcclFunction::dlHcomGetandClearOverFlowTasks(const char *group, hccl::HcclDumpInfo **hcclDumpInfoPtr, | 306 | HcclResult DlHcclFunction::dlHcomGetandClearOverFlowTasks(const char *group, hccl::HcclDumpInfo **hcclDumpInfoPtr, |
| 189 | s32 *len) { | 307 | s32 *len) { |
| 190 | return dlHcomGetandClearOverFlowTasksFunc(group, hcclDumpInfoPtr, len); | 308 | return dlHcomGetandClearOverFlowTasksFunc(group, hcclDumpInfoPtr, len); |
| 191 | -} | 309 | +} |
| 310 | + | ||
| 311 | +// 图模式相关函数实现 | ||
| 312 | +HcclResult DlHcclFunction::dlHcclCreateOpParamGraphMode(OpParamGraphModePtr *opParam) { | ||
| 313 | + return dlHcclCreateOpParamGraphModeFunc(opParam); | ||
| 314 | +} | ||
| 315 | + | ||
| 316 | +HcclResult DlHcclFunction::dlHcclDestroyOpParamGraphMode(OpParamGraphModePtr opParam) { | ||
| 317 | + return dlHcclDestroyOpParamGraphModeFunc(opParam); | ||
| 318 | +} | ||
| 319 | + | ||
| 320 | +HcclResult DlHcclFunction::dlHcclSetOpParamGraphModeOpType(OpParamGraphModePtr opParam, const char *opType) { | ||
| 321 | + return dlHcclSetOpParamGraphModeOpTypeFunc(opParam, opType); | ||
| 322 | +} | ||
| 323 | + | ||
| 324 | +HcclResult DlHcclFunction::dlHcclSetOpParamGraphModeDataCount(OpParamGraphModePtr opParam, const u64 *dataCount) { | ||
| 325 | + return dlHcclSetOpParamGraphModeDataCountFunc(opParam, dataCount); | ||
| 326 | +} | ||
| 327 | + | ||
| 328 | +HcclResult DlHcclFunction::dlHcclSetOpParamGraphModeRankSize(OpParamGraphModePtr opParam, const u32 *rankSize) { | ||
| 329 | + return dlHcclSetOpParamGraphModeRankSizeFunc(opParam, rankSize); | ||
| 330 | +} | ||
| 331 | + | ||
| 332 | +HcclResult DlHcclFunction::dlHcclSetOpParamGraphModeHCCLBufferSize(OpParamGraphModePtr opParam, const u64 *hcclBufferSize) { | ||
| 333 | + return dlHcclSetOpParamGraphModeHCCLBufferSizeFunc(opParam, hcclBufferSize); | ||
| 334 | +} | ||
| 335 | + | ||
| 336 | +HcclResult DlHcclFunction::dlHcclSetOpParamGraphModeDataType(OpParamGraphModePtr opParam, const HcclDataType dataType) { | ||
| 337 | + return dlHcclSetOpParamGraphModeDataTypeFunc(opParam, dataType); | ||
| 338 | +} | ||
| 339 | + | ||
| 340 | +HcclResult DlHcclFunction::dlHcclSetAivSelectOpParamGraphMode(OpParamGraphModePtr opParam, const char *group, u64 count, void *counts, HcclDataType dataType, HcclReduceOp op, HcclCMDType opTypeAiv, u32 aivCoreLimit, bool ifAiv) { | ||
| 341 | + return dlHcclSetAivSelectOpParamGraphModeFunc(opParam, group, count, counts, dataType, op, opTypeAiv, aivCoreLimit, ifAiv); | ||
| 342 | +} | ||
| 343 | + | ||
| 344 | +HcclResult DlHcclFunction::dlHcclCalcOpResOfflineGraphMode(OpParamGraphModePtr opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum) { | ||
| 345 | + return dlHcclCalcOpResOfflineGraphModeFunc(opParam, opMemSize, streamNum, taskNum, aivCoreNum); | ||
| 346 | +} | ||
| 347 | + | ||
| 348 | +HcclResult DlHcclFunction::dlHcclCalcOpResOnlineGraphMode(OpParamGraphModePtr opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum) { | ||
| 349 | + return dlHcclCalcOpResOnlineGraphModeFunc(opParam, opMemSize, streamNum, taskNum, aivCoreNum); | ||
| 350 | +} | ||
| 351 | + | ||
| 352 | +HcclResult DlHcclFunction::dlHcclAllGatherGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 353 | + return dlHcclAllGatherGraphModeFunc(sendBuf, recvBuf, sendCount, dataType, group, stream, optag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 354 | +} | ||
| 355 | + | ||
| 356 | +HcclResult DlHcclFunction::dlHcclBroadcastGraphMode(void *buf, uint64_t count, HcclDataType dataType, uint32_t root, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 357 | + return dlHcclBroadcastGraphModeFunc(buf, count, dataType, root, group, stream, optag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 358 | +} | ||
| 359 | + | ||
| 360 | +HcclResult DlHcclFunction::dlHcclReduceScatterVGraphMode(void *sendBuf, const void *sendCounts, const void *sendDispls, void *recvBuf, | ||
| 361 | + uint64_t recvCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 362 | + return dlHcclReduceScatterVGraphModeFunc(sendBuf, sendCounts, sendDispls, recvBuf, recvCount, dataType, op, group, stream, optag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 363 | +} | ||
| 364 | + | ||
| 365 | +HcclResult DlHcclFunction::dlHcclAllGatherVGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, const void *recvCounts, const void *recvDispls, HcclDataType dataType, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 366 | + return dlHcclAllGatherVGraphModeFunc(sendBuf, recvBuf, sendCount, recvCounts, recvDispls, dataType, group, stream, optag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 367 | +} | ||
| 368 | + | ||
| 369 | +HcclResult DlHcclFunction::dlHcclAlltoAllGraphMode(const void *sendBuf, uint64_t sendCount, HcclDataType sendType, const void *recvBuf, uint64_t recvCount, HcclDataType recvType, | ||
| 370 | + const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 371 | + return dlHcclAlltoAllGraphModeFunc(sendBuf, sendCount, sendType, recvBuf, recvCount, recvType, | ||
| 372 | + group, stream, optag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 373 | +} | ||
| 374 | + | ||
| 375 | +HcclResult DlHcclFunction::dlHcclAlltoAllVGraphMode(const void *sendBuf, const void *sendCounts, const void *sdispls, HcclDataType sendType, | ||
| 376 | + const void *recvBuf, const void *recvCounts, const void *rdispls, HcclDataType recvType, | ||
| 377 | + const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 378 | + return dlHcclAlltoAllVGraphModeFunc(sendBuf, sendCounts, sdispls, sendType, recvBuf, recvCounts, rdispls, recvType, | ||
| 379 | + group, stream, optag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 380 | +} | ||
| 381 | + | ||
| 382 | +HcclResult DlHcclFunction::dlHcclAlltoAllVCGraphMode(const void *sendBuf, const void *sendCountMatrix, HcclDataType sendType, const void *recvBuf, HcclDataType recvType, | ||
| 383 | + const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 384 | + return dlHcclAlltoAllVCGraphModeFunc(sendBuf, sendCountMatrix, sendType, recvBuf, recvType, | ||
| 385 | + group, stream, optag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 386 | +} | ||
| 387 | + | ||
| 388 | +HcclResult DlHcclFunction::dlHcclSendGraphMode(void *sendBuf, uint64_t count, HcclDataType dataType, uint32_t destRank, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 389 | + return dlHcclSendGraphModeFunc(sendBuf, count, dataType, destRank, group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 390 | +} | ||
| 391 | + | ||
| 392 | +HcclResult DlHcclFunction::dlHcclRecvGraphMode(void *recvBuf, uint64_t count, HcclDataType dataType, uint32_t srcRank, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 393 | + return dlHcclRecvGraphModeFunc(recvBuf, count, dataType, srcRank, group, stream, tag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 394 | +} | ||
| 395 | + | ||
| 396 | +HcclResult DlHcclFunction::dlHcclAllReduceGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 397 | + return dlHcclAllReduceGraphModeFunc(sendBuf, recvBuf, sendCount, dataType, op, group, stream, optag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 398 | +} | ||
| 399 | + | ||
| 400 | +HcclResult DlHcclFunction::dlHcclReduceGraphMode(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op, uint32_t root, | ||
| 401 | + const char *group, void *stream, const char *optag, void **streams, size_t streamCount, | ||
| 402 | + void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 403 | + return dlHcclReduceGraphModeFunc(sendBuf, recvBuf, count, dataType, op, root, group, stream, optag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 404 | +} | ||
| 405 | + | ||
| 406 | +HcclResult DlHcclFunction::dlHcclReduceScatterGraphMode(void *sendBuf, void *recvBuf, uint64_t recvCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize) { | ||
| 407 | + return dlHcclReduceScatterGraphModeFunc(sendBuf, recvBuf, recvCount, dataType, op, group, stream, optag, streams, streamCount, scratchMemAddr, scratchMemSize); | ||
| 408 | +} | ||
| 409 | + | ||
| 410 | +HcclResult DlHcclFunction::dlHcclSetAivCoreLimitGraphMode(const char *group, u32 aivCoreLimit) { | ||
| 411 | + return dlHcclSetAivCoreLimitGraphModeFunc(group, aivCoreLimit); | ||
| 412 | +} | ||
| @@ -14,18 +14,22 @@ | |||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | + | ||
| 17 | 18 | ||
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | 21 | ||
| 21 | using aclrtStream = void *; | 22 | using aclrtStream = void *; |
| 22 | 23 | ||
| 24 | +// 因为ge中不感知OpParamGraphMode,所以使用void* | ||
| 25 | +using OpParamGraphModePtr = void *; | ||
| 26 | + | ||
| 23 | class DlHcclFunction { | 27 | class DlHcclFunction { |
| 24 | public: | 28 | public: |
| 25 | static DlHcclFunction &get_instance(); | 29 | static DlHcclFunction &get_instance(); |
| 26 | HcclResult init(); | 30 | HcclResult init(); |
| 27 | void deinit(); | 31 | void deinit(); |
| 28 | - | 32 | + bool isLoadHcclGraphModeFunctions(); |
| 29 | HcclResult dlHcclAllReduce(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op, | 33 | HcclResult dlHcclAllReduce(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op, |
| 30 | HcclComm comm, aclrtStream stream); | 34 | HcclComm comm, aclrtStream stream); |
| 31 | 35 | ||
| @@ -66,6 +70,38 @@ class DlHcclFunction { | |||
| 66 | 70 | ||
| 67 | HcclResult dlHcomGetandClearOverFlowTasks(const char *group, hccl::HcclDumpInfo **hcclDumpInfoPtr, s32 *len); | 71 | HcclResult dlHcomGetandClearOverFlowTasks(const char *group, hccl::HcclDumpInfo **hcclDumpInfoPtr, s32 *len); |
| 68 | 72 | ||
| 73 | + // 图模式相关函数 | ||
| 74 | + HcclResult dlHcclCreateOpParamGraphMode(OpParamGraphModePtr *opParam); | ||
| 75 | + HcclResult dlHcclDestroyOpParamGraphMode(OpParamGraphModePtr opParam); | ||
| 76 | + HcclResult dlHcclSetOpParamGraphModeOpType(OpParamGraphModePtr opParam, const char *opType); | ||
| 77 | + HcclResult dlHcclSetOpParamGraphModeDataCount(OpParamGraphModePtr opParam, const u64 *dataCount); | ||
| 78 | + HcclResult dlHcclSetOpParamGraphModeDataType(OpParamGraphModePtr opParam, const HcclDataType dataType); | ||
| 79 | + HcclResult dlHcclSetOpParamGraphModeRankSize(OpParamGraphModePtr opParam, const u32 *rankSize); | ||
| 80 | + HcclResult dlHcclSetOpParamGraphModeHCCLBufferSize(OpParamGraphModePtr opParam, const u64 *hcclBufferSize); | ||
| 81 | + HcclResult dlHcclSetAivSelectOpParamGraphMode(OpParamGraphModePtr opParam, const char *group, u64 count, void *counts, HcclDataType dataType, HcclReduceOp op, HcclCMDType opTypeAiv, u32 aivCoreLimit, bool ifAiv); | ||
| 82 | + HcclResult dlHcclCalcOpResOfflineGraphMode(OpParamGraphModePtr opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum); | ||
| 83 | + HcclResult dlHcclCalcOpResOnlineGraphMode(OpParamGraphModePtr opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum); | ||
| 84 | + HcclResult dlHcclAllGatherGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 85 | + HcclResult dlHcclBroadcastGraphMode(void *buf, uint64_t count, HcclDataType dataType, uint32_t root, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 86 | + HcclResult dlHcclReduceScatterVGraphMode(void *sendBuf, const void *sendCounts, const void *sendDispls, void *recvBuf, | ||
| 87 | + uint64_t recvCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 88 | + HcclResult dlHcclAllGatherVGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, const void *recvCounts, const void *recvDispls, HcclDataType dataType, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 89 | + HcclResult dlHcclAlltoAllGraphMode(const void *sendBuf, uint64_t sendCount, HcclDataType sendType, const void *recvBuf, uint64_t recvCount, HcclDataType recvType, | ||
| 90 | + const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 91 | + HcclResult dlHcclAlltoAllVGraphMode(const void *sendBuf, const void *sendCounts, const void *sdispls, HcclDataType sendType, | ||
| 92 | + const void *recvBuf, const void *recvCounts, const void *rdispls, HcclDataType recvType, | ||
| 93 | + const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 94 | + HcclResult dlHcclAlltoAllVCGraphMode(const void *sendBuf, const void *sendCountMatrix, HcclDataType sendType, const void *recvBuf, HcclDataType recvType, | ||
| 95 | + const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 96 | + HcclResult dlHcclSendGraphMode(void *sendBuf, uint64_t count, HcclDataType dataType, uint32_t destRank, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 97 | + HcclResult dlHcclRecvGraphMode(void *recvBuf, uint64_t count, HcclDataType dataType, uint32_t srcRank, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 98 | + HcclResult dlHcclAllReduceGraphMode(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 99 | + HcclResult dlHcclReduceGraphMode(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op, uint32_t root, | ||
| 100 | + const char *group, void *stream, const char *optag, void **streams, size_t streamCount, | ||
| 101 | + void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 102 | + HcclResult dlHcclReduceScatterGraphMode(void *sendBuf, void *recvBuf, uint64_t recvCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize); | ||
| 103 | + HcclResult dlHcclSetAivCoreLimitGraphMode(const char *group, u32 aivCoreLimit); | ||
| 104 | + | ||
| 69 | private: | 105 | private: |
| 70 | DlHcclFunction(); | 106 | DlHcclFunction(); |
| 71 | ~DlHcclFunction(); | 107 | ~DlHcclFunction(); |
| @@ -75,7 +111,8 @@ class DlHcclFunction { | |||
| 75 | void *dl_hccl_handle; | 111 | void *dl_hccl_handle; |
| 76 | void *dl_hcomm_handle; | 112 | void *dl_hcomm_handle; |
| 77 | std::mutex handleMutex_; | 113 | std::mutex handleMutex_; |
| 78 | - | 114 | + bool isHcclGraphModeFunctionsLoaded_ = false; |
| 115 | + HcclResult initHcclGraphModeFunctions(); | ||
| 79 | std::function<HcclResult(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, | 116 | std::function<HcclResult(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, |
| 80 | aclrtStream stream)> | 117 | aclrtStream stream)> |
| 81 | dlHcclAllGatherFunc; | 118 | dlHcclAllGatherFunc; |
| @@ -128,6 +165,55 @@ class DlHcclFunction { | |||
| 128 | 165 | ||
| 129 | std::function<HcclResult(const char *group, hccl::HcclDumpInfo **hcclDumpInfoPtr, s32 *len)> | 166 | std::function<HcclResult(const char *group, hccl::HcclDumpInfo **hcclDumpInfoPtr, s32 *len)> |
| 130 | dlHcomGetandClearOverFlowTasksFunc; | 167 | dlHcomGetandClearOverFlowTasksFunc; |
| 168 | + | ||
| 169 | + // 图模式相关函数指针 | ||
| 170 | + std::function<HcclResult(OpParamGraphModePtr *opParam)> | ||
| 171 | + dlHcclCreateOpParamGraphModeFunc; | ||
| 172 | + std::function<HcclResult(OpParamGraphModePtr opParam)> | ||
| 173 | + dlHcclDestroyOpParamGraphModeFunc; | ||
| 174 | + std::function<HcclResult(OpParamGraphModePtr opParam, const char *opType)> | ||
| 175 | + dlHcclSetOpParamGraphModeOpTypeFunc; | ||
| 176 | + std::function<HcclResult(OpParamGraphModePtr, const char *, u64, void *, HcclDataType, HcclReduceOp, HcclCMDType, u32, bool)> | ||
| 177 | + dlHcclSetAivSelectOpParamGraphModeFunc; | ||
| 178 | + std::function<HcclResult(OpParamGraphModePtr, const u64 *)> | ||
| 179 | + dlHcclSetOpParamGraphModeDataCountFunc; | ||
| 180 | + std::function<HcclResult(OpParamGraphModePtr, const u32 *)> | ||
| 181 | + dlHcclSetOpParamGraphModeRankSizeFunc; | ||
| 182 | + std::function<HcclResult(OpParamGraphModePtr, const u64 *)> | ||
| 183 | + dlHcclSetOpParamGraphModeHCCLBufferSizeFunc; | ||
| 184 | + std::function<HcclResult(OpParamGraphModePtr, const HcclDataType)> | ||
| 185 | + dlHcclSetOpParamGraphModeDataTypeFunc; | ||
| 186 | + std::function<HcclResult(OpParamGraphModePtr, u64 *, u32 *, u32 *, u32 *)> | ||
| 187 | + dlHcclCalcOpResOfflineGraphModeFunc; | ||
| 188 | + std::function<HcclResult(OpParamGraphModePtr opParam, u64 *opMemSize, u32 *streamNum, u32 *taskNum, u32 *aivCoreNum)> | ||
| 189 | + dlHcclCalcOpResOnlineGraphModeFunc; | ||
| 190 | + std::function<HcclResult(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 191 | + dlHcclAllGatherGraphModeFunc; | ||
| 192 | + std::function<HcclResult(void *buf, uint64_t count, HcclDataType dataType, uint32_t root, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 193 | + dlHcclBroadcastGraphModeFunc; | ||
| 194 | + std::function<HcclResult(void *sendBuf, const void *sendCounts, const void *sendDispls, void *recvBuf, uint64_t recvCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 195 | + dlHcclReduceScatterVGraphModeFunc; | ||
| 196 | + std::function<HcclResult(void *sendBuf, void *recvBuf, uint64_t sendCount, const void *recvCounts, const void *recvDispls, HcclDataType dataType, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 197 | + dlHcclAllGatherVGraphModeFunc; | ||
| 198 | + std::function<HcclResult(const void *sendBuf, uint64_t sendCount, HcclDataType sendType, const void *recvBuf, uint64_t recvCount, HcclDataType recvType, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 199 | + dlHcclAlltoAllGraphModeFunc; | ||
| 200 | + std::function<HcclResult(const void *sendBuf, const void *sendCounts, const void *sdispls, HcclDataType sendType, const void *recvBuf, const void *recvCounts, const void *rdispls, HcclDataType recvType, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 201 | + dlHcclAlltoAllVGraphModeFunc; | ||
| 202 | + std::function<HcclResult(const void *sendBuf, const void *sendCountMatrix, HcclDataType sendType, const void *recvBuf, HcclDataType recvType, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 203 | + dlHcclAlltoAllVCGraphModeFunc; | ||
| 204 | + std::function<HcclResult(void *sendBuf, uint64_t count, HcclDataType dataType, uint32_t destRank, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 205 | + dlHcclSendGraphModeFunc; | ||
| 206 | + std::function<HcclResult(void *recvBuf, uint64_t count, HcclDataType dataType, uint32_t srcRank, const char *group, void *stream, const char *tag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 207 | + dlHcclRecvGraphModeFunc; | ||
| 208 | + std::function<HcclResult(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 209 | + dlHcclAllReduceGraphModeFunc; | ||
| 210 | + std::function<HcclResult(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op, uint32_t root, const char * group, void *stream, const char *opTag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 211 | + dlHcclReduceGraphModeFunc; | ||
| 212 | + std::function<HcclResult(void *sendBuf, void *recvBuf, uint64_t recvCount, HcclDataType dataType, HcclReduceOp op, const char *group, void *stream, const char *optag, void **streams, size_t streamCount, void *scratchMemAddr, uint64_t scratchMemSize)> | ||
| 213 | + dlHcclReduceScatterGraphModeFunc; | ||
| 214 | + std::function<HcclResult(const char *, u32)> | ||
| 215 | + dlHcclSetAivCoreLimitGraphModeFunc; | ||
| 216 | + | ||
| 131 | }; | 217 | }; |
| 132 | 218 | ||
| 133 | 219 | ||
| @@ -19,7 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | - | 22 | +#include "adapter_dlhcclfunc.h" |
| 23 | namespace hccl { | 23 | namespace hccl { |
| 24 | 24 | ||
| 25 | HcclResult HcomInitialize() { | 25 | HcclResult HcomInitialize() { |
| @@ -373,4 +373,31 @@ HcclResult SalParseInformation(nlohmann::json &parseInformation, const std::stri | |||
| 373 | } | 373 | } |
| 374 | return HCCL_SUCCESS; | 374 | return HCCL_SUCCESS; |
| 375 | } | 375 | } |
| 376 | + | ||
| 377 | +HcclResult IsUsingOpenSource(bool &openSource) { | ||
| 378 | + // 如果开源模式HCCL相关函数未定义,走原流程 | ||
| 379 | + bool dllFuncValid = false; | ||
| 380 | + CHK_RET(HcceIsHcclGraphModeValid(dllFuncValid)); | ||
| 381 | + if (!dllFuncValid) { | ||
| 382 | + openSource = false; | ||
| 383 | + HCCL_INFO("[HcomBaseFuns] IsUsingOpenSource: HcceIsHcclGraphModeValid is false, use original flow."); | ||
| 384 | + return HCCL_SUCCESS; | ||
| 385 | + } | ||
| 386 | + std::string socVersion{}; | ||
| 387 | + if (ge::GetThreadLocalContext().GetOption(ge::SOC_VERSION, socVersion) != ge::GRAPH_SUCCESS) { | ||
| 388 | + HCCL_ERROR("[HcomBaseFuns][IsUsingOpenSource] get soc version failed"); | ||
| 389 | + return HCCL_E_NOT_FOUND; | ||
L | |||
| 390 | + } | ||
| 391 | + HCCL_INFO("[HcomBaseFuns] IsUsingOpenSource: socVersion[%s]", socVersion.c_str()); | ||
| 392 | + const char *indOp = getenv("HCCL_INDEPENDENT_OP"); | ||
| 393 | + | ||
| 394 | + if (socVersion.find("Ascend950") == std::string::npos) { | ||
| 395 | + openSource = false; | ||
| 396 | + } else if (indOp != nullptr && strcmp(indOp, "") != 0) { | ||
| 397 | + openSource = true; | ||
| 398 | + } else { | ||
| 399 | + openSource = false; | ||
| 400 | + } | ||
| 401 | + return HCCL_SUCCESS; | ||
| 402 | +} | ||
| 376 | } // namespace hccl | 403 | } // namespace hccl |
| @@ -279,6 +279,7 @@ void SetThreadName(const std::string &threadStr); | |||
| 279 | bool IsSocVersion91093(std::string socVersion); | 279 | bool IsSocVersion91093(std::string socVersion); |
| 280 | bool IsSocVersion910B(std::string socVersion); | 280 | bool IsSocVersion910B(std::string socVersion); |
| 281 | bool IsSocVersion910(std::string socVersion); | 281 | bool IsSocVersion910(std::string socVersion); |
| 282 | +HcclResult IsUsingOpenSource(bool &openSource); | ||
| 282 | 283 | ||
| 283 | } // namespace hccl | 284 | } // namespace hccl |
| 284 | 285 | ||
Mcompiler/engines/hccl_engine/hcom_graph_adaptor/ge_plugin/common/ops_kernel_info_store_base.cc+20-0
| @@ -160,4 +160,24 @@ HcclResult HCCLOpsKernelInfoStore::GetReduceTypeFromTaskInfo(const ge::GETaskKer | |||
| 160 | HCCL_INFO("get optype[%s] from task info success.", GetReduceOpEnumStr(opType).c_str()); | 160 | HCCL_INFO("get optype[%s] from task info success.", GetReduceOpEnumStr(opType).c_str()); |
| 161 | return HCCL_SUCCESS; | 161 | return HCCL_SUCCESS; |
| 162 | } | 162 | } |
| 163 | + | ||
| 164 | + | ||
| 165 | +HcclResult HCCLOpsKernelInfoStore::GetStreamsFromTaskInfo(const ge::GETaskKernelHcclInfo &hcclInfo, | ||
| 166 | + std::vector<rtStream_t> &streams) { | ||
| 167 | + streams = hcclInfo.hcclStreamList; | ||
L size是否需要传出去? ![]() ![]() | |||
| 168 | + HCCL_INFO("get streams len[%llu] from task info success.", hcclInfo.hcclStreamList.size()); | ||
| 169 | + return HCCL_SUCCESS; | ||
| 170 | +} | ||
| 171 | + | ||
| 172 | +HcclResult HCCLOpsKernelInfoStore::GetWorkSpaceTaskInfo(const ge::GETaskKernelHcclInfo &hcclInfo, | ||
| 173 | + void **workSpace, uint64_t &memSize) { | ||
| 174 | + *workSpace = hcclInfo.workSpaceAddr; | ||
| 175 | + memSize = hcclInfo.workSpaceMemSize; | ||
| 176 | + HCCL_INFO("get input address[0x%016llx] len[%llu] from task info success.", (uintptr_t)hcclInfo.workSpaceAddr, hcclInfo.workSpaceMemSize); | ||
| 177 | + return HCCL_SUCCESS; | ||
| 178 | +} | ||
| 179 | + | ||
| 180 | + | ||
| 181 | + | ||
| 182 | + | ||
| 163 | } // namespace hccl | 183 | } // namespace hccl |
| @@ -51,6 +51,8 @@ class HCCLOpsKernelInfoStore : public ge::OpsKernelInfoStore { | |||
| 51 | HcclResult GetReduceTypeFromTaskInfo(const ge::GETaskKernelHcclInfo &hcclInfo, HcclReduceOp &opType); | 51 | HcclResult GetReduceTypeFromTaskInfo(const ge::GETaskKernelHcclInfo &hcclInfo, HcclReduceOp &opType); |
| 52 | HcclResult GetGlobalWorkSpaceAddrFromTaskInfo(const ge::GETaskKernelHcclInfo &hcclInfo, | 52 | HcclResult GetGlobalWorkSpaceAddrFromTaskInfo(const ge::GETaskKernelHcclInfo &hcclInfo, |
| 53 | std::vector<void *> &globalWorkSpaceAddr); | 53 | std::vector<void *> &globalWorkSpaceAddr); |
| 54 | + HcclResult GetStreamsFromTaskInfo(const ge::GETaskKernelHcclInfo &hcclInfo, std::vector<rtStream_t> &streams); | ||
| 55 | + HcclResult GetWorkSpaceTaskInfo(const ge::GETaskKernelHcclInfo &hcclInfo, void **workSpace, uint64_t &memSize); | ||
| 54 | }; | 56 | }; |
| 55 | } // namespace hccl | 57 | } // namespace hccl |
| 56 | 58 | ||
| @@ -14,6 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | + | ||
| 17 | 18 | ||
| 18 | 19 | ||
| 19 | 20 | ||
| @@ -1017,10 +1018,28 @@ HcclResult HcomGraphOptimizer::GetHcomReceiveOpOutputSize(const ge::OpDescPtr &o | |||
| 1017 | HcclResult HcomGraphOptimizer::HcomCalcOpRunningParam(ge::Node &node, bool uknownShapeGraph) { | 1018 | HcclResult HcomGraphOptimizer::HcomCalcOpRunningParam(ge::Node &node, bool uknownShapeGraph) { |
| 1018 | HCCL_INFO("calculate hccl runing parameters start."); | 1019 | HCCL_INFO("calculate hccl runing parameters start."); |
| 1019 | 1020 | ||
| 1020 | - HcclResult ret; | ||
| 1021 | - HcomOpParam hcomOpParam; | ||
| 1022 | - HcomResResponse hcomResResponse; | ||
| 1023 | std::string sCollectiveType; | 1021 | std::string sCollectiveType; |
| 1022 | + u32 streamNum = 0; | ||
| 1023 | + u64 opMemSize = 0; | ||
| 1024 | + u32 taskNum = 0; | ||
| 1025 | + u32 aivCoreNum = 0; | ||
| 1026 | + CHK_RET(CalcOpRunningResources(node, sCollectiveType, streamNum, opMemSize, taskNum, aivCoreNum)); | ||
| 1027 | + | ||
| 1028 | + CHK_RET(SetOpRunningParamAttributes(node, sCollectiveType, streamNum, opMemSize)); | ||
| 1029 | + | ||
| 1030 | + if (uknownShapeGraph) { | ||
| 1031 | + u32 cleanTaskNum = 0; | ||
| 1032 | + CHK_RET(HcomOpUtils::GetTensorCleanTaskNum(node, sCollectiveType, cleanTaskNum)); | ||
| 1033 | + taskNum += cleanTaskNum; | ||
| 1034 | + CHK_RET(CheckForceUnknown(node, taskNum)); | ||
| 1035 | + } | ||
| 1036 | + | ||
| 1037 | + return HCCL_SUCCESS; | ||
| 1038 | +} | ||
| 1039 | + | ||
| 1040 | +HcclResult HcomGraphOptimizer::CalcOpRunningResources(const ge::Node &node, std::string &sCollectiveType, | ||
| 1041 | + u32 &streamNum, u64 &opMemSize, u32 &taskNum, u32 &aivCoreNum) { | ||
| 1042 | + HcomOpParam hcomOpParam; | ||
| 1024 | std::string sGroup; | 1043 | std::string sGroup; |
| 1025 | std::string socVersion; | 1044 | std::string socVersion; |
| 1026 | std::vector<int64_t> sendCountMatrix; | 1045 | std::vector<int64_t> sendCountMatrix; |
| @@ -1031,63 +1050,86 @@ HcclResult HcomGraphOptimizer::HcomCalcOpRunningParam(ge::Node &node, bool uknow | |||
| 1031 | std::vector<u32> curRanks; | 1050 | std::vector<u32> curRanks; |
| 1032 | std::string rankTableStr; | 1051 | std::string rankTableStr; |
| 1033 | std::string rankTableM; | 1052 | std::string rankTableM; |
| 1034 | - | ||
| 1035 | CHK_RET(SetHcomOpParam(node, &hcomOpParam, sCollectiveType, sGroup, socVersion, sendCountMatrix, sendCounts, | 1053 | CHK_RET(SetHcomOpParam(node, &hcomOpParam, sCollectiveType, sGroup, socVersion, sendCountMatrix, sendCounts, |
| 1036 | sendDispls, recvCounts, recvDispls, curRanks, rankTableStr, rankTableM)); | 1054 | sendDispls, recvCounts, recvDispls, curRanks, rankTableStr, rankTableM)); |
| 1037 | 1055 | ||
| 1038 | - if (IsOfflineCompilation() || hcomOpParam.groupListSize != 0) { | 1056 | + bool openSourceTag = false; |
| 1039 | - CHK_RET(HcomCalcOpResOffline(&hcomOpParam, &hcomResResponse)); | 1057 | + CHK_RET(IsUsingOpenSource(openSourceTag)); |
| 1058 | + if (openSourceTag) { | ||
| 1059 | + HCCL_INFO("[HcomCalcOpRunningParam] enter opensource produce"); | ||
| 1060 | + | ||
| 1061 | + OpParamGraphModePtr opParamPtr = nullptr; | ||
| 1062 | + CHK_RET(HcceCreateOpParamGraphMode(&opParamPtr)); | ||
| 1063 | + // 使用RAII模式管理资源 | ||
| 1064 | + OpParamGraphModeGuard opParamGuard(opParamPtr); | ||
| 1065 | + // 设置Op参数 | ||
| 1066 | + CHK_RET(SetHcclOpParam(node, &hcomOpParam, opParamPtr, sCollectiveType, sendCounts, | ||
| 1067 | + sendDispls, recvCounts, recvDispls, sGroup.c_str())); | ||
| 1068 | + | ||
| 1069 | + if (IsOfflineCompilation() || hcomOpParam.groupListSize != 0) { | ||
| 1070 | + CHK_RET(HcceCalcOpResOfflineGraphMode(opParamPtr, &opMemSize, &streamNum, &taskNum, &aivCoreNum)); | ||
| 1071 | + } else { | ||
| 1072 | + CHK_RET(HcceCalcOpResOnlineGraphMode(opParamPtr, &opMemSize, &streamNum, &taskNum, &aivCoreNum)); | ||
| 1073 | + } | ||
| 1074 | + | ||
| 1075 | + if (!ge::AttrUtils::SetInt(node.GetOpDesc(), "hccl_aiv_core_num", static_cast<int64_t>(aivCoreNum))) { | ||
| 1076 | + HCCL_ERROR("[Calc][OpRunningParam] op[%s]: set aivCore number[%u] to OpDesc failed.", sCollectiveType.c_str(), aivCoreNum); | ||
| 1077 | + return HCCL_E_INTERNAL; | ||
| 1078 | + } | ||
| 1079 | + HCCL_INFO("[HcomGraphOptimizer][HcomCalcOpRunningParam] end opensource produce"); | ||
| 1040 | } else { | 1080 | } else { |
| 1041 | - CHK_RET(HcomCalcOpOnline(&hcomOpParam, &hcomResResponse)); | 1081 | + HcomResResponse hcomResResponse; |
| 1082 | + if (IsOfflineCompilation() || hcomOpParam.groupListSize != 0) { | ||
| 1083 | + CHK_RET(HcomCalcOpResOffline(&hcomOpParam, &hcomResResponse)); | ||
| 1084 | + } else { | ||
| 1085 | + CHK_RET(HcomCalcOpOnline(&hcomOpParam, &hcomResResponse)); | ||
| 1086 | + } | ||
| 1087 | + streamNum = static_cast<u32>(hcomResResponse.streamNum); | ||
| 1088 | + opMemSize = hcomResResponse.opMemSize; | ||
| 1089 | + taskNum = static_cast<u32>(hcomResResponse.taskNum); | ||
| 1042 | } | 1090 | } |
| 1043 | 1091 | ||
| 1092 | + return HCCL_SUCCESS; | ||
| 1093 | +} | ||
| 1094 | + | ||
| 1095 | +HcclResult HcomGraphOptimizer::SetOpRunningParamAttributes(ge::Node &node, const std::string &sCollectiveType, | ||
| 1096 | + u32 &streamNum, u64 opMemSize) { | ||
| 1044 | std::string nodeName = node.GetName(); | 1097 | std::string nodeName = node.GetName(); |
| 1098 | + | ||
| 1045 | if (sCollectiveType == HCCL_KERNEL_OP_TYPE_SEND || sCollectiveType == HCCL_KERNEL_OP_TYPE_RECEIVE || | 1099 | if (sCollectiveType == HCCL_KERNEL_OP_TYPE_SEND || sCollectiveType == HCCL_KERNEL_OP_TYPE_RECEIVE || |
| 1046 | (sCollectiveType == HCCL_KERNEL_OP_TYPE_BROADCAST && nodeName.find(NO_CALCULATION) != std::string::npos)) { | 1100 | (sCollectiveType == HCCL_KERNEL_OP_TYPE_BROADCAST && nodeName.find(NO_CALCULATION) != std::string::npos)) { |
| 1047 | - // 重新刷新从流为0 | 1101 | + streamNum = 0; |
| 1048 | - hcomResResponse.streamNum = 0; | ||
| 1049 | } | 1102 | } |
| 1050 | 1103 | ||
| 1051 | - if (ge::AttrUtils::SetInt(node.GetOpDesc(), "used_stream_num", hcomResResponse.streamNum) == false) { | 1104 | + if (!ge::AttrUtils::SetInt(node.GetOpDesc(), "used_stream_num", streamNum)) { |
| 1052 | - HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] op[%s]: set stream number[%llu] to OpDesc failed.", HCCL_E_PARA, | 1105 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] op[%s]: set stream number[%u] to OpDesc failed.", |
| 1053 | - hcomOpParam.opType, hcomResResponse.streamNum); | 1106 | + HCOM_ERROR_CODE(HCCL_E_PARA), sCollectiveType.c_str(), streamNum); |
| 1054 | return HCCL_E_INTERNAL; | 1107 | return HCCL_E_INTERNAL; |
| 1055 | } | 1108 | } |
| 1056 | 1109 | ||
| 1057 | - CHK_RET(SetOpWorkerSpaceForKnowShape(node, hcomResResponse.opMemSize)); | 1110 | + CHK_RET(SetOpWorkerSpaceForKnowShape(node, opMemSize)); |
| 1058 | - ret = SetOpMemAttr(node, node.GetOpDesc()->GetType(), hcomResResponse.opMemSize); | 1111 | + |
| 1059 | - CHK_PRT_RET( | 1112 | + HcclResult ret = SetOpMemAttr(node, node.GetOpDesc()->GetType(), opMemSize); |
| 1060 | - ret != HCCL_SUCCESS, | ||
| 1061 | - HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set node[%s] mem attr failed.", ret, node.GetName().c_str()), | ||
| 1062 | - HCCL_E_INTERNAL); | ||
| 1063 | - | ||
| 1064 | - // 设置output size 大小 | ||
| 1065 | - ret = SetOpOutputMemSize(node, hcomOpParam.opType); | ||
| 1066 | - CHK_PRT_RET( | ||
| 1067 | - ret != HCCL_SUCCESS, | ||
| 1068 | - HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set op[%s] output size failed.", ret, hcomOpParam.opType), | ||
| 1069 | - HCCL_E_INTERNAL); | ||
| 1070 | - | ||
| 1071 | - // 设定atomic index参数 | ||
| 1072 | - ret = SetOpAtomicInputIndex(node, hcomOpParam.opType); | ||
| 1073 | CHK_PRT_RET(ret != HCCL_SUCCESS, | 1113 | CHK_PRT_RET(ret != HCCL_SUCCESS, |
| 1074 | - HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set op[%s] atomic input index failed.", ret, | 1114 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set node[%s] mem attr failed.", |
L ret直接打成errNo是不是不合适,下同 ![]() ![]() | |||
| 1075 | - hcomOpParam.opType), | 1115 | + HCOM_ERROR_CODE(ret), node.GetName().c_str()), |
| 1076 | HCCL_E_INTERNAL); | 1116 | HCCL_E_INTERNAL); |
| 1077 | 1117 | ||
| 1078 | - HCCL_INFO( | 1118 | + ret = SetOpOutputMemSize(node, sCollectiveType.c_str()); |
| 1079 | - "[Calc][OpRunningParam] node[%s] calculate hccl runing parameters completed. stream num:[%llu], workspace " | 1119 | + CHK_PRT_RET(ret != HCCL_SUCCESS, |
| 1080 | - "size:[%llu]bytes", | 1120 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set op[%s] output size failed.", |
| 1081 | - node.GetName().c_str(), hcomResResponse.streamNum, hcomResResponse.opMemSize); | 1121 | + HCOM_ERROR_CODE(ret), sCollectiveType.c_str()), |
| 1122 | + HCCL_E_INTERNAL); | ||
| 1082 | 1123 | ||
| 1083 | - if (uknownShapeGraph) { // 动态图+集合通信算子+send/recv | 1124 | + ret = SetOpAtomicInputIndex(node, sCollectiveType.c_str()); |
| 1084 | - // 计算清零task数量,累加到hcomResResponse算出的taskNum | 1125 | + CHK_PRT_RET(ret != HCCL_SUCCESS, |
| 1085 | - u32 taskNum = static_cast<u32>(hcomResResponse.taskNum); | 1126 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set op[%s] atomic input index failed.", |
| 1086 | - u32 cleanTaskNum = 0; | 1127 | + HCOM_ERROR_CODE(ret), sCollectiveType.c_str()), |
| 1087 | - CHK_RET(HcomOpUtils::GetTensorCleanTaskNum(node, sCollectiveType, cleanTaskNum)); | 1128 | + HCCL_E_INTERNAL); |
| 1088 | - taskNum += cleanTaskNum; | 1129 | + |
| 1089 | - CHK_RET(CheckForceUnknown(node, taskNum)); | 1130 | + HCCL_INFO("[Calc][OpRunningParam] node[%s] calculate hccl runing parameters completed. " |
| 1090 | - } | 1131 | + "stream num:[%llu], workspace size:[%llu]bytes", |
| 1132 | + node.GetName().c_str(), streamNum, opMemSize); | ||
| 1091 | 1133 | ||
| 1092 | return HCCL_SUCCESS; | 1134 | return HCCL_SUCCESS; |
| 1093 | } | 1135 | } |
| @@ -1369,4 +1411,206 @@ HcclResult HcomGraphOptimizer::SetHcomOpParam(const ge::Node &node, HcomOpParam | |||
| 1369 | hcomOpParam->groupList, hcomOpParam->groupListSize, hcomOpParam->rankTable); | 1411 | hcomOpParam->groupList, hcomOpParam->groupListSize, hcomOpParam->rankTable); |
| 1370 | return HCCL_SUCCESS; | 1412 | return HCCL_SUCCESS; |
| 1371 | } | 1413 | } |
| 1414 | + | ||
| 1415 | +HcclResult HcomGraphOptimizer::SetHcclOpParam(const ge::Node &node, HcomOpParam *hcomOpParam, OpParamGraphModePtr opParamPtr, std::string &sCollectiveType, | ||
L 【代码规范】参数过多?超大函数?是否需要优化 ![]() ![]() | |||
| 1416 | + std::vector<int64_t> &sendCounts, std::vector<int64_t> &sendDispls, | ||
| 1417 | + std::vector<int64_t> &recvCounts, std::vector<int64_t> &recvDispls, const char* group) { | ||
| 1418 | + HCCL_INFO("[Calc][SetHcclOpParam] with [%s].", sCollectiveType.c_str()); | ||
| 1419 | + HcclResult ret; | ||
| 1420 | + sCollectiveType = node.GetOpDesc()->GetType(); | ||
| 1421 | + ret = CheckSupportedOP(sCollectiveType); | ||
| 1422 | + CHK_PRT_RET( | ||
| 1423 | + ret != HCCL_SUCCESS, | ||
| 1424 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] op type[%s] is not supported.", ret, sCollectiveType.c_str()), | ||
| 1425 | + HCCL_E_NOT_SUPPORT); | ||
| 1426 | + // aiv参数 | ||
| 1427 | + u64 count = 0; | ||
| 1428 | + void* counts = nullptr; | ||
| 1429 | + HcclDataType dataType = HCCL_DATA_TYPE_RESERVED; | ||
| 1430 | + HcclReduceOp reduction = HcclReduceOp::HCCL_REDUCE_SUM; | ||
| 1431 | + HcclCMDType opTypeAiv = HcclCMDType::HCCL_CMD_INVALID; | ||
| 1432 | + u32 aivCoreLimit = 0; | ||
| 1433 | + bool ifAiv = false; | ||
| 1434 | + | ||
| 1435 | + // 计算Aiv参数 | ||
| 1436 | + CHK_RET(GetAivParam(node, sCollectiveType, group, count, dataType, reduction, opTypeAiv, aivCoreLimit, ifAiv)); | ||
| 1437 | + // 设置aiv参数 | ||
| 1438 | + ret = HcceSetAivSelectOpParamGraphMode(opParamPtr, group, count, counts, dataType, reduction, opTypeAiv, aivCoreLimit, ifAiv); | ||
| 1439 | + CHK_PRT_RET( | ||
| 1440 | + ret != HCCL_SUCCESS, | ||
| 1441 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set aivParam failed.", ret), | ||
| 1442 | + ret); | ||
| 1443 | + // 设置 opType | ||
| 1444 | + ret = HcceSetOpParamGraphModeOpType(opParamPtr, sCollectiveType.c_str()); | ||
| 1445 | + CHK_PRT_RET( | ||
| 1446 | + ret != HCCL_SUCCESS, | ||
| 1447 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set op type[%s] failed.", ret, sCollectiveType.c_str()), | ||
| 1448 | + ret); | ||
| 1449 | + | ||
| 1450 | + ret = HcomOpUtils::ConversionOpDataType(node.GetOpDesc(), sCollectiveType, dataType); | ||
| 1451 | + CHK_PRT_RET( | ||
| 1452 | + ret != HCCL_SUCCESS, | ||
| 1453 | + HCCL_ERROR("[Get][OpWorkspaceMemSize]op[%s]: get data type failed. ret[%d]", sCollectiveType.c_str(), ret), ret); | ||
| 1454 | + | ||
| 1455 | + ret = HcceSetOpParamGraphModeDataType(opParamPtr, dataType); | ||
| 1456 | + CHK_PRT_RET( | ||
| 1457 | + ret != HCCL_SUCCESS, | ||
| 1458 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set data type failed.", ret), | ||
| 1459 | + ret); | ||
| 1460 | + | ||
| 1461 | + // 设置 rankSize | ||
| 1462 | + int64_t hcomComm = 0; | ||
| 1463 | + std::string sGroup; | ||
| 1464 | + ret = GetCommFromOpDesc(node.GetOpDesc(), hcomComm, sGroup); | ||
| 1465 | + CHK_PRT_RET( | ||
| 1466 | + ret != HCCL_SUCCESS, | ||
| 1467 | + HCCL_ERROR("[Get][OpWorkspaceMemSize]op[%s]: GetGroupFromOpDesc failed. ret[%d]", sCollectiveType.c_str(), ret), | ||
| 1468 | + ret); | ||
| 1469 | + if (hcomComm != static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | ||
| 1470 | + CHK_RET(GetGroupNameByOpBaseHcom(hcomComm, &(hcomOpParam->group))); | ||
| 1471 | + } else { | ||
| 1472 | + hcomOpParam->group = const_cast<char *>(sGroup.c_str()); | ||
| 1473 | + } | ||
| 1474 | + | ||
| 1475 | + u32 rankSize = 0; | ||
| 1476 | + if (!IsOfflineCompilation()) { | ||
| 1477 | + if (hcomComm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | ||
| 1478 | + CHK_RET(HcomGetRankSize(sGroup.c_str(), &rankSize)); | ||
| 1479 | + } else { | ||
| 1480 | + char *group = nullptr; | ||
| 1481 | + CHK_RET(GetGroupNameByOpBaseHcom(hcomComm, &group)); | ||
| 1482 | + CHK_RET(HcomGetRankSize(group, &rankSize)); | ||
| 1483 | + } | ||
| 1484 | + } else { | ||
| 1485 | + // 离线编译ranksize在HcomCalcOpResOffline中计算 | ||
| 1486 | + } | ||
| 1487 | + if ((sCollectiveType == HCCL_KERNEL_OP_TYPE_REDUCESCATTER) || (sCollectiveType == HCCL_KERNEL_OP_TYPE_ALLGATHER)) { | ||
| 1488 | + CHK_PRT_RET((!ge::AttrUtils::GetInt(node.GetOpDesc(), HCOM_ATTR_RANK_SIZE, rankSize)), | ||
| 1489 | + HCCL_ERROR("[Get][OpWorkspaceMemSize]op[%s] get attr[%s] failed.", sCollectiveType.c_str(), | ||
| 1490 | + HCOM_ATTR_RANK_SIZE.c_str()), | ||
| 1491 | + HCCL_E_PARA); | ||
| 1492 | + CHK_PRT_RET((rankSize <= 0), | ||
| 1493 | + HCCL_ERROR("[Get][OpWorkspaceMemSize]op[%s]: rank_size[%d] should be " | ||
| 1494 | + "greater than 0.", | ||
| 1495 | + sCollectiveType.c_str(), rankSize), | ||
| 1496 | + HCCL_E_PARA); | ||
| 1497 | + } | ||
| 1498 | + ret = HcceSetOpParamGraphModeRankSize(opParamPtr, &rankSize); | ||
| 1499 | + CHK_PRT_RET( | ||
| 1500 | + ret != HCCL_SUCCESS, | ||
| 1501 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set rank_size[%d] failed.", ret, rankSize), | ||
| 1502 | + ret); | ||
| 1503 | + | ||
| 1504 | + ret = GetCountFromOpDesc(node.GetOpDesc(), sCollectiveType, dataType, count); | ||
| 1505 | + HCCL_INFO("GetCountFromOpDesc count[%d]", count); | ||
| 1506 | + | ||
| 1507 | + ret = HcomOpUtils::GetAccuracyCountFromOpDesc(node.GetOpDesc(), sCollectiveType, dataType, count, rankSize); | ||
| 1508 | + HCCL_INFO("GetAccuracyCountFromOpDesc count[%d]", count); | ||
| 1509 | + CHK_PRT_RET(ret != HCCL_SUCCESS, | ||
| 1510 | + HCCL_ERROR("[Get][OpWorkspaceMemSize]op[%s]: get count failed. ret[%d]", sCollectiveType.c_str(), ret), | ||
| 1511 | + ret); | ||
| 1512 | + ret = HcceSetOpParamGraphModeDataCount(opParamPtr, &count); | ||
| 1513 | + HCCL_INFO("Count[%llu]", count); | ||
| 1514 | + CHK_PRT_RET( | ||
| 1515 | + ret != HCCL_SUCCESS, | ||
| 1516 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set count[%d] failed.", ret, count), | ||
| 1517 | + ret); | ||
| 1518 | + | ||
| 1519 | + if (sCollectiveType == HCCL_KERNEL_OP_TYPE_REDUCESCATTERV) { | ||
| 1520 | + // reducescatterv复用HcomOpParam的All2AllDataDes字段 | ||
| 1521 | + CHK_RET( | ||
| 1522 | + HcomOpUtils::GetReduceScatterVCountsDispl(const_cast<ge::Node &>(node), sendCounts, sendDispls, recvCounts)); | ||
| 1523 | + count = *std::max_element(sendCounts.begin(), sendCounts.end()); | ||
| 1524 | + ret = HcceSetOpParamGraphModeDataCount(opParamPtr, &count); | ||
| 1525 | + HCCL_INFO("REDUCESCATTERV Count[%llu]", count); | ||
| 1526 | + CHK_PRT_RET( | ||
| 1527 | + ret != HCCL_SUCCESS, | ||
| 1528 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set count[%d] failed.", ret, count), | ||
| 1529 | + ret); | ||
| 1530 | + } | ||
| 1531 | + | ||
| 1532 | + if (sCollectiveType == HCCL_KERNEL_OP_TYPE_ALLGATHERV) { | ||
| 1533 | + // allgatherv复用HcomOpParam的All2AllDataDes字段 | ||
| 1534 | + CHK_RET(HcomOpUtils::GetAllGatherVCountsDispl(const_cast<ge::Node &>(node), sendCounts, recvCounts, recvDispls)); | ||
| 1535 | + count = *std::max_element(recvCounts.begin(), recvCounts.end()); | ||
| 1536 | + ret = HcceSetOpParamGraphModeDataCount(opParamPtr, &count); | ||
| 1537 | + HCCL_INFO("ALLGATHERV Count[%llu]", count); | ||
| 1538 | + CHK_PRT_RET( | ||
| 1539 | + ret != HCCL_SUCCESS, | ||
| 1540 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set count[%d] failed.", ret, count), | ||
| 1541 | + ret); | ||
| 1542 | + } | ||
| 1543 | + | ||
| 1544 | + if (sCollectiveType == HCCL_KERNEL_OP_TYPE_ALLTOALLV) { | ||
| 1545 | + HcclDataType sendType; | ||
| 1546 | + HcclDataType recvType; | ||
| 1547 | + CHK_RET(HcomOpUtils::GetAlltoAllDataType(node.GetOpDesc(), sendType, recvType)); | ||
| 1548 | + | ||
| 1549 | + auto op = node.GetOpDesc(); | ||
| 1550 | + if (ge::AttrUtils::HasAttr(op, "send_counts")) { | ||
| 1551 | + CHK_RET(HcomOpUtils::GetAlltoAllCountsDispl(op, sendCounts, sendDispls, recvCounts, recvDispls)); | ||
| 1552 | + } else { | ||
| 1553 | + CHK_RET(HcomOpUtils::GetAlltoAllCountsDispl(const_cast<ge::Node &>(node), sendCounts, sendDispls, recvCounts, | ||
| 1554 | + recvDispls)); | ||
| 1555 | + } | ||
| 1556 | + | ||
| 1557 | + if (sendCounts.size() < rankSize) { | ||
| 1558 | + HCCL_ERROR("[sendCounts] size[%u] is invalid, expect size: %llu", sendCounts.size(), rankSize); | ||
| 1559 | + return HCCL_E_PARA; | ||
| 1560 | + } | ||
| 1561 | + | ||
| 1562 | + count = *std::max_element(sendCounts.begin(), sendCounts.end()); | ||
| 1563 | + ret = HcceSetOpParamGraphModeDataCount(opParamPtr, &count); | ||
| 1564 | + HCCL_INFO("ALLTOALLV Count[%llu]", count); | ||
| 1565 | + CHK_PRT_RET( | ||
| 1566 | + ret != HCCL_SUCCESS, | ||
| 1567 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set count[%d] failed.", ret, count), | ||
| 1568 | + ret); | ||
| 1569 | + } | ||
| 1570 | + | ||
| 1571 | + // 获取cclbuffer size | ||
| 1572 | + u64 cclBuffSize; | ||
| 1573 | + CHK_RET(GetCCLBufferAvailableSize(cclBuffSize)); | ||
| 1574 | + ret = HcceSetOpParamGraphModeHCCLBufferSize(opParamPtr, &cclBuffSize); | ||
| 1575 | + CHK_PRT_RET( | ||
| 1576 | + ret != HCCL_SUCCESS, | ||
| 1577 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set op type[%s] failed.", ret, sCollectiveType.c_str()), | ||
| 1578 | + ret); | ||
| 1579 | + | ||
| 1580 | + return HCCL_SUCCESS; | ||
| 1581 | +} | ||
| 1582 | + | ||
| 1583 | +HcclResult HcomGraphOptimizer::GetAivParam(const ge::Node &node, std::string &sCollectiveType, const char* group, | ||
| 1584 | + u64 &count, HcclDataType &dataType, HcclReduceOp &reduction, HcclCMDType &opType, | ||
| 1585 | + u32 &aivCoreLimit, bool ifAiv) { | ||
| 1586 | + CHK_RET(HcomOpUtils::GetAivCoreLimit(node.GetOpDesc(), sCollectiveType, aivCoreLimit)); | ||
| 1587 | + (void)ifAiv; | ||
| 1588 | + HcclResult ret; | ||
| 1589 | + u32 rankSize = 0; | ||
| 1590 | + CHK_RET(HcomGetRankSize(group, &rankSize)); | ||
| 1591 | + | ||
| 1592 | + ret = HcomOpUtils::ConversionOpDataType(node.GetOpDesc(), sCollectiveType, dataType); | ||
| 1593 | + CHK_PRT_RET( | ||
| 1594 | + ret != HCCL_SUCCESS, | ||
| 1595 | + HCCL_ERROR("[Get][SetSuperKernelScopeAttr]op[%s]: get data type failed. ret[%d]", sCollectiveType.c_str(), ret), | ||
| 1596 | + ret); | ||
| 1597 | + | ||
| 1598 | + ret = HcomOpUtils::GetCountFromOpDescSuperkernel(node.GetOpDesc(), sCollectiveType, dataType, count, rankSize); | ||
| 1599 | + CHK_PRT_RET( | ||
| 1600 | + ret != HCCL_SUCCESS, | ||
| 1601 | + HCCL_ERROR("[Get][SetSuperKernelScopeAttr]op[%s]: get count failed. ret[%d]", sCollectiveType.c_str(), ret), | ||
| 1602 | + ret); | ||
| 1603 | + | ||
| 1604 | + auto iter = HCCL_OPTYPE_NAME_MAP.find(sCollectiveType); | ||
| 1605 | + if (iter != HCCL_OPTYPE_NAME_MAP.end()) { | ||
| 1606 | + opType = iter->second; | ||
| 1607 | + } | ||
| 1608 | + | ||
| 1609 | + if (opType == HcclCMDType::HCCL_CMD_ALLREDUCE || opType == HcclCMDType::HCCL_CMD_REDUCE_SCATTER) { | ||
| 1610 | + CHK_RET(HcomOpUtils::GetReduction(node.GetOpDesc(), reduction)); | ||
| 1611 | + } | ||
| 1612 | + | ||
| 1613 | + return HCCL_SUCCESS; | ||
| 1614 | +} | ||
| 1615 | + | ||
| 1372 | } // namespace hccl | 1616 | } // namespace hccl |
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 20 | 21 | ||
| 21 | 22 | ||
| @@ -84,9 +85,19 @@ class HcomGraphOptimizer : public ge::GraphOptimizer { | |||
| 84 | std::vector<int64_t> &sendCounts, std::vector<int64_t> &sendDispls, | 85 | std::vector<int64_t> &sendCounts, std::vector<int64_t> &sendDispls, |
| 85 | std::vector<int64_t> &recvCounts, std::vector<int64_t> &recvDispls, | 86 | std::vector<int64_t> &recvCounts, std::vector<int64_t> &recvDispls, |
| 86 | std::vector<u32> &curRanks, std::string &rankTableStr, std::string &rankTableM); | 87 | std::vector<u32> &curRanks, std::string &rankTableStr, std::string &rankTableM); |
| 88 | + HcclResult SetHcclOpParam(const ge::Node &node, HcomOpParam *hcomOpParam, OpParamGraphModePtr opParam, std::string &sCollectiveType, | ||
| 89 | + std::vector<int64_t> &sendCounts, std::vector<int64_t> &sendDispls, | ||
| 90 | + std::vector<int64_t> &recvCounts, std::vector<int64_t> &recvDispls, const char* group); | ||
| 91 | + HcclResult GetAivParam(const ge::Node &node, std::string &sCollectiveType, const char* group, | ||
| 92 | + u64 &count, HcclDataType &dataType, HcclReduceOp &reduction, HcclCMDType &opType, | ||
| 93 | + u32 &aivCoreLimit, bool ifAiv); | ||
| 87 | HcclResult SetOpWorkerSpaceForKnowShape(ge::Node &node, u64 &opMemSize); | 94 | HcclResult SetOpWorkerSpaceForKnowShape(ge::Node &node, u64 &opMemSize); |
| 88 | HcclResult GetOriginalGraphShapeTypeFromDesc(const ge::OpDescPtr &op, u32 &shapeType); | 95 | HcclResult GetOriginalGraphShapeTypeFromDesc(const ge::OpDescPtr &op, u32 &shapeType); |
| 89 | HcclResult CheckForceUnknown(const ge::Node &node, u32 &taskNum); | 96 | HcclResult CheckForceUnknown(const ge::Node &node, u32 &taskNum); |
| 97 | + HcclResult CalcOpRunningResources(const ge::Node &node, std::string &sCollectiveType, | ||
| 98 | + u32 &streamNum, u64 &opMemSize, u32 &taskNum, u32 &aivCoreNum); | ||
| 99 | + HcclResult SetOpRunningParamAttributes(ge::Node &node, const std::string &sCollectiveType, | ||
| 100 | + u32 &streamNum, u64 opMemSize); | ||
| 90 | 101 | ||
| 91 | bool IsSubgraphMultiBatch(ge::ComputeGraph &graph); | 102 | bool IsSubgraphMultiBatch(ge::ComputeGraph &graph); |
| 92 | 103 | ||
| @@ -10,8 +10,10 @@ | |||
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | + | ||
| 13 | 14 | ||
| 14 | 15 | ||
| 16 | + | ||
| 15 | 17 | ||
| 16 | 18 | ||
| 17 | 19 | ||
| @@ -668,6 +670,18 @@ HcclResult HcomOpsKernelBuilder::GetCountsFromOpDesc(const ge::Node &node, std:: | |||
| 668 | 670 | ||
| 669 | HcclResult HcomOpsKernelBuilder::TaskDefSetNumBlocks(const ge::Node &node, domi::TaskDef &taskDef, | 671 | HcclResult HcomOpsKernelBuilder::TaskDefSetNumBlocks(const ge::Node &node, domi::TaskDef &taskDef, |
| 670 | const std::string sCollectiveType, const u32 aivCoreLimit) { | 672 | const std::string sCollectiveType, const u32 aivCoreLimit) { |
| 673 | + u32 numBlocks = 0; | ||
| 674 | + if (ge::AttrUtils::GetInt(node.GetOpDesc(), "hccl_aiv_core_num", numBlocks)) { | ||
| 675 | + domi::KernelHcclDef *kernelDefHccl = taskDef.mutable_kernel_hccl(); | ||
| 676 | + CHK_PRT_RET((kernelDefHccl == nullptr), | ||
| 677 | + HCCL_ERROR("[Generate][Task]node[%s]: kernelDefHccl is null.", node.GetOpDesc()->GetName().c_str()), | ||
| 678 | + HCCL_E_PTR); | ||
| 679 | + | ||
| 680 | + kernelDefHccl->set_aiv_block_dim(numBlocks); | ||
| 681 | + HCCL_INFO("[TaskDefSetNumBlocks] %s set numBlocks %d success", sCollectiveType.c_str(), numBlocks); | ||
| 682 | + return HCCL_SUCCESS; | ||
| 683 | + } | ||
| 684 | + | ||
| 671 | // 离线模式不设置核数 | 685 | // 离线模式不设置核数 |
| 672 | if (IsOfflineCompilation()) { | 686 | if (IsOfflineCompilation()) { |
| 673 | HCCL_DEBUG("[TaskDefSetNumBlocks] IsOfflineCompilation, not set numBlocks"); | 687 | HCCL_DEBUG("[TaskDefSetNumBlocks] IsOfflineCompilation, not set numBlocks"); |
| @@ -721,8 +735,6 @@ HcclResult HcomOpsKernelBuilder::TaskDefSetNumBlocks(const ge::Node &node, domi: | |||
| 721 | HCCL_DEBUG("[TaskDefSetNumBlocks] not Aiv, do not set numBlocks"); | 735 | HCCL_DEBUG("[TaskDefSetNumBlocks] not Aiv, do not set numBlocks"); |
| 722 | return HCCL_SUCCESS; | 736 | return HCCL_SUCCESS; |
| 723 | } | 737 | } |
| 724 | - | ||
| 725 | - u32 numBlocks = 0; | ||
| 726 | CHK_RET(HcomCalcAivCoreNum(group.c_str(), opType, count, countsPtr, dataType, aivCoreLimit, algName, &numBlocks)); | 738 | CHK_RET(HcomCalcAivCoreNum(group.c_str(), opType, count, countsPtr, dataType, aivCoreLimit, algName, &numBlocks)); |
| 727 | 739 | ||
| 728 | domi::KernelHcclDef *kernelDefHccl = taskDef.mutable_kernel_hccl(); | 740 | domi::KernelHcclDef *kernelDefHccl = taskDef.mutable_kernel_hccl(); |
| @@ -767,12 +779,23 @@ HcclResult HcomOpsKernelBuilder::GenerateTaskPrivateDef(const ge::Node &node, | |||
| 767 | HcclResult HcomOpsKernelBuilder::HcomCalcOpRunningParam(ge::Node &node) { | 779 | HcclResult HcomOpsKernelBuilder::HcomCalcOpRunningParam(ge::Node &node) { |
| 768 | HCCL_INFO("calculate hccl runing parameters start."); | 780 | HCCL_INFO("calculate hccl runing parameters start."); |
| 769 | 781 | ||
| 770 | - HcclResult ret; | ||
| 771 | - HcomOpParam hcomOpParam; | ||
| 772 | - HcomResResponse hcomResResponse; | ||
| 773 | std::string sCollectiveType; | 782 | std::string sCollectiveType; |
| 774 | std::string sGroup; | 783 | std::string sGroup; |
| 775 | - std::string socVersion; | 784 | + u32 streamNum = 0; |
| 785 | + u64 opMemSize = 0; | ||
| 786 | + u32 taskNum = 0; | ||
| 787 | + u32 aivCoreNum = 0; | ||
| 788 | + CHK_RET(CalcOpRunningResources(node, sCollectiveType, sGroup, streamNum, opMemSize, taskNum, aivCoreNum)); | ||
| 789 | + | ||
| 790 | + CHK_RET(SetOpRunningParamAttributes(node, sCollectiveType, sGroup, streamNum, opMemSize, taskNum)); | ||
| 791 | + | ||
| 792 | + return HCCL_SUCCESS; | ||
| 793 | +} | ||
| 794 | + | ||
| 795 | +HcclResult HcomOpsKernelBuilder::CalcOpRunningResources(const ge::Node &node, std::string &sCollectiveType, | ||
| 796 | + std::string &sGroup, u32 &streamNum, | ||
| 797 | + u64 &opMemSize, u32 &taskNum, u32 &aivCoreNum) { | ||
| 798 | + | ||
| 776 | std::vector<int64_t> sendCountMatrix; | 799 | std::vector<int64_t> sendCountMatrix; |
| 777 | std::vector<int64_t> sendCounts; | 800 | std::vector<int64_t> sendCounts; |
| 778 | std::vector<int64_t> sendDispls; | 801 | std::vector<int64_t> sendDispls; |
| @@ -781,67 +804,110 @@ HcclResult HcomOpsKernelBuilder::HcomCalcOpRunningParam(ge::Node &node) { | |||
| 781 | std::vector<u32> curRanks; | 804 | std::vector<u32> curRanks; |
| 782 | std::string rankTableStr; | 805 | std::string rankTableStr; |
| 783 | std::string rankTableM; | 806 | std::string rankTableM; |
| 784 | - | 807 | + std::string socVersion; |
| 808 | + HcomOpParam hcomOpParam; | ||
| 809 | + HCCL_INFO("[HcomCalcOpRunningParam] CalcOpRunningResources"); | ||
| 785 | CHK_RET(SetHcomOpParam(node, &hcomOpParam, sCollectiveType, sGroup, socVersion, sendCountMatrix, sendCounts, | 810 | CHK_RET(SetHcomOpParam(node, &hcomOpParam, sCollectiveType, sGroup, socVersion, sendCountMatrix, sendCounts, |
| 786 | sendDispls, recvCounts, recvDispls, curRanks, rankTableStr, rankTableM)); | 811 | sendDispls, recvCounts, recvDispls, curRanks, rankTableStr, rankTableM)); |
| 787 | 812 | ||
| 788 | - if (IsOfflineCompilation() || hcomOpParam.groupListSize != 0) { | 813 | + bool openSourceTag = false; |
| 789 | - CHK_RET(HcomCalcOpResOffline(&hcomOpParam, &hcomResResponse)); | 814 | + CHK_RET(IsUsingOpenSource(openSourceTag)); |
| 815 | + if (openSourceTag) { | ||
| 816 | + HCCL_INFO("[HcomCalcOpRunningParam] enter opensource produce"); | ||
| 817 | + | ||
| 818 | + OpParamGraphModePtr opParamPtr = nullptr; | ||
| 819 | + CHK_RET(HcceCreateOpParamGraphMode(&opParamPtr)); | ||
| 820 | + // 使用RAII模式管理资源 | ||
| 821 | + OpParamGraphModeGuard opParamGuard(opParamPtr); | ||
| 822 | + | ||
| 823 | + // 设置Op参数 | ||
| 824 | + CHK_RET(SetHcclOpParam(node, &hcomOpParam, opParamPtr, sCollectiveType, sendCounts, | ||
| 825 | + sendDispls, recvCounts, recvDispls, sGroup.c_str())); | ||
| 826 | + HCCL_INFO("[HcomCalcOpRunningParam] enter opensource produce"); | ||
| 827 | + if (IsOfflineCompilation() || hcomOpParam.groupListSize != 0) { | ||
| 828 | + CHK_RET(HcceCalcOpResOfflineGraphMode(opParamPtr, &opMemSize, &streamNum, &taskNum, &aivCoreNum)); | ||
| 829 | + } else { | ||
| 830 | + CHK_RET(HcceCalcOpResOnlineGraphMode(opParamPtr, &opMemSize, &streamNum, &taskNum, &aivCoreNum)); | ||
| 831 | + } | ||
| 832 | + | ||
| 833 | + if (!ge::AttrUtils::SetInt(node.GetOpDesc(), "hccl_aiv_core_num", static_cast<int64_t>(aivCoreNum))) { | ||
| 834 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] op[%s]: set aivCore number[%llu] to OpDesc failed.", | ||
| 835 | + HCOM_ERROR_CODE(HCCL_E_PARA), hcomOpParam.opType, aivCoreNum); | ||
| 836 | + return HCCL_E_INTERNAL; | ||
| 837 | + } | ||
| 838 | + | ||
| 839 | + HCCL_INFO("[HcomOpsKernelBuilder][HcomCalcOpRunningParam] end opensource produce"); | ||
| 790 | } else { | 840 | } else { |
| 791 | - CHK_RET(HcomCalcOpOnline(&hcomOpParam, &hcomResResponse)); | 841 | + HcomResResponse hcomResResponse; |
| 842 | + if (IsOfflineCompilation() || hcomOpParam.groupListSize != 0) { | ||
| 843 | + CHK_RET(HcomCalcOpResOffline(&hcomOpParam, &hcomResResponse)); | ||
| 844 | + } else { | ||
| 845 | + CHK_RET(HcomCalcOpOnline(&hcomOpParam, &hcomResResponse)); | ||
| 846 | + } | ||
| 847 | + streamNum = static_cast<u32>(hcomResResponse.streamNum); | ||
| 848 | + opMemSize = hcomResResponse.opMemSize; | ||
| 849 | + taskNum = static_cast<u32>(hcomResResponse.taskNum); | ||
| 792 | } | 850 | } |
| 793 | 851 | ||
| 852 | + return HCCL_SUCCESS; | ||
| 853 | +} | ||
| 854 | + | ||
| 855 | +HcclResult HcomOpsKernelBuilder::SetOpRunningParamAttributes(ge::Node &node, const std::string &sCollectiveType, | ||
| 856 | + const std::string &sGroup, u32 &streamNum, | ||
| 857 | + u64 opMemSize, u32 taskNum) { | ||
| 794 | std::string nodeName = node.GetName(); | 858 | std::string nodeName = node.GetName(); |
| 859 | + | ||
| 795 | if (sCollectiveType == HCCL_KERNEL_OP_TYPE_SEND || sCollectiveType == HCCL_KERNEL_OP_TYPE_RECEIVE || | 860 | if (sCollectiveType == HCCL_KERNEL_OP_TYPE_SEND || sCollectiveType == HCCL_KERNEL_OP_TYPE_RECEIVE || |
| 796 | (sCollectiveType == HCCL_KERNEL_OP_TYPE_BROADCAST && nodeName.find(NO_CALCULATION) != std::string::npos)) { | 861 | (sCollectiveType == HCCL_KERNEL_OP_TYPE_BROADCAST && nodeName.find(NO_CALCULATION) != std::string::npos)) { |
| 797 | // 重新刷新从流为0 | 862 | // 重新刷新从流为0 |
| 798 | - hcomResResponse.streamNum = 0; | 863 | + streamNum = 0; |
| 799 | } | 864 | } |
| 800 | 865 | ||
| 801 | - if (ge::AttrUtils::SetInt(node.GetOpDesc(), "used_stream_num", hcomResResponse.streamNum) == false) { | 866 | + if (ge::AttrUtils::SetInt(node.GetOpDesc(), "used_stream_num", streamNum) == false) { |
| 802 | - HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] op[%s]: set stream number[%llu] to OpDesc failed.", HCCL_E_PARA, | 867 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] op[%s]: set stream number[%llu] to OpDesc failed.", |
| 803 | - hcomOpParam.opType, hcomResResponse.streamNum); | 868 | + HCCL_E_PARA, sCollectiveType.c_str(), streamNum); |
| 804 | return HCCL_E_INTERNAL; | 869 | return HCCL_E_INTERNAL; |
| 805 | } | 870 | } |
| 806 | 871 | ||
| 807 | // 计算清零task数量,累加到hcomResResponse算出的taskNum | 872 | // 计算清零task数量,累加到hcomResResponse算出的taskNum |
| 808 | - u32 taskNum = static_cast<u32>(hcomResResponse.taskNum); | ||
| 809 | u32 cleanTaskNum = 0; | 873 | u32 cleanTaskNum = 0; |
| 810 | CHK_RET(HcomOpUtils::GetTensorCleanTaskNum(node, sCollectiveType, cleanTaskNum)); | 874 | CHK_RET(HcomOpUtils::GetTensorCleanTaskNum(node, sCollectiveType, cleanTaskNum)); |
| 811 | taskNum += cleanTaskNum; | 875 | taskNum += cleanTaskNum; |
| 812 | if (ge::AttrUtils::SetInt(node.GetOpDesc(), "_hccl_task_num", taskNum) == false) { | 876 | if (ge::AttrUtils::SetInt(node.GetOpDesc(), "_hccl_task_num", taskNum) == false) { |
| 813 | - HCCL_ERROR("[HcomCalc][OpRunningParam]errNo[0x%016llx] op[%s]: set _hccl_task_num to OpDesc failed.", HCCL_E_PARA, | 877 | + HCCL_ERROR("[HcomCalc][OpRunningParam]errNo[0x%016llx] op[%s]: set _hccl_task_num to OpDesc failed.", |
| 814 | - hcomOpParam.opType); | 878 | + HCCL_E_PARA, sCollectiveType.c_str()); |
| 815 | return HCCL_E_PARA; | 879 | return HCCL_E_PARA; |
| 816 | } | 880 | } |
| 817 | 881 | ||
| 818 | - CHK_RET(SetOpWorkerSpaceForKnowShape(node, hcomResResponse.opMemSize)); | 882 | + CHK_RET(SetOpWorkerSpaceForKnowShape(node, opMemSize)); |
| 819 | - ret = SetOpMemAttr(node, node.GetOpDesc()->GetType(), hcomResResponse.opMemSize); | 883 | + |
| 820 | - CHK_PRT_RET( | 884 | + HcclResult ret = SetOpMemAttr(node, node.GetOpDesc()->GetType(), opMemSize); |
| 821 | - ret != HCCL_SUCCESS, | 885 | + CHK_PRT_RET(ret != HCCL_SUCCESS, |
| 822 | - HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set node[%s] mem attr failed.", ret, node.GetName().c_str()), | 886 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set node[%s] mem attr failed.", |
| 823 | - HCCL_E_INTERNAL); | 887 | + ret, node.GetName().c_str()), |
| 888 | + HCCL_E_INTERNAL); | ||
| 824 | 889 | ||
| 825 | - HCCL_INFO( | 890 | + HCCL_INFO("[Calc][OpRunningParam] node[%s] calculate hccl runing parameters completed. " |
| 826 | - "[Calc][OpRunningParam] node[%s] calculate hccl runing parameters completed. stream num:[%llu], workspace " | 891 | + "stream num:[%llu], workspace size:[%llu]bytes", |
| 827 | - "size:[%llu]bytes", | 892 | + node.GetName().c_str(), streamNum, opMemSize); |
| 828 | - node.GetName().c_str(), hcomResResponse.streamNum, hcomResResponse.opMemSize); | ||
| 829 | HCCL_INFO("GetAndSetTaskNum success. task num:[%llu]", taskNum); | 893 | HCCL_INFO("GetAndSetTaskNum success. task num:[%llu]", taskNum); |
| 830 | 894 | ||
| 831 | // 设置output size 大小 | 895 | // 设置output size 大小 |
| 832 | - ret = SetOpOutputMemSize(node, hcomOpParam.opType); | 896 | + ret = SetOpOutputMemSize(node, sCollectiveType.c_str()); |
| 833 | - CHK_PRT_RET( | 897 | + CHK_PRT_RET(ret != HCCL_SUCCESS, |
| 834 | - ret != HCCL_SUCCESS, | 898 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set op[%s] output size failed.", |
| 835 | - HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set op[%s] output size failed.", ret, hcomOpParam.opType), | 899 | + ret, sCollectiveType.c_str()), |
| 836 | - HCCL_E_INTERNAL); | 900 | + HCCL_E_INTERNAL); |
| 837 | 901 | ||
| 838 | // 设定atomic index参数 | 902 | // 设定atomic index参数 |
| 839 | - ret = SetOpAtomicInputIndex(node, hcomOpParam.opType); | 903 | + ret = SetOpAtomicInputIndex(node, sCollectiveType.c_str()); |
| 840 | CHK_PRT_RET(ret != HCCL_SUCCESS, | 904 | CHK_PRT_RET(ret != HCCL_SUCCESS, |
| 841 | - HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set op[%s] atomic input index failed.", ret, | 905 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set op[%s] atomic input index failed.", |
| 842 | - hcomOpParam.opType), | 906 | + ret, sCollectiveType.c_str()), |
| 843 | HCCL_E_INTERNAL); | 907 | HCCL_E_INTERNAL); |
| 908 | + | ||
| 844 | CHK_RET(SetAttachedStreamInfoList(node, sGroup)); | 909 | CHK_RET(SetAttachedStreamInfoList(node, sGroup)); |
| 910 | + | ||
| 845 | return HCCL_SUCCESS; | 911 | return HCCL_SUCCESS; |
| 846 | } | 912 | } |
| 847 | 913 | ||
| @@ -1781,4 +1847,202 @@ HcclResult HcomOpsKernelBuilder::SetHcomOpParam(const ge::Node &node, HcomOpPara | |||
| 1781 | hcomOpParam->groupList, hcomOpParam->groupListSize, hcomOpParam->rankTable); | 1847 | hcomOpParam->groupList, hcomOpParam->groupListSize, hcomOpParam->rankTable); |
| 1782 | return HCCL_SUCCESS; | 1848 | return HCCL_SUCCESS; |
| 1783 | } | 1849 | } |
| 1850 | + | ||
| 1851 | +HcclResult HcomOpsKernelBuilder::SetHcclOpParam(const ge::Node &node, HcomOpParam *hcomOpParam, OpParamGraphModePtr opParamPtr, std::string &sCollectiveType, | ||
| 1852 | + std::vector<int64_t> &sendCounts, std::vector<int64_t> &sendDispls, | ||
| 1853 | + std::vector<int64_t> &recvCounts, std::vector<int64_t> &recvDispls, const char* group) { | ||
| 1854 | + HCCL_INFO("[Calc][SetHcclOpParam] with [%s].", sCollectiveType.c_str()); | ||
| 1855 | + HcclResult ret; | ||
| 1856 | + sCollectiveType = node.GetOpDesc()->GetType(); | ||
| 1857 | + ret = CheckSupportedOP(sCollectiveType); | ||
| 1858 | + CHK_PRT_RET( | ||
| 1859 | + ret != HCCL_SUCCESS, | ||
| 1860 | + HCCL_ERROR("[HcomOpsKernelBuilder][OpRunningParam]errNo[0x%016llx] op type[%s] is not supported.", ret, sCollectiveType.c_str()), | ||
| 1861 | + HCCL_E_NOT_SUPPORT); | ||
| 1862 | + // 补充参数 | ||
| 1863 | + u64 count = 0; | ||
| 1864 | + void* counts = nullptr; | ||
| 1865 | + HcclDataType dataType = HCCL_DATA_TYPE_RESERVED; | ||
| 1866 | + HcclReduceOp reduction = HcclReduceOp::HCCL_REDUCE_SUM; | ||
| 1867 | + HcclCMDType opTypeAiv = HcclCMDType::HCCL_CMD_INVALID; | ||
| 1868 | + u32 aivCoreLimit = 0; | ||
| 1869 | + bool ifAiv = false; | ||
| 1870 | + | ||
| 1871 | + // 计算Aiv参数 | ||
| 1872 | + CHK_RET(GetAivParam(node, sCollectiveType, group, count, dataType, reduction, opTypeAiv, aivCoreLimit, ifAiv)); | ||
| 1873 | + // 设置aiv参数 | ||
| 1874 | + ret = HcceSetAivSelectOpParamGraphMode(opParamPtr, group, count, counts, dataType, reduction, opTypeAiv, aivCoreLimit, ifAiv); | ||
| 1875 | + CHK_PRT_RET( | ||
| 1876 | + ret != HCCL_SUCCESS, | ||
| 1877 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set aivParam failed.", HCOM_ERROR_CODE(ret)), | ||
| 1878 | + ret); | ||
| 1879 | + // 设置 opType | ||
| 1880 | + ret = HcceSetOpParamGraphModeOpType(opParamPtr, sCollectiveType.c_str()); | ||
| 1881 | + CHK_PRT_RET( | ||
| 1882 | + ret != HCCL_SUCCESS, | ||
| 1883 | + HCCL_ERROR("[HcomOpsKernelBuilder][OpRunningParam]errNo[0x%016llx] set op type[%s] failed.", HCOM_ERROR_CODE(ret), sCollectiveType.c_str()), | ||
| 1884 | + ret); | ||
| 1885 | + | ||
| 1886 | + // 补充参数 | ||
| 1887 | + ret = HcomOpUtils::ConversionOpDataType(node.GetOpDesc(), sCollectiveType, dataType); | ||
| 1888 | + CHK_PRT_RET( | ||
| 1889 | + ret != HCCL_SUCCESS, | ||
| 1890 | + HCCL_ERROR("[Get][OpWorkspaceMemSize]op[%s]: get data type failed. ret[%d]", sCollectiveType.c_str(), ret), ret); | ||
| 1891 | + | ||
| 1892 | + ret = HcceSetOpParamGraphModeDataType(opParamPtr, dataType); | ||
| 1893 | + CHK_PRT_RET( | ||
| 1894 | + ret != HCCL_SUCCESS, | ||
| 1895 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set data type failed.", HCOM_ERROR_CODE(ret)), | ||
| 1896 | + ret); | ||
| 1897 | + | ||
| 1898 | + // 设置 rankSize | ||
| 1899 | + int64_t hcomComm = 0; | ||
| 1900 | + std::string sGroup; | ||
| 1901 | + ret = GetCommFromOpDesc(node.GetOpDesc(), hcomComm, sGroup); | ||
| 1902 | + CHK_PRT_RET( | ||
| 1903 | + ret != HCCL_SUCCESS, | ||
| 1904 | + HCCL_ERROR("[Get][OpWorkspaceMemSize]op[%s]: GetGroupFromOpDesc failed. ret[%d]", sCollectiveType.c_str(), ret), | ||
| 1905 | + ret); | ||
| 1906 | + if (hcomComm != static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | ||
| 1907 | + CHK_RET(GetGroupNameByOpBaseHcom(hcomComm, &(hcomOpParam->group))); | ||
| 1908 | + } else { | ||
| 1909 | + hcomOpParam->group = const_cast<char *>(sGroup.c_str()); | ||
| 1910 | + } | ||
| 1911 | + | ||
| 1912 | + u32 rankSize = 0; | ||
| 1913 | + if (!IsOfflineCompilation()) { | ||
| 1914 | + if (hcomComm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | ||
| 1915 | + CHK_RET(HcomGetRankSize(sGroup.c_str(), &rankSize)); | ||
| 1916 | + } else { | ||
| 1917 | + char *group = nullptr; | ||
| 1918 | + CHK_RET(GetGroupNameByOpBaseHcom(hcomComm, &group)); | ||
| 1919 | + CHK_RET(HcomGetRankSize(group, &rankSize)); | ||
| 1920 | + } | ||
| 1921 | + } else { | ||
| 1922 | + // 离线编译ranksize在HcomCalcOpResOffline中计算 | ||
| 1923 | + } | ||
| 1924 | + if ((sCollectiveType == HCCL_KERNEL_OP_TYPE_REDUCESCATTER) || (sCollectiveType == HCCL_KERNEL_OP_TYPE_ALLGATHER)) { | ||
| 1925 | + CHK_PRT_RET((!ge::AttrUtils::GetInt(node.GetOpDesc(), HCOM_ATTR_RANK_SIZE, rankSize)), | ||
| 1926 | + HCCL_ERROR("[Get][OpWorkspaceMemSize]op[%s] get attr[%s] failed.", sCollectiveType.c_str(), | ||
| 1927 | + HCOM_ATTR_RANK_SIZE.c_str()), | ||
| 1928 | + HCCL_E_PARA); | ||
| 1929 | + CHK_PRT_RET((rankSize <= 0), | ||
| 1930 | + HCCL_ERROR("[Get][OpWorkspaceMemSize]op[%s]: rank_size[%d] should be " | ||
| 1931 | + "greater than 0.", | ||
| 1932 | + sCollectiveType.c_str(), rankSize), | ||
| 1933 | + HCCL_E_PARA); | ||
| 1934 | + } | ||
| 1935 | + ret = HcceSetOpParamGraphModeRankSize(opParamPtr, &rankSize); | ||
| 1936 | + CHK_PRT_RET( | ||
| 1937 | + ret != HCCL_SUCCESS, | ||
| 1938 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set rank_size[%d] failed.", HCOM_ERROR_CODE(ret), rankSize), | ||
| 1939 | + ret); | ||
| 1940 | + ret = HcomOpUtils::GetAccuracyCountFromOpDesc(node.GetOpDesc(), sCollectiveType, dataType, count, rankSize); | ||
| 1941 | + HCCL_INFO("GetAccuracyCountFromOpDesc count[%d]", count); | ||
【接口使用】getcount和getaccuracycount都是为了计算count,但是getcount接口应该要日落了;getaccuracycount是更准确的计算方式 ![]() ![]() | |||
| 1942 | + CHK_PRT_RET(ret != HCCL_SUCCESS, | ||
| 1943 | + HCCL_ERROR("[Get][OpWorkspaceMemSize]op[%s]: get count failed. ret[%d]", sCollectiveType.c_str(), ret), | ||
| 1944 | + ret); | ||
| 1945 | + ret = HcceSetOpParamGraphModeDataCount(opParamPtr, &count); | ||
| 1946 | + HCCL_INFO("Count[%llu]", count); | ||
| 1947 | + CHK_PRT_RET( | ||
| 1948 | + ret != HCCL_SUCCESS, | ||
| 1949 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set count[%d] failed.", HCOM_ERROR_CODE(ret), count), | ||
| 1950 | + ret); | ||
| 1951 | + | ||
| 1952 | + if (sCollectiveType == HCCL_KERNEL_OP_TYPE_REDUCESCATTERV) { | ||
| 1953 | + // reducescatterv复用HcomOpParam的All2AllDataDes字段 | ||
| 1954 | + CHK_RET( | ||
| 1955 | + HcomOpUtils::GetReduceScatterVCountsDispl(const_cast<ge::Node &>(node), sendCounts, sendDispls, recvCounts)); | ||
| 1956 | + count = *std::max_element(sendCounts.begin(), sendCounts.end()); | ||
| 1957 | + ret = HcceSetOpParamGraphModeDataCount(opParamPtr, &count); | ||
| 1958 | + HCCL_INFO("REDUCESCATTERV Count[%llu]", count); | ||
| 1959 | + CHK_PRT_RET( | ||
| 1960 | + ret != HCCL_SUCCESS, | ||
| 1961 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set count[%d] failed.", HCOM_ERROR_CODE(ret), count), | ||
| 1962 | + ret); | ||
| 1963 | + } | ||
| 1964 | + | ||
| 1965 | + if (sCollectiveType == HCCL_KERNEL_OP_TYPE_ALLGATHERV) { | ||
| 1966 | + // allgatherv复用HcomOpParam的All2AllDataDes字段 | ||
| 1967 | + CHK_RET(HcomOpUtils::GetAllGatherVCountsDispl(const_cast<ge::Node &>(node), sendCounts, recvCounts, recvDispls)); | ||
| 1968 | + count = *std::max_element(recvCounts.begin(), recvCounts.end()); | ||
| 1969 | + ret = HcceSetOpParamGraphModeDataCount(opParamPtr, &count); | ||
| 1970 | + HCCL_INFO("ALLGATHERV Count[%llu]", count); | ||
| 1971 | + CHK_PRT_RET( | ||
| 1972 | + ret != HCCL_SUCCESS, | ||
| 1973 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set count[%d] failed.", HCOM_ERROR_CODE(ret), count), | ||
| 1974 | + ret); | ||
| 1975 | + } | ||
| 1976 | + | ||
| 1977 | + if (sCollectiveType == HCCL_KERNEL_OP_TYPE_ALLTOALLV) { | ||
| 1978 | + HcclDataType sendType; | ||
| 1979 | + HcclDataType recvType; | ||
| 1980 | + CHK_RET(HcomOpUtils::GetAlltoAllDataType(node.GetOpDesc(), sendType, recvType)); | ||
| 1981 | + | ||
| 1982 | + auto op = node.GetOpDesc(); | ||
| 1983 | + if (ge::AttrUtils::HasAttr(op, "send_counts")) { | ||
| 1984 | + CHK_RET(HcomOpUtils::GetAlltoAllCountsDispl(op, sendCounts, sendDispls, recvCounts, recvDispls)); | ||
| 1985 | + } else { | ||
| 1986 | + CHK_RET(HcomOpUtils::GetAlltoAllCountsDispl(const_cast<ge::Node &>(node), sendCounts, sendDispls, recvCounts, | ||
| 1987 | + recvDispls)); | ||
| 1988 | + } | ||
| 1989 | + | ||
| 1990 | + if (sendCounts.size() < rankSize) { | ||
| 1991 | + HCCL_ERROR("[sendCounts] size[%u] is invalid, expect size: %llu", sendCounts.size(), rankSize); | ||
| 1992 | + return HCCL_E_PARA; | ||
| 1993 | + } | ||
| 1994 | + | ||
| 1995 | + count = *std::max_element(sendCounts.begin(), sendCounts.end()); | ||
| 1996 | + ret = HcceSetOpParamGraphModeDataCount(opParamPtr, &count); | ||
| 1997 | + HCCL_INFO("ALLTOALLV Count[%llu]", count); | ||
| 1998 | + CHK_PRT_RET( | ||
| 1999 | + ret != HCCL_SUCCESS, | ||
| 2000 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set count[%d] failed.", HCOM_ERROR_CODE(ret), count), | ||
| 2001 | + ret); | ||
| 2002 | + } | ||
| 2003 | + | ||
| 2004 | + // 获取cclbuffer size | ||
| 2005 | + u64 cclBuffSize; | ||
| 2006 | + CHK_RET(GetCCLBufferAvailableSize(cclBuffSize)); | ||
| 2007 | + ret = HcceSetOpParamGraphModeHCCLBufferSize(opParamPtr, &cclBuffSize); | ||
| 2008 | + CHK_PRT_RET( | ||
| 2009 | + ret != HCCL_SUCCESS, | ||
| 2010 | + HCCL_ERROR("[Calc][OpRunningParam]errNo[0x%016llx] set cclBuffSize[%llu] failed.", HCOM_ERROR_CODE(ret), cclBuffSize), | ||
| 2011 | + ret); | ||
| 2012 | + return HCCL_SUCCESS; | ||
| 2013 | +} | ||
| 2014 | + | ||
| 2015 | +HcclResult HcomOpsKernelBuilder::GetAivParam(const ge::Node &node, std::string &sCollectiveType, const char* group, | ||
| 2016 | + u64 &count, HcclDataType &dataType, HcclReduceOp &reduction, HcclCMDType &opType, | ||
| 2017 | + u32 &aivCoreLimit, bool ifAiv) { | ||
| 2018 | + CHK_RET(HcomOpUtils::GetAivCoreLimit(node.GetOpDesc(), sCollectiveType, aivCoreLimit)); | ||
| 2019 | + (void)ifAiv; | ||
| 2020 | + HcclResult ret; | ||
| 2021 | + u32 rankSize = 0; | ||
| 2022 | + CHK_RET(HcomGetRankSize(group, &rankSize)); | ||
| 2023 | + | ||
| 2024 | + ret = HcomOpUtils::ConversionOpDataType(node.GetOpDesc(), sCollectiveType, dataType); | ||
| 2025 | + CHK_PRT_RET( | ||
| 2026 | + ret != HCCL_SUCCESS, | ||
| 2027 | + HCCL_ERROR("[Get][SetSuperKernelScopeAttr]op[%s]: get data type failed. ret[%d]", sCollectiveType.c_str(), ret), | ||
| 2028 | + ret); | ||
| 2029 | + | ||
| 2030 | + ret = HcomOpUtils::GetCountFromOpDescSuperkernel(node.GetOpDesc(), sCollectiveType, dataType, count, rankSize); | ||
| 2031 | + CHK_PRT_RET( | ||
| 2032 | + ret != HCCL_SUCCESS, | ||
| 2033 | + HCCL_ERROR("[Get][SetSuperKernelScopeAttr]op[%s]: get count failed. ret[%d]", sCollectiveType.c_str(), ret), | ||
| 2034 | + ret); | ||
| 2035 | + | ||
| 2036 | + auto iter = HCCL_OPTYPE_NAME_MAP.find(sCollectiveType); | ||
| 2037 | + if (iter != HCCL_OPTYPE_NAME_MAP.end()) { | ||
| 2038 | + opType = iter->second; | ||
| 2039 | + } | ||
| 2040 | + | ||
| 2041 | + if (opType == HcclCMDType::HCCL_CMD_ALLREDUCE || opType == HcclCMDType::HCCL_CMD_REDUCE_SCATTER) { | ||
| 2042 | + CHK_RET(HcomOpUtils::GetReduction(node.GetOpDesc(), reduction)); | ||
| 2043 | + } | ||
| 2044 | + | ||
| 2045 | + return HCCL_SUCCESS; | ||
| 2046 | +} | ||
| 2047 | + | ||
| 1784 | } // namespace hccl | 2048 | } // namespace hccl |
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | + | ||
| 16 | 17 | ||
| 17 | namespace hccl { | 18 | namespace hccl { |
| 18 | class HcomOpsKernelBuilder : public HCCLOpsKernelBuilder { | 19 | class HcomOpsKernelBuilder : public HCCLOpsKernelBuilder { |
| @@ -35,6 +36,12 @@ class HcomOpsKernelBuilder : public HCCLOpsKernelBuilder { | |||
| 35 | std::vector<int64_t> &sendCounts, std::vector<int64_t> &sendDispls, | 36 | std::vector<int64_t> &sendCounts, std::vector<int64_t> &sendDispls, |
| 36 | std::vector<int64_t> &recvCounts, std::vector<int64_t> &recvDispls, | 37 | std::vector<int64_t> &recvCounts, std::vector<int64_t> &recvDispls, |
| 37 | std::vector<u32> &curRanks, std::string &rankTableStr, std::string &rankTableM); | 38 | std::vector<u32> &curRanks, std::string &rankTableStr, std::string &rankTableM); |
| 39 | + HcclResult SetHcclOpParam(const ge::Node &node, HcomOpParam *hcomOpParam, OpParamGraphModePtr opParam, std::string &sCollectiveType, | ||
| 40 | + std::vector<int64_t> &sendCounts, std::vector<int64_t> &sendDispls, | ||
| 41 | + std::vector<int64_t> &recvCounts, std::vector<int64_t> &recvDispls, const char* group); | ||
| 42 | + HcclResult GetAivParam(const ge::Node &node, std::string &sCollectiveType, const char* group, | ||
| 43 | + u64 &count, HcclDataType &dataType, HcclReduceOp &reduction, HcclCMDType &opType, | ||
| 44 | + u32 &aivCoreLimit, bool ifAiv); | ||
| 38 | HcclResult SetOpWorkerSpaceForKnowShape(ge::Node &node, u64 &opMemSize); | 45 | HcclResult SetOpWorkerSpaceForKnowShape(ge::Node &node, u64 &opMemSize); |
| 39 | HcclResult GetSupportedOP(std::vector<std::string> &hcclSupportOp) const override; | 46 | HcclResult GetSupportedOP(std::vector<std::string> &hcclSupportOp) const override; |
| 40 | HcclResult SetOpMemAttr(ge::Node &node, const std::string &sCollectiveType, const u64 &opMemSize) override; | 47 | HcclResult SetOpMemAttr(ge::Node &node, const std::string &sCollectiveType, const u64 &opMemSize) override; |
| @@ -99,6 +106,10 @@ class HcomOpsKernelBuilder : public HCCLOpsKernelBuilder { | |||
| 99 | HcclResult SetAttachedStreamInfoList(ge::Node &node, const std::string &group); // 设置附属从流信息 | 106 | HcclResult SetAttachedStreamInfoList(ge::Node &node, const std::string &group); // 设置附属从流信息 |
| 100 | HcclResult TaskDefSetNumBlocks(const ge::Node &node, domi::TaskDef &taskDef, const std::string sCollectiveType, | 107 | HcclResult TaskDefSetNumBlocks(const ge::Node &node, domi::TaskDef &taskDef, const std::string sCollectiveType, |
| 101 | const u32 aivCoreLimit); | 108 | const u32 aivCoreLimit); |
| 109 | + HcclResult CalcOpRunningResources(const ge::Node &node, std::string &sCollectiveType, | ||
| 110 | + std::string &sGroup, u32 &streamNum, u64 &opMemSize, u32 &taskNum, u32 &aivCoreNum); | ||
| 111 | + HcclResult SetOpRunningParamAttributes(ge::Node &node, const std::string &sCollectiveType, | ||
| 112 | + const std::string &sGroup, u32 &streamNum, u64 opMemSize, u32 taskNum); | ||
| 102 | int32_t optionFeatureBaseRefreshable_; | 113 | int32_t optionFeatureBaseRefreshable_; |
| 103 | }; | 114 | }; |
| 104 | } // namespace hccl | 115 | } // namespace hccl |
Mcompiler/engines/hccl_engine/hcom_graph_adaptor/ge_plugin/hcom/hcom_ops_kernel_info_store.cc+588-166
| @@ -9,6 +9,8 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | + | ||
| 13 | + | ||
| 12 | 14 | ||
| 13 | 15 | ||
| 14 | 16 | ||
| @@ -109,48 +111,59 @@ HcclResult HcomOpsKernelInfoStore::GenerateOpTagFromTaskInfo(const ge::GETaskInf | |||
| 109 | CHK_RET(HcomGenerateCclOpTag(opType.c_str(), comm, group.c_str(), cTag)); | 111 | CHK_RET(HcomGenerateCclOpTag(opType.c_str(), comm, group.c_str(), cTag)); |
| 110 | sTag = cTag; | 112 | sTag = cTag; |
| 111 | } else if (opType == HCCL_KERNEL_OP_TYPE_SEND) { | 113 | } else if (opType == HCCL_KERNEL_OP_TYPE_SEND) { |
| 112 | - // Send/Receive 算子的 tag 为 group + sr_tag + src_rank + dest_rank | 114 | + // Send/Receive 算子的 tag 需一致(用于注册获取资源),为 "SendRecv" + srTag + srcRank + destRank + group name hash + op index in group |
| 113 | uint32_t srTag = privateDefBuf->srTag; | 115 | uint32_t srTag = privateDefBuf->srTag; |
| 114 | std::string sSrTag = std::to_string(srTag); | 116 | std::string sSrTag = std::to_string(srTag); |
| 115 | destRank = privateDefBuf->destRank; | 117 | destRank = privateDefBuf->destRank; |
| 118 | + std::string sSrcRank; | ||
| 116 | std::string sDestRank = std::to_string(destRank); | 119 | std::string sDestRank = std::to_string(destRank); |
| 117 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 120 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 118 | ret = HcomGetRankId(group.c_str(), &srcRank); | 121 | ret = HcomGetRankId(group.c_str(), &srcRank); |
| 119 | CHK_PRT_RET(ret != HCCL_SUCCESS, | 122 | CHK_PRT_RET(ret != HCCL_SUCCESS, |
| 120 | HCCL_ERROR("[Generate][OpTag]op[%s]: get rank id failed. ret[%d]", opType.c_str(), ret), ret); | 123 | HCCL_ERROR("[Generate][OpTag]op[%s]: get rank id failed. ret[%d]", opType.c_str(), ret), ret); |
| 121 | - std::string sSrcRank = std::to_string(srcRank); | 124 | + sSrcRank = std::to_string(srcRank); |
| 122 | - sTag = group + "_" + sSrTag + "_" + sSrcRank + "_" + sDestRank; | 125 | + HCCL_DEBUG("[Generate][OpTag][Send]: group[%s], srTag[%s], srcRank[%s], dstRank[%s]", group.c_str(), sSrTag.c_str(), sSrcRank.c_str(), sDestRank.c_str()); |
| 123 | } else { | 126 | } else { |
| 124 | char *groupname = nullptr; | 127 | char *groupname = nullptr; |
| 125 | CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 128 | CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); |
| 126 | ret = HcomGetRankId(groupname, &srcRank); | 129 | ret = HcomGetRankId(groupname, &srcRank); |
| 127 | CHK_PRT_RET(ret != HCCL_SUCCESS, | 130 | CHK_PRT_RET(ret != HCCL_SUCCESS, |
| 128 | HCCL_ERROR("[Generate][OpTag]op[%s]: get rank id failed. ret[%d]", opType.c_str(), ret), ret); | 131 | HCCL_ERROR("[Generate][OpTag]op[%s]: get rank id failed. ret[%d]", opType.c_str(), ret), ret); |
| 129 | - std::string sSrcRank = std::to_string(srcRank); | 132 | + sSrcRank = std::to_string(srcRank); |
| 130 | identifier = std::string(groupname); | 133 | identifier = std::string(groupname); |
| 131 | - sTag = identifier + "_" + sSrTag + "_" + sSrcRank + "_" + sDestRank; | 134 | + HCCL_DEBUG("[Generate][OpTag][Send]: identifier[%s], srTag[%s], srcRank[%s], dstRank[%s]", identifier.c_str(), sSrTag.c_str(), sSrcRank.c_str(), sDestRank.c_str()); |
| 132 | } | 135 | } |
| 136 | + std::string baseTag = "SendRecv_" + sSrTag + "_" + sSrcRank + "_" + sDestRank; | ||
| 137 | + char cTag[CCL_OP_TAG_MAX_LEN]; | ||
| 138 | + CHK_RET(HcomGenerateCclOpTag(baseTag.c_str(), comm, group.c_str(), cTag)); | ||
| 139 | + sTag = cTag; | ||
| 133 | } else if (opType == HCCL_KERNEL_OP_TYPE_RECEIVE) { | 140 | } else if (opType == HCCL_KERNEL_OP_TYPE_RECEIVE) { |
| 141 | + // Send/Receive 算子的 tag 需一致(用于注册获取资源),为 "SendRecv" + srTag + srcRank + destRank + group name hash + op index in group | ||
| 134 | uint32_t srTag = privateDefBuf->srTag; | 142 | uint32_t srTag = privateDefBuf->srTag; |
| 135 | std::string sSrTag = std::to_string(srTag); | 143 | std::string sSrTag = std::to_string(srTag); |
| 136 | srcRank = privateDefBuf->srcRank; | 144 | srcRank = privateDefBuf->srcRank; |
| 137 | std::string sSrcRank = std::to_string(srcRank); | 145 | std::string sSrcRank = std::to_string(srcRank); |
| 146 | + std::string sDestRank; | ||
| 138 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 147 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 139 | ret = HcomGetRankId(group.c_str(), &destRank); | 148 | ret = HcomGetRankId(group.c_str(), &destRank); |
| 140 | CHK_PRT_RET(ret != HCCL_SUCCESS, | 149 | CHK_PRT_RET(ret != HCCL_SUCCESS, |
| 141 | HCCL_ERROR("[Generate][OpTag]op[%s]: get rank id failed. ret[%d]", opType.c_str(), ret), ret); | 150 | HCCL_ERROR("[Generate][OpTag]op[%s]: get rank id failed. ret[%d]", opType.c_str(), ret), ret); |
| 142 | - std::string sDestRank = std::to_string(destRank); | 151 | + sDestRank = std::to_string(destRank); |
| 143 | - sTag = group + "_" + sSrTag + "_" + sSrcRank + "_" + sDestRank; | 152 | + HCCL_DEBUG("[Generate][OpTag][Recv]: group[%s], srTag[%s], srcRank[%s], dstRank[%s]", group.c_str(), sSrTag.c_str(), sSrcRank.c_str(), sDestRank.c_str()); |
| 144 | } else { | 153 | } else { |
| 145 | char *groupname = nullptr; | 154 | char *groupname = nullptr; |
| 146 | CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 155 | CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); |
| 147 | ret = HcomGetRankId(groupname, &destRank); | 156 | ret = HcomGetRankId(groupname, &destRank); |
| 148 | CHK_PRT_RET(ret != HCCL_SUCCESS, | 157 | CHK_PRT_RET(ret != HCCL_SUCCESS, |
| 149 | HCCL_ERROR("[Generate][OpTag]op[%s]: get rank id failed. ret[%d]", opType.c_str(), ret), ret); | 158 | HCCL_ERROR("[Generate][OpTag]op[%s]: get rank id failed. ret[%d]", opType.c_str(), ret), ret); |
| 150 | - std::string sDestRank = std::to_string(destRank); | 159 | + sDestRank = std::to_string(destRank); |
| 151 | identifier = std::string(groupname); | 160 | identifier = std::string(groupname); |
| 152 | - sTag = identifier + "_" + sSrTag + "_" + sSrcRank + "_" + sDestRank; | 161 | + HCCL_DEBUG("[Generate][OpTag][Recv]: identifier[%s], srTag[%s], srcRank[%s], dstRank[%s]", identifier.c_str(), sSrTag.c_str(), sSrcRank.c_str(), sDestRank.c_str()); |
| 153 | } | 162 | } |
| 163 | + std::string baseTag = "SendRecv_" + sSrTag + "_" + sSrcRank + "_" + sDestRank; | ||
| 164 | + char cTag[CCL_OP_TAG_MAX_LEN]; | ||
| 165 | + CHK_RET(HcomGenerateCclOpTag(baseTag.c_str(), comm, group.c_str(), cTag)); | ||
| 166 | + sTag = cTag; | ||
| 154 | } else { | 167 | } else { |
| 155 | HCCL_ERROR("[Generate][OpTag]errNo[0x%016llx] get tag name failed. op type[%s] is invalid.", | 168 | HCCL_ERROR("[Generate][OpTag]errNo[0x%016llx] get tag name failed. op type[%s] is invalid.", |
| 156 | HCOM_ERROR_CODE(HCCL_E_PARA), opType.c_str()); | 169 | HCOM_ERROR_CODE(HCCL_E_PARA), opType.c_str()); |
| @@ -414,6 +427,25 @@ void HcomOpsKernelInfoStore::GetAllGatherVParams(const ge::GETaskInfo &task, uin | |||
| 414 | } | 427 | } |
| 415 | } | 428 | } |
| 416 | 429 | ||
| 430 | +HcclResult HcomOpsKernelInfoStore::PrepareOpExecutionParams(const std::vector<std::string> &tagVec, | ||
| 431 | + const ge::GETaskKernelHcclInfo &hcclInfo, | ||
| 432 | + HcclOpExecResParams &resParams) { | ||
| 433 | + resParams.tag = tagVec[0]; | ||
| 434 | + | ||
| 435 | + CHK_RET(GetStreamsFromTaskInfo(hcclInfo, resParams.streams)); | ||
| 436 | + resParams.streamArray = nullptr; | ||
| 437 | + resParams.streamCount = resParams.streams.size(); | ||
| 438 | + if (resParams.streamCount > 0) { | ||
| 439 | + resParams.streamArray = resParams.streams.data(); | ||
| 440 | + } | ||
| 441 | + | ||
| 442 | + resParams.scratchMemAddr = nullptr; | ||
| 443 | + resParams.scratchMemSize = 0; | ||
| 444 | + CHK_RET(GetWorkSpaceTaskInfo(hcclInfo, &resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 445 | + | ||
| 446 | + return HCCL_SUCCESS; | ||
| 447 | +} | ||
| 448 | + | ||
| 417 | HcclResult HcomOpsKernelInfoStore::HcomAlltoAllVOpKernel(const ge::GETaskInfo &task, | 449 | HcclResult HcomOpsKernelInfoStore::HcomAlltoAllVOpKernel(const ge::GETaskInfo &task, |
| 418 | const std::vector<std::string> &tagVec) { | 450 | const std::vector<std::string> &tagVec) { |
| 419 | CHK_PRT_RET((task.kernelHcclInfo.size() != 1), | 451 | CHK_PRT_RET((task.kernelHcclInfo.size() != 1), |
| @@ -421,6 +453,7 @@ HcclResult HcomOpsKernelInfoStore::HcomAlltoAllVOpKernel(const ge::GETaskInfo &t | |||
| 421 | "size in HCOM should be 1", | 453 | "size in HCOM should be 1", |
| 422 | HCOM_ERROR_CODE(HCCL_E_PARA)), | 454 | HCOM_ERROR_CODE(HCCL_E_PARA)), |
| 423 | HCCL_E_PARA); | 455 | HCCL_E_PARA); |
| 456 | + ge::GETaskKernelHcclInfo hcclInfo = task.kernelHcclInfo[0]; // HCOM场景下只会有一个 | ||
| 424 | 457 | ||
| 425 | rtStream_t stream; | 458 | rtStream_t stream; |
| 426 | CHK_RET(GetStreamMainFromTaskInfo(task, stream)); | 459 | CHK_RET(GetStreamMainFromTaskInfo(task, stream)); |
| @@ -461,17 +494,31 @@ HcclResult HcomOpsKernelInfoStore::HcomAlltoAllVOpKernel(const ge::GETaskInfo &t | |||
| 461 | CHK_RET(GetCommCCLBuf(shapeType, comm, group, sendBufPtr, recvBufPtr)); | 494 | CHK_RET(GetCommCCLBuf(shapeType, comm, group, sendBufPtr, recvBufPtr)); |
| 462 | } | 495 | } |
| 463 | 496 | ||
| 464 | - if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 497 | + HcclOpExecResParams resParams; |
| 465 | - CHK_RET(HcomAlltoAllV(sendBufPtr, sendCounts, sendDispls, sendType, recvBufPtr, recvCounts, recvDispls, recvType, | 498 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); |
| 466 | - group.c_str(), stream, tagVec[0].c_str())); | ||
| 467 | - } else { | ||
| 468 | - char *groupname = nullptr; | ||
| 469 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | ||
| 470 | - CHK_RET(HcomAlltoAllV(sendBufPtr, sendCounts, sendDispls, sendType, recvBufPtr, recvCounts, recvDispls, recvType, | ||
| 471 | - groupname, stream, tagVec[0].c_str())); | ||
| 472 | - HCCL_DEBUG("[HcclCommGraph][Type]AlltoAllVOpKernel."); | ||
| 473 | - } | ||
| 474 | 499 | ||
| 500 | + const char *groupName = nullptr; | ||
| 501 | + if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | ||
| 502 | + groupName = group.c_str(); | ||
| 503 | + } else { | ||
| 504 | + char *tmp = nullptr; | ||
| 505 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); | ||
| 506 | + groupName = tmp; | ||
| 507 | + } | ||
| 508 | + HCCL_INFO("[HcomAlltoAllVOpKernel] groupName: [%s]", groupName); | ||
| 509 | + bool openSourceTag = false; | ||
| 510 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 511 | + if (openSourceTag) { | ||
| 512 | + HCCL_INFO("[HcomAlltoAllVOpKernel] enter opensource produce, call HcceAlltoAllVGraphMode"); | ||
| 513 | + CHK_RET(HcceAlltoAllVGraphMode( | ||
| 514 | + sendBufPtr, sendCounts, sendDispls, sendType, recvBufPtr, recvCounts, recvDispls, recvType, | ||
| 515 | + groupName, stream, resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 516 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 517 | + HCCL_INFO("[HcomAlltoAllVOpKernel] HcceAlltoAllVGraphMode end"); | ||
| 518 | + } else { | ||
| 519 | + CHK_RET(HcomAlltoAllV(sendBufPtr, sendCounts, sendDispls, sendType, recvBufPtr, recvCounts, recvDispls, recvType, | ||
| 520 | + groupName, stream, tagVec[0].c_str())); | ||
| 521 | + } | ||
| 475 | CHK_RET(RefreshOutputAddr(shapeType, comm, group, reinterpret_cast<void *>(recvBuf), outputMemSize, stream)); | 522 | CHK_RET(RefreshOutputAddr(shapeType, comm, group, reinterpret_cast<void *>(recvBuf), outputMemSize, stream)); |
| 476 | 523 | ||
| 477 | return HCCL_SUCCESS; | 524 | return HCCL_SUCCESS; |
| @@ -484,6 +531,7 @@ HcclResult HcomOpsKernelInfoStore::HcomAlltoAllOpKernel(const ge::GETaskInfo &ta | |||
| 484 | "size in HCOM should be 1", | 531 | "size in HCOM should be 1", |
| 485 | HCOM_ERROR_CODE(HCCL_E_PARA)), | 532 | HCOM_ERROR_CODE(HCCL_E_PARA)), |
| 486 | HCCL_E_PARA); | 533 | HCCL_E_PARA); |
| 534 | + ge::GETaskKernelHcclInfo hcclInfo = task.kernelHcclInfo[0]; // HCOM场景下只会有一个 | ||
| 487 | 535 | ||
| 488 | std::string group; | 536 | std::string group; |
| 489 | CHK_RET(GetGroupFromTaskInfo(task, group)); | 537 | CHK_RET(GetGroupFromTaskInfo(task, group)); |
| @@ -499,10 +547,10 @@ HcclResult HcomOpsKernelInfoStore::HcomAlltoAllOpKernel(const ge::GETaskInfo &ta | |||
| 499 | CHK_RET(HcomGetRankSize(groupname, &rankSize)); | 547 | CHK_RET(HcomGetRankSize(groupname, &rankSize)); |
| 500 | } | 548 | } |
| 501 | 549 | ||
| 502 | - void *sendBuf = task.kernelHcclInfo[0].inputDataAddr; | 550 | + void *sendBuf = hcclInfo.inputDataAddr; |
| 503 | - void *recvBuf = task.kernelHcclInfo[0].outputDataAddr; | 551 | + void *recvBuf = hcclInfo.outputDataAddr; |
| 504 | - u64 sendCount = task.kernelHcclInfo[0].count / rankSize; | 552 | + u64 sendCount = hcclInfo.count / rankSize; |
| 505 | - u64 recvCount = task.kernelHcclInfo[0].count / rankSize; | 553 | + u64 recvCount = hcclInfo.count / rankSize; |
| 506 | HcclDataType sendType; | 554 | HcclDataType sendType; |
| 507 | CHK_RET(GetDataTypeFromTaskInfo(task, sendType)); | 555 | CHK_RET(GetDataTypeFromTaskInfo(task, sendType)); |
| 508 | HcclDataType recvType; | 556 | HcclDataType recvType; |
| @@ -510,10 +558,27 @@ HcclResult HcomOpsKernelInfoStore::HcomAlltoAllOpKernel(const ge::GETaskInfo &ta | |||
| 510 | rtStream_t stream; | 558 | rtStream_t stream; |
| 511 | CHK_RET(GetStreamMainFromTaskInfo(task, stream)); | 559 | CHK_RET(GetStreamMainFromTaskInfo(task, stream)); |
| 512 | 560 | ||
| 561 | + HcclOpExecResParams resParams; | ||
| 562 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); | ||
| 563 | + | ||
| 513 | HCCL_DEBUG("[AlltoAllOp][Kernel] totalCount[%llu] rankSize[%u] sendCount[%llu] recvCount[%llu]", | 564 | HCCL_DEBUG("[AlltoAllOp][Kernel] totalCount[%llu] rankSize[%u] sendCount[%llu] recvCount[%llu]", |
| 514 | - task.kernelHcclInfo[0].count, rankSize, sendCount, recvCount); | 565 | + hcclInfo.count, rankSize, sendCount, recvCount); |
| 515 | - CHK_RET(HcomAllToAll(sendBuf, sendCount, sendType, recvBuf, recvCount, recvType, group.c_str(), stream, | 566 | + |
| 516 | - tagVec[0].c_str())); | 567 | + const char* groupName = group.c_str(); |
| 568 | + HCCL_INFO("[HcomAlltoAllOpKernel] groupName: [%s]", groupName); | ||
| 569 | + bool openSourceTag = false; | ||
| 570 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 571 | + if (openSourceTag) { | ||
| 572 | + HCCL_INFO("[HcomAlltoAllOpKernel] enter opensource produce, call HcceAlltoAllGraphMode"); | ||
| 573 | + CHK_RET(HcceAlltoAllGraphMode( | ||
| 574 | + sendBuf, sendCount, sendType, recvBuf, recvCount, recvType, groupName, stream, | ||
| 575 | + resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 576 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 577 | + HCCL_INFO("[HcomAlltoAllOpKernel] HcceAlltoAllGraphMode end"); | ||
| 578 | + } else { | ||
| 579 | + CHK_RET(HcomAllToAll(sendBuf, sendCount, sendType, recvBuf, recvCount, recvType, groupName, stream, | ||
| 580 | + tagVec[0].c_str())); | ||
| 581 | + } | ||
| 517 | return HCCL_SUCCESS; | 582 | return HCCL_SUCCESS; |
| 518 | } | 583 | } |
| 519 | 584 | ||
| @@ -524,6 +589,7 @@ HcclResult HcomOpsKernelInfoStore::HcomAlltoAllVCOpKernel(const ge::GETaskInfo & | |||
| 524 | "size in HCOM should be 1", | 589 | "size in HCOM should be 1", |
| 525 | HCOM_ERROR_CODE(HCCL_E_PARA)), | 590 | HCOM_ERROR_CODE(HCCL_E_PARA)), |
| 526 | HCCL_E_PARA); | 591 | HCCL_E_PARA); |
| 592 | + ge::GETaskKernelHcclInfo hcclInfo = task.kernelHcclInfo[0]; // HCOM场景下只会有一个 | ||
| 527 | 593 | ||
| 528 | rtStream_t stream; | 594 | rtStream_t stream; |
| 529 | CHK_RET(GetStreamMainFromTaskInfo(task, stream)); | 595 | CHK_RET(GetStreamMainFromTaskInfo(task, stream)); |
| @@ -560,15 +626,30 @@ HcclResult HcomOpsKernelInfoStore::HcomAlltoAllVCOpKernel(const ge::GETaskInfo & | |||
| 560 | CHK_RET(GetCommCCLBuf(shapeType, comm, group, sendBufPtr, recvBufPtr)); | 626 | CHK_RET(GetCommCCLBuf(shapeType, comm, group, sendBufPtr, recvBufPtr)); |
| 561 | } | 627 | } |
| 562 | 628 | ||
| 629 | + HcclOpExecResParams resParams; | ||
| 630 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); | ||
| 631 | + | ||
| 632 | + const char* groupName = nullptr; | ||
| 563 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 633 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 564 | - CHK_RET(HcomAlltoAllVC(sendBufPtr, sendCountMatrix, sendType, recvBufPtr, recvType, group.c_str(), stream, | 634 | + groupName = group.c_str(); |
| 565 | - tagVec[0].c_str())); | ||
| 566 | } else { | 635 | } else { |
| 567 | - char *sGroup = nullptr; | 636 | + char *tmp = nullptr; |
| 568 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &sGroup)); | 637 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 569 | - CHK_RET( | 638 | + groupName = tmp; |
| 570 | - HcomAlltoAllVC(sendBufPtr, sendCountMatrix, sendType, recvBufPtr, recvType, sGroup, stream, tagVec[0].c_str())); | 639 | + } |
| 571 | - HCCL_DEBUG("[HcclCommGraph][Type]AlltoAllVCOpKernel."); | 640 | + HCCL_INFO("[HcomAlltoAllVCOpKernel] groupName: [%s]", groupName); |
| 641 | + bool openSourceTag = false; | ||
| 642 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 643 | + if (openSourceTag) { | ||
| 644 | + HCCL_INFO("[HcomAlltoAllVCOpKernel] enter opensource produce, call HcceAlltoAllVCGraphMode"); | ||
| 645 | + CHK_RET(HcceAlltoAllVCGraphMode( | ||
| 646 | + sendBufPtr, sendCountMatrix, sendType, recvBufPtr, recvType, | ||
| 647 | + groupName, stream, resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 648 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 649 | + HCCL_INFO("[HcomAlltoAllVCOpKernel] HcceAlltoAllVCGraphMode end"); | ||
| 650 | + } else { | ||
| 651 | + CHK_RET(HcomAlltoAllVC( | ||
| 652 | + sendBufPtr, sendCountMatrix, sendType, recvBufPtr, recvType, groupName, stream, tagVec[0].c_str())); | ||
| 572 | } | 653 | } |
| 573 | 654 | ||
| 574 | CHK_RET(RefreshOutputAddr(shapeType, comm, group, reinterpret_cast<void *>(recvBuf), outputMemSize, stream)); | 655 | CHK_RET(RefreshOutputAddr(shapeType, comm, group, reinterpret_cast<void *>(recvBuf), outputMemSize, stream)); |
| @@ -752,21 +833,37 @@ HcclResult HcomOpsKernelInfoStore::HcomAllReduceOpKernel(const ge::GETaskInfo &t | |||
| 752 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); | 833 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); |
| 753 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); | 834 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); |
| 754 | 835 | ||
| 836 | + HcclOpExecResParams resParams; | ||
| 837 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); | ||
| 838 | + | ||
| 755 | if (task.needRefresh) { | 839 | if (task.needRefresh) { |
| 756 | CHK_RET(HcomAllReduceLoop(task, tagVec, shapeType, comm, group, inputDataPtr, outputDataPtr, count, dataType, | 840 | CHK_RET(HcomAllReduceLoop(task, tagVec, shapeType, comm, group, inputDataPtr, outputDataPtr, count, dataType, |
| 757 | - reduceType, streamMain)); | 841 | + reduceType, streamMain, resParams)); |
| 758 | } else { | 842 | } else { |
| 759 | CHK_RET(CleanIntervalMemoryOpKernel(task, tagVec[0], reinterpret_cast<uintptr_t>(inputDataPtr), 0, streamMain, | 843 | CHK_RET(CleanIntervalMemoryOpKernel(task, tagVec[0], reinterpret_cast<uintptr_t>(inputDataPtr), 0, streamMain, |
| 760 | HcclCMDType::HCCL_CMD_ALLREDUCE)); | 844 | HcclCMDType::HCCL_CMD_ALLREDUCE)); |
| 761 | 845 | ||
| 846 | + const char *groupName = nullptr; | ||
| 762 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 847 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 763 | - CHK_RET(HcomAllReduce(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, reduceType, group.c_str(), | 848 | + groupName = group.c_str(); |
| 764 | - streamMain)); | 849 | + |
| 765 | } else { | 850 | } else { |
| 766 | - char *groupname = nullptr; | 851 | + char *tmp = nullptr; |
| 767 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 852 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 768 | - CHK_RET(HcomAllReduce(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, reduceType, groupname, | 853 | + groupName = tmp; |
| 769 | - streamMain)); | 854 | + } |
| 855 | + HCCL_INFO("[HcomAllReduceOpKernel] groupName: [%s]", groupName); | ||
| 856 | + bool openSourceTag = false; | ||
| 857 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 858 | + if (openSourceTag) { | ||
| 859 | + HCCL_INFO("[HcomAllReduceOpKernel] enter opensource produce, call HcceAllReduceGraphMode"); | ||
| 860 | + CHK_RET(HcceAllReduceGraphMode( | ||
| 861 | + inputDataPtr, outputDataPtr, count, dataType, reduceType, groupName, streamMain, | ||
| 862 | + resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 863 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 864 | + HCCL_INFO("[HcomAllReduceOpKernel] HcceAllReduceGraphMode end"); | ||
| 865 | + } else { | ||
| 866 | + CHK_RET(HcomAllReduce(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, reduceType, groupName, streamMain)); | ||
| 770 | } | 867 | } |
| 771 | } | 868 | } |
| 772 | 869 | ||
| @@ -802,11 +899,10 @@ HcclResult HcomOpsKernelInfoStore::HcomAllReduceLoop(const ge::GETaskInfo &task, | |||
| 802 | u32 shapeType, const int64_t &comm, const std::string &group, | 899 | u32 shapeType, const int64_t &comm, const std::string &group, |
| 803 | void *&inputDataPtr, void *&outputDataPtr, u64 count, | 900 | void *&inputDataPtr, void *&outputDataPtr, u64 count, |
| 804 | HcclDataType dataType, HcclReduceOp reduceType, | 901 | HcclDataType dataType, HcclReduceOp reduceType, |
| 805 | - rtStream_t streamMain) { | 902 | + rtStream_t streamMain, HcclOpExecResParams &resParams) { |
| 806 | // 获取 in ccl buf | 903 | // 获取 in ccl buf |
| 807 | u64 commInputSize; | 904 | u64 commInputSize; |
| 808 | CHK_RET(GetHcomInCCLbufferSize(commInputSize, shapeType, comm, group)); | 905 | CHK_RET(GetHcomInCCLbufferSize(commInputSize, shapeType, comm, group)); |
| 809 | - | ||
| 810 | // 计算出cclbuffer支持最大的count数量 | 906 | // 计算出cclbuffer支持最大的count数量 |
| 811 | u32 unitSize = SIZE_TABLE[dataType]; | 907 | u32 unitSize = SIZE_TABLE[dataType]; |
| 812 | u64 maxCountPerLoop = commInputSize / unitSize; // ccl buffer内存单次最多能够接受的input count | 908 | u64 maxCountPerLoop = commInputSize / unitSize; // ccl buffer内存单次最多能够接受的input count |
| @@ -853,14 +949,28 @@ HcclResult HcomOpsKernelInfoStore::HcomAllReduceLoop(const ge::GETaskInfo &task, | |||
| 853 | } | 949 | } |
| 854 | 950 | ||
| 855 | // 执行 hcom 算子 | 951 | // 执行 hcom 算子 |
| 952 | + const char *groupName = nullptr; | ||
| 856 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 953 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 857 | - CHK_RET(HcomAllReduce(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, reduceType, | 954 | + groupName = group.c_str(); |
| 858 | - group.c_str(), streamMain)); | 955 | + |
| 859 | } else { | 956 | } else { |
| 860 | - char *groupname = nullptr; | 957 | + char *tmp = nullptr; |
| 861 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 958 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 862 | - CHK_RET(HcomAllReduce(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, reduceType, | 959 | + groupName = tmp; |
| 863 | - groupname, streamMain)); | 960 | + } |
| 961 | + | ||
| 962 | + HCCL_INFO("[HcomAllReduceLoop] groupName: [%s]", groupName); | ||
| 963 | + bool openSourceTag = false; | ||
| 964 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 965 | + if (openSourceTag) { | ||
| 966 | + HCCL_INFO("[HcomAllReduceLoop] enter opensource produce, call HcceAllReduceGraphMode"); | ||
| 967 | + | ||
| 968 | + CHK_RET(HcceAllReduceGraphMode( | ||
| 969 | + commInputPtr, commOutputPtr, curCount, dataType, reduceType, groupName, streamMain, tagVec[loopTime].c_str(), | ||
| 970 | + resParams.streamArray, resParams.streamCount, resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 971 | + HCCL_INFO("[HcomAllReduceLoop] HcceAllReduceGraphMode end"); | ||
| 972 | + } else { | ||
| 973 | + CHK_RET(HcomAllReduce(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, reduceType, groupName, streamMain)); | ||
| 864 | } | 974 | } |
| 865 | 975 | ||
| 866 | // 将结果拷回二级指针上 | 976 | // 将结果拷回二级指针上 |
| @@ -914,21 +1024,36 @@ HcclResult HcomOpsKernelInfoStore::HcomAllGatherOpKernel(const ge::GETaskInfo &t | |||
| 914 | 1024 | ||
| 915 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); | 1025 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); |
| 916 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); | 1026 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); |
| 917 | - | 1027 | + |
| 1028 | + HcclOpExecResParams resParams; | ||
| 1029 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); | ||
| 1030 | + | ||
| 918 | if (task.needRefresh) { | 1031 | if (task.needRefresh) { |
| 919 | CHK_RET( | 1032 | CHK_RET( |
| 920 | - HcomAllGatherLoop(tagVec, shapeType, comm, group, inputDataPtr, outputDataPtr, count, dataType, streamMain)); | 1033 | + HcomAllGatherLoop(tagVec, shapeType, comm, group, inputDataPtr, outputDataPtr, count, dataType, streamMain, resParams)); |
| 921 | } else { | 1034 | } else { |
| 1035 | + const char *groupName = nullptr; | ||
| 922 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 1036 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 923 | - CHK_RET( | 1037 | + groupName = group.c_str(); |
| 924 | - HcomAllGather(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, group.c_str(), streamMain)); | ||
| 925 | } else { | 1038 | } else { |
| 926 | - char *groupname = nullptr; | 1039 | + char *tmp = nullptr; |
| 927 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 1040 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 928 | - CHK_RET(HcomAllGather(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, groupname, streamMain)); | 1041 | + groupName = tmp; |
| 1042 | + } | ||
| 1043 | + HCCL_INFO("[HcomAllGatherOpKernel] groupName: [%s]", groupName); | ||
| 1044 | + bool openSourceTag = false; | ||
| 1045 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 1046 | + if (openSourceTag) { | ||
| 1047 | + HCCL_INFO("[HcomAllGatherOpKernel] enter opensource produce, call HcceAllGatherGraphMode"); | ||
| 1048 | + CHK_RET(HcceAllGatherGraphMode( | ||
| 1049 | + inputDataPtr, outputDataPtr, count, dataType, groupName, streamMain, | ||
| 1050 | + resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 1051 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 1052 | + HCCL_INFO("[HcomAllGatherOpKernel] HcceAllGatherGraphMode end"); | ||
| 1053 | + } else { | ||
| 1054 | + CHK_RET(HcomAllGather(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, groupName, streamMain)); | ||
| 929 | } | 1055 | } |
| 930 | } | 1056 | } |
| 931 | - | ||
| 932 | return HCCL_SUCCESS; | 1057 | return HCCL_SUCCESS; |
| 933 | } | 1058 | } |
| 934 | 1059 | ||
| @@ -966,8 +1091,32 @@ HcclResult HcomOpsKernelInfoStore::HcomAllGatherVOpKernel(const ge::GETaskInfo & | |||
| 966 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); | 1091 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); |
| 967 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); | 1092 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); |
| 968 | 1093 | ||
| 969 | - CHK_RET(HcomAllGatherV(tagVec[0].c_str(), inputDataPtr, sendCount, outputDataPtr, recvCounts, recvDispls, dataType, | 1094 | + HcclOpExecResParams resParams; |
| 970 | - group.c_str(), streamMain)); | 1095 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); |
| 1096 | + | ||
| 1097 | + const char *groupName = nullptr; | ||
| 1098 | + if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | ||
| 1099 | + groupName = group.c_str(); | ||
| 1100 | + } else { | ||
| 1101 | + char *tmp = nullptr; | ||
| 1102 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); | ||
| 1103 | + groupName = tmp; | ||
| 1104 | + } | ||
| 1105 | + HCCL_INFO("[HcomAllGatherVOpKernel] groupName: [%s]", groupName); | ||
| 1106 | + bool openSourceTag = false; | ||
| 1107 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 1108 | + if (openSourceTag) { | ||
| 1109 | + HCCL_INFO("[HcomAllGatherVOpKernel] enter opensource produce, call HcceAllGatherVGraphMode"); | ||
| 1110 | + CHK_RET(HcceAllGatherVGraphMode( | ||
| 1111 | + inputDataPtr, outputDataPtr, sendCount, recvCounts, recvDispls, dataType, groupName, streamMain, | ||
| 1112 | + resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 1113 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 1114 | + HCCL_INFO("[HcomAllGatherVOpKernel] HcceAllGatherVGraphMode end"); | ||
| 1115 | + } else { | ||
| 1116 | + // 执行 hcom 算子 | ||
| 1117 | + CHK_RET(HcomAllGatherV(tagVec[0].c_str(), inputDataPtr, sendCount, outputDataPtr, recvCounts, recvDispls, dataType, | ||
| 1118 | + group.c_str(), streamMain)); | ||
| 1119 | + } | ||
| 971 | 1120 | ||
| 972 | return HCCL_SUCCESS; | 1121 | return HCCL_SUCCESS; |
| 973 | } | 1122 | } |
| @@ -975,7 +1124,7 @@ HcclResult HcomOpsKernelInfoStore::HcomAllGatherVOpKernel(const ge::GETaskInfo & | |||
| 975 | HcclResult HcomOpsKernelInfoStore::HcomAllGatherLoop(const std::vector<std::string> &tagVec, u32 shapeType, | 1124 | HcclResult HcomOpsKernelInfoStore::HcomAllGatherLoop(const std::vector<std::string> &tagVec, u32 shapeType, |
| 976 | const int64_t &comm, const std::string &group, void *&inputDataPtr, | 1125 | const int64_t &comm, const std::string &group, void *&inputDataPtr, |
| 977 | void *&outputDataPtr, u64 count, HcclDataType dataType, | 1126 | void *&outputDataPtr, u64 count, HcclDataType dataType, |
| 978 | - rtStream_t streamMain) { | 1127 | + rtStream_t streamMain, HcclOpExecResParams &resParams) { |
| 979 | // 获取 out ccl buf | 1128 | // 获取 out ccl buf |
| 980 | u64 commOutputSize; | 1129 | u64 commOutputSize; |
| 981 | GetHcomOutCCLbufferSize(commOutputSize, shapeType, comm, group); | 1130 | GetHcomOutCCLbufferSize(commOutputSize, shapeType, comm, group); |
| @@ -1026,14 +1175,25 @@ HcclResult HcomOpsKernelInfoStore::HcomAllGatherLoop(const std::vector<std::stri | |||
| 1026 | CHK_RET(GetCommCCLBuf(shapeType, comm, group, commInputPtr, commOutputPtr)); | 1175 | CHK_RET(GetCommCCLBuf(shapeType, comm, group, commInputPtr, commOutputPtr)); |
| 1027 | 1176 | ||
| 1028 | // 执行 hcom 算子 | 1177 | // 执行 hcom 算子 |
| 1178 | + const char *groupName = nullptr; | ||
| 1029 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 1179 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 1030 | - CHK_RET(HcomAllGather(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, group.c_str(), | 1180 | + groupName = group.c_str(); |
| 1031 | - streamMain)); | ||
| 1032 | } else { | 1181 | } else { |
| 1033 | - char *groupname = nullptr; | 1182 | + char *tmp = nullptr; |
| 1034 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 1183 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 1035 | - CHK_RET(HcomAllGather(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, groupname, | 1184 | + groupName = tmp; |
| 1036 | - streamMain)); | 1185 | + } |
| 1186 | + HCCL_INFO("[HcomAllGatherLoop] groupName: [%s]", groupName); | ||
| 1187 | + bool openSourceTag = false; | ||
| 1188 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 1189 | + if (openSourceTag) { | ||
| 1190 | + HCCL_INFO("[HcomAllGatherLoop] enter opensource produce, call HcceAllGatherGraphMode"); | ||
| 1191 | + // 准备 streams 参数 | ||
| 1192 | + CHK_RET(HcceAllGatherGraphMode(commInputPtr, commOutputPtr, curCount, dataType, groupName, streamMain, tagVec[loopTime].c_str(), | ||
| 1193 | + resParams.streamArray, resParams.streamCount, resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 1194 | + HCCL_INFO("[HcomAllGatherLoop] HcceAllGatherGraphMode end"); | ||
| 1195 | + } else { | ||
| 1196 | + CHK_RET(HcomAllGather(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, groupName, streamMain)); | ||
| 1037 | } | 1197 | } |
| 1038 | 1198 | ||
| 1039 | // 将结果拷回二级指针上 | 1199 | // 将结果拷回二级指针上 |
| @@ -1247,11 +1407,8 @@ HcclResult HcomOpsKernelInfoStore::HcomReduceScatterOpKernel(const ge::GETaskInf | |||
| 1247 | HcclReduceOp reduceType; | 1407 | HcclReduceOp reduceType; |
| 1248 | std::vector<void *> globalWorkSpaceAddr; | 1408 | std::vector<void *> globalWorkSpaceAddr; |
| 1249 | std::vector<ge::GETaskKernelHcclInfo> hcclInfos = task.kernelHcclInfo; | 1409 | std::vector<ge::GETaskKernelHcclInfo> hcclInfos = task.kernelHcclInfo; |
| 1250 | - CHK_PRT_RET((hcclInfos.size() != 1), | 1410 | + CHK_PRT_RET((hcclInfos.size() != 1), HCCL_ERROR("[ReduceScatterOp][Kernel]errNo[0x%016llx] GETaskInfo size" |
| 1251 | - HCCL_ERROR("[ReduceScatterOp][Kernel]errNo[0x%016llx] GETaskInfo size" | 1411 | + "in HCOM should be 1", HCOM_ERROR_CODE(HCCL_E_PARA)), HCCL_E_PARA); |
| 1252 | - "in HCOM should be 1", | ||
| 1253 | - HCOM_ERROR_CODE(HCCL_E_PARA)), | ||
| 1254 | - HCCL_E_PARA); | ||
| 1255 | ge::GETaskKernelHcclInfo hcclInfo = hcclInfos[0]; // HCOM场景下只会有一个 | 1412 | ge::GETaskKernelHcclInfo hcclInfo = hcclInfos[0]; // HCOM场景下只会有一个 |
| 1256 | 1413 | ||
| 1257 | // 获取 hcom api 必须的参数 | 1414 | // 获取 hcom api 必须的参数 |
| @@ -1277,22 +1434,37 @@ HcclResult HcomOpsKernelInfoStore::HcomReduceScatterOpKernel(const ge::GETaskInf | |||
| 1277 | 1434 | ||
| 1278 | CHK_RET(SetGlobalWorkSpace(comm, group, globalWorkSpaceAddr)); | 1435 | CHK_RET(SetGlobalWorkSpace(comm, group, globalWorkSpaceAddr)); |
| 1279 | 1436 | ||
| 1437 | + HcclOpExecResParams resParams; | ||
| 1438 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); | ||
| 1439 | + | ||
| 1280 | if (task.needRefresh) { | 1440 | if (task.needRefresh) { |
| 1281 | CHK_RET(HcomReduceScatterLoop(task, tagVec, shapeType, comm, group, inputDataPtr, outputDataPtr, count, dataType, | 1441 | CHK_RET(HcomReduceScatterLoop(task, tagVec, shapeType, comm, group, inputDataPtr, outputDataPtr, count, dataType, |
| 1282 | - reduceType, streamMain)); | 1442 | + reduceType, streamMain, resParams)); |
| 1283 | } else { | 1443 | } else { |
| 1284 | CHK_RET(CleanIntervalMemoryOpKernel(task, tagVec[0], reinterpret_cast<uintptr_t>(inputDataPtr), 0, streamMain, | 1444 | CHK_RET(CleanIntervalMemoryOpKernel(task, tagVec[0], reinterpret_cast<uintptr_t>(inputDataPtr), 0, streamMain, |
| 1285 | HcclCMDType::HCCL_CMD_REDUCE_SCATTER)); | 1445 | HcclCMDType::HCCL_CMD_REDUCE_SCATTER)); |
| 1286 | 1446 | ||
| 1287 | // 执行 hcom 算子 | 1447 | // 执行 hcom 算子 |
| 1448 | + const char *groupName = nullptr; | ||
| 1288 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 1449 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 1289 | - CHK_RET(HcomReduceScatter(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, reduceType, | 1450 | + groupName = group.c_str(); |
| 1290 | - group.c_str(), streamMain)); | ||
| 1291 | } else { | 1451 | } else { |
| 1292 | - char *groupname = nullptr; | 1452 | + char *tmp = nullptr; |
| 1293 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 1453 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 1294 | - CHK_RET(HcomReduceScatter(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, reduceType, groupname, | 1454 | + groupName = tmp; |
| 1295 | - streamMain)); | 1455 | + } |
| 1456 | + HCCL_INFO("[HcomReduceScatterOpKernel] groupName[%s]", groupName); | ||
| 1457 | + bool openSourceTag = false; | ||
| 1458 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 1459 | + if (openSourceTag) { | ||
| 1460 | + HCCL_INFO("[HcomReduceScatterOpKernel] enter opensource produce, call HcceReduceScatterGraphMode"); | ||
| 1461 | + CHK_RET(HcceReduceScatterGraphMode(inputDataPtr, outputDataPtr, count, dataType, reduceType, | ||
| 1462 | + groupName, streamMain, resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 1463 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 1464 | + HCCL_INFO("[HcomReduceScatterOpKernel] HcceReduceScatterGraphMode end"); | ||
| 1465 | + } else { | ||
| 1466 | + CHK_RET(HcomReduceScatter(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, reduceType, | ||
| 1467 | + group.c_str(), streamMain)); | ||
| 1296 | } | 1468 | } |
| 1297 | } | 1469 | } |
| 1298 | 1470 | ||
| @@ -1340,9 +1512,32 @@ HcclResult HcomOpsKernelInfoStore::HcomReduceScatterVOpKernel(const ge::GETaskIn | |||
| 1340 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); | 1512 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); |
| 1341 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); | 1513 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); |
| 1342 | 1514 | ||
| 1343 | - // 执行 hcom 算子 | 1515 | + HcclOpExecResParams resParams; |
| 1344 | - CHK_RET(HcomReduceScatterV(tagVec[0].c_str(), inputDataPtr, sendCounts, sendDispls, outputDataPtr, recvCount, | 1516 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); |
| 1345 | - dataType, reduceType, group.c_str(), streamMain)); | 1517 | + |
| 1518 | + const char *groupName = nullptr; | ||
| 1519 | + if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | ||
| 1520 | + groupName = group.c_str(); | ||
| 1521 | + } else { | ||
| 1522 | + char *tmp = nullptr; | ||
| 1523 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); | ||
| 1524 | + groupName = tmp; | ||
| 1525 | + } | ||
| 1526 | + HCCL_INFO("[HcomReduceScatterVOpKernel] groupName: [%s]", groupName); | ||
| 1527 | + bool openSourceTag = false; | ||
| 1528 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 1529 | + if (openSourceTag) { | ||
| 1530 | + HCCL_INFO("[HcomReduceScatterVOpKernel] enter opensource produce, call HcceReduceScatterVGraphMode"); | ||
| 1531 | + CHK_RET(HcceReduceScatterVGraphMode( | ||
| 1532 | + inputDataPtr, sendCounts, sendDispls, outputDataPtr, recvCount, dataType, reduceType, groupName, streamMain, | ||
| 1533 | + resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 1534 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 1535 | + HCCL_INFO("[HcomReduceScatterVOpKernel] HcceReduceScatterVGraphMode end"); | ||
| 1536 | + } else { | ||
| 1537 | + // 执行 hcom 算子 | ||
| 1538 | + CHK_RET(HcomReduceScatterV(tagVec[0].c_str(), inputDataPtr, sendCounts, sendDispls, outputDataPtr, recvCount, | ||
| 1539 | + dataType, reduceType, group.c_str(), streamMain)); | ||
| 1540 | + } | ||
| 1346 | 1541 | ||
| 1347 | return HCCL_SUCCESS; | 1542 | return HCCL_SUCCESS; |
| 1348 | } | 1543 | } |
| @@ -1352,7 +1547,7 @@ HcclResult HcomOpsKernelInfoStore::HcomReduceScatterLoop(const ge::GETaskInfo &t | |||
| 1352 | const int64_t &comm, const std::string &group, | 1547 | const int64_t &comm, const std::string &group, |
| 1353 | void *&inputDataPtr, void *&outputDataPtr, u64 count, | 1548 | void *&inputDataPtr, void *&outputDataPtr, u64 count, |
| 1354 | HcclDataType dataType, HcclReduceOp reduceType, | 1549 | HcclDataType dataType, HcclReduceOp reduceType, |
| 1355 | - rtStream_t streamMain) { | 1550 | + rtStream_t streamMain, HcclOpExecResParams &resParams) { |
| 1356 | // 获取 in ccl buf | 1551 | // 获取 in ccl buf |
| 1357 | u64 commInputSize; | 1552 | u64 commInputSize; |
| 1358 | CHK_RET(GetHcomInCCLbufferSize(commInputSize, shapeType, comm, group)); | 1553 | CHK_RET(GetHcomInCCLbufferSize(commInputSize, shapeType, comm, group)); |
| @@ -1419,15 +1614,26 @@ HcclResult HcomOpsKernelInfoStore::HcomReduceScatterLoop(const ge::GETaskInfo &t | |||
| 1419 | } | 1614 | } |
| 1420 | 1615 | ||
| 1421 | // 执行 hcom 算子 | 1616 | // 执行 hcom 算子 |
| 1617 | + const char *groupName = nullptr; | ||
| 1422 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 1618 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 1423 | - CHK_RET(HcomReduceScatter(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, reduceType, | 1619 | + groupName = group.c_str(); |
| 1424 | - group.c_str(), streamMain)); | ||
| 1425 | } else { | 1620 | } else { |
| 1426 | - char *groupname = nullptr; | 1621 | + char *tmp = nullptr; |
| 1427 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 1622 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 1428 | - CHK_RET(HcomReduceScatter(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, reduceType, groupname, | 1623 | + groupName = tmp; |
| 1429 | - streamMain)); | 1624 | + } |
| 1430 | - } | 1625 | + HCCL_INFO("[HcomReduceScatterLoop] groupName[%s]", groupName); |
| 1626 | + bool openSourceTag = false; | ||
| 1627 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 1628 | + if (openSourceTag) { | ||
| 1629 | + HCCL_INFO("[HcomReduceScatterLoop] enter opensource produce, call HcceReduceScatterGraphMode"); | ||
| 1630 | + CHK_RET(HcceReduceScatterGraphMode(commInputPtr, commOutputPtr, curCount, dataType, reduceType, | ||
| 1631 | + groupName, streamMain, tagVec[loopTime].c_str(), | ||
| 1632 | + resParams.streamArray, resParams.streamCount, resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 1633 | + } else { | ||
| 1634 | + CHK_RET(HcomReduceScatter(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, | ||
| 1635 | + reduceType, groupName, streamMain)); | ||
| 1636 | + } | ||
| 1431 | 1637 | ||
| 1432 | // 将结果拷回二级指针上 | 1638 | // 将结果拷回二级指针上 |
| 1433 | CHK_RET(RefreshOutputAddr(devType, shapeType, comm, group, outputDataPtr, outputOffset, curSize, outputMaxSize, | 1639 | CHK_RET(RefreshOutputAddr(devType, shapeType, comm, group, outputDataPtr, outputOffset, curSize, outputMaxSize, |
| @@ -1524,17 +1730,34 @@ HcclResult HcomOpsKernelInfoStore::HcomBroadcastOpKernel(const ge::GETaskInfo &t | |||
| 1524 | 1730 | ||
| 1525 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); | 1731 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); |
| 1526 | 1732 | ||
| 1733 | + HcclOpExecResParams resParams; | ||
| 1734 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); | ||
| 1735 | + | ||
| 1527 | if (task.needRefresh) { | 1736 | if (task.needRefresh) { |
| 1528 | - CHK_RET(HcomBroadcastLoop(tagVec, shapeType, comm, group, inputDataPtr, count, dataType, root, streamMain)); | 1737 | + CHK_RET(HcomBroadcastLoop(tagVec, shapeType, comm, group, inputDataPtr, count, dataType, root, streamMain, resParams)); |
| 1529 | } else { | 1738 | } else { |
| 1530 | // 执行 hcom 算子 | 1739 | // 执行 hcom 算子 |
| 1740 | + const char *groupName = nullptr; | ||
| 1531 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 1741 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 1532 | - CHK_RET(HcomBroadcast(tagVec[0].c_str(), inputDataPtr, count, dataType, root, group.c_str(), streamMain)); | 1742 | + groupName = group.c_str(); |
| 1533 | } else { | 1743 | } else { |
| 1534 | - char *groupname = nullptr; | 1744 | + char *tmp = nullptr; |
| 1535 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 1745 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 1536 | - CHK_RET(HcomBroadcast(tagVec[0].c_str(), inputDataPtr, count, dataType, root, groupname, streamMain)); | 1746 | + groupName = tmp; |
| 1537 | - } | 1747 | + } |
| 1748 | + HCCL_INFO("[HcomBroadcastOpKernel] groupName: [%s]", groupName); | ||
| 1749 | + bool openSourceTag = false; | ||
| 1750 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 1751 | + if (openSourceTag) { | ||
| 1752 | + HCCL_INFO("[HcomBroadcastOpKernel] enter opensource produce, call HcceBroadcastGraphMode"); | ||
| 1753 | + CHK_RET(HcceBroadcastGraphMode( | ||
| 1754 | + inputDataPtr, count, dataType, root, groupName, streamMain, | ||
| 1755 | + resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 1756 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 1757 | + HCCL_INFO("[HcomBroadcastOpKernel] HcceBroadcastGraphMode end"); | ||
| 1758 | + } else { | ||
| 1759 | + CHK_RET(HcomBroadcast(tagVec[0].c_str(), inputDataPtr, count, dataType, root, groupName, streamMain)); | ||
| 1760 | + } | ||
| 1538 | } | 1761 | } |
| 1539 | 1762 | ||
| 1540 | return HCCL_SUCCESS; | 1763 | return HCCL_SUCCESS; |
| @@ -1543,11 +1766,10 @@ HcclResult HcomOpsKernelInfoStore::HcomBroadcastOpKernel(const ge::GETaskInfo &t | |||
| 1543 | HcclResult HcomOpsKernelInfoStore::HcomBroadcastLoop(const std::vector<std::string> &tagVec, u32 shapeType, | 1766 | HcclResult HcomOpsKernelInfoStore::HcomBroadcastLoop(const std::vector<std::string> &tagVec, u32 shapeType, |
| 1544 | const int64_t &comm, const std::string &group, void *&inputDataPtr, | 1767 | const int64_t &comm, const std::string &group, void *&inputDataPtr, |
| 1545 | u64 count, HcclDataType dataType, u32 root, | 1768 | u64 count, HcclDataType dataType, u32 root, |
| 1546 | - rtStream_t streamMain) { | 1769 | + rtStream_t streamMain, HcclOpExecResParams &resParams) { |
| 1547 | // 获取 in ccl buf | 1770 | // 获取 in ccl buf |
| 1548 | u64 commInputSize; | 1771 | u64 commInputSize; |
| 1549 | CHK_RET(GetHcomInCCLbufferSize(commInputSize, shapeType, comm, group)); | 1772 | CHK_RET(GetHcomInCCLbufferSize(commInputSize, shapeType, comm, group)); |
| 1550 | - | ||
| 1551 | // 计算出cclbuffer支持最大的count数量 | 1773 | // 计算出cclbuffer支持最大的count数量 |
| 1552 | u32 unitSize = SIZE_TABLE[dataType]; | 1774 | u32 unitSize = SIZE_TABLE[dataType]; |
| 1553 | u64 maxCountPerLoop = commInputSize / unitSize; // ccl buffer内存单次最多能够接受的input count | 1775 | u64 maxCountPerLoop = commInputSize / unitSize; // ccl buffer内存单次最多能够接受的input count |
| @@ -1586,13 +1808,25 @@ HcclResult HcomOpsKernelInfoStore::HcomBroadcastLoop(const std::vector<std::stri | |||
| 1586 | CHK_RET(GetCommCCLBuf(shapeType, HCCL_KERNEL_OP_TYPE_BROADCAST, comm, group, commInputPtr)); | 1808 | CHK_RET(GetCommCCLBuf(shapeType, HCCL_KERNEL_OP_TYPE_BROADCAST, comm, group, commInputPtr)); |
| 1587 | 1809 | ||
| 1588 | // 执行 hcom 算子 | 1810 | // 执行 hcom 算子 |
| 1811 | + const char *groupName = nullptr; | ||
| 1589 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 1812 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 1590 | - CHK_RET( | 1813 | + groupName = group.c_str(); |
| 1591 | - HcomBroadcast(tagVec[loopTime].c_str(), commInputPtr, curCount, dataType, root, group.c_str(), streamMain)); | ||
| 1592 | } else { | 1814 | } else { |
| 1593 | - char *groupname = nullptr; | 1815 | + char *tmp = nullptr; |
| 1594 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 1816 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 1595 | - CHK_RET(HcomBroadcast(tagVec[loopTime].c_str(), commInputPtr, curCount, dataType, root, groupname, streamMain)); | 1817 | + groupName = tmp; |
| 1818 | + } | ||
| 1819 | + HCCL_INFO("[HcomBroadcastLoop] groupName: [%s]", groupName); | ||
| 1820 | + bool openSourceTag = false; | ||
| 1821 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 1822 | + if (openSourceTag) { | ||
| 1823 | + HCCL_INFO("[HcomBroadcastLoop] enter opensource produce, call HcceBroadcastGraphMode"); | ||
| 1824 | + CHK_RET(HcceBroadcastGraphMode( | ||
| 1825 | + commInputPtr, curCount, dataType, root, groupName, streamMain, tagVec[loopTime].c_str(), | ||
| 1826 | + resParams.streamArray, resParams.streamCount, resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 1827 | + HCCL_INFO("[HcomBroadcastLoop] HcceBroadcastGraphMode end"); | ||
| 1828 | + } else { | ||
| 1829 | + CHK_RET(HcomBroadcast(tagVec[loopTime].c_str(), commInputPtr, curCount, dataType, root, groupName, streamMain)); | ||
| 1596 | } | 1830 | } |
| 1597 | 1831 | ||
| 1598 | // 将结果拷回二级指针上 | 1832 | // 将结果拷回二级指针上 |
| @@ -1642,6 +1876,9 @@ HcclResult HcomOpsKernelInfoStore::HcomReduceOpKernel(const ge::GETaskInfo &task | |||
| 1642 | uintptr_t outputAddr = 0; | 1876 | uintptr_t outputAddr = 0; |
| 1643 | CHK_RET(GetOutputAddrFromTaskInfo(hcclInfo, outputAddr)); | 1877 | CHK_RET(GetOutputAddrFromTaskInfo(hcclInfo, outputAddr)); |
| 1644 | 1878 | ||
| 1879 | + HcclReduceOp reduceType; | ||
| 1880 | + CHK_RET(GetReduceTypeFromTaskInfo(hcclInfo, reduceType)); | ||
| 1881 | + | ||
| 1645 | u32 shapeType = 0; | 1882 | u32 shapeType = 0; |
| 1646 | // 动态shap地址刷新 | 1883 | // 动态shap地址刷新 |
| 1647 | CHK_RET(GetOriginalGraphShapeTypeFromTaskInfo(task, shapeType)); | 1884 | CHK_RET(GetOriginalGraphShapeTypeFromTaskInfo(task, shapeType)); |
| @@ -1653,23 +1890,37 @@ HcclResult HcomOpsKernelInfoStore::HcomReduceOpKernel(const ge::GETaskInfo &task | |||
| 1653 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); | 1890 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); |
| 1654 | 1891 | ||
| 1655 | CHK_RET(SetGlobalWorkSpace(comm, group, globalWorkSpaceAddr)); | 1892 | CHK_RET(SetGlobalWorkSpace(comm, group, globalWorkSpaceAddr)); |
| 1656 | - HcclReduceOp reduceType; | 1893 | + HcclOpExecResParams resParams; |
| 1657 | - CHK_RET(GetReduceTypeFromTaskInfo(hcclInfo, reduceType)); | 1894 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); |
| 1658 | 1895 | ||
| 1659 | if (task.needRefresh) { | 1896 | if (task.needRefresh) { |
| 1660 | CHK_RET(HcomReduceLoop(task, tagVec, shapeType, comm, group, inputDataPtr, outputDataPtr, count, dataType, | 1897 | CHK_RET(HcomReduceLoop(task, tagVec, shapeType, comm, group, inputDataPtr, outputDataPtr, count, dataType, |
| 1661 | - reduceType, root, streamMain)); | 1898 | + reduceType, root, streamMain, resParams)); |
| 1662 | } else { | 1899 | } else { |
| 1663 | CHK_RET(CleanIntervalMemoryOpKernel(task, tagVec[0], reinterpret_cast<uintptr_t>(inputDataPtr), 0, streamMain, | 1900 | CHK_RET(CleanIntervalMemoryOpKernel(task, tagVec[0], reinterpret_cast<uintptr_t>(inputDataPtr), 0, streamMain, |
| 1664 | HcclCMDType::HCCL_CMD_REDUCE)); | 1901 | HcclCMDType::HCCL_CMD_REDUCE)); |
| 1902 | + const char *groupName = nullptr; | ||
| 1665 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 1903 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 1666 | - CHK_RET(HcomReduce(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, reduceType, root, | 1904 | + groupName = group.c_str(); |
| 1667 | - group.c_str(), streamMain)); | 1905 | + |
| 1668 | } else { | 1906 | } else { |
| 1669 | - char *groupname = nullptr; | 1907 | + char *tmp = nullptr; |
| 1670 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 1908 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 1671 | - CHK_RET(HcomReduce(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, reduceType, root, groupname, | 1909 | + groupName = tmp; |
| 1672 | - streamMain)); | 1910 | + } |
| 1911 | + HCCL_INFO("[HcomReduceOpKernel] groupName: [%s]", groupName); | ||
| 1912 | + bool openSourceTag = false; | ||
| 1913 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 1914 | + if (openSourceTag) { | ||
| 1915 | + HCCL_INFO("[HcomReduceOpKernel] enter opensource produce, call HcceReduceGraphMode"); | ||
| 1916 | + CHK_RET(HcceReduceGraphMode( | ||
| 1917 | + inputDataPtr, outputDataPtr, count, dataType, reduceType, root, groupName, streamMain, | ||
| 1918 | + resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 1919 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 1920 | + HCCL_INFO("[HcomReduceOpKernel] HcceReduceGraphMode end"); | ||
| 1921 | + } else { | ||
| 1922 | + CHK_RET(HcomReduce(tagVec[0].c_str(), inputDataPtr, outputDataPtr, count, dataType, reduceType, root, | ||
| 1923 | + groupName, streamMain)); | ||
| 1673 | } | 1924 | } |
| 1674 | } | 1925 | } |
| 1675 | return HCCL_SUCCESS; | 1926 | return HCCL_SUCCESS; |
| @@ -1679,7 +1930,7 @@ HcclResult HcomOpsKernelInfoStore::HcomReduceLoop(const ge::GETaskInfo &task, co | |||
| 1679 | u32 shapeType, const int64_t &comm, const std::string &group, | 1930 | u32 shapeType, const int64_t &comm, const std::string &group, |
| 1680 | void *&inputDataPtr, void *&outputDataPtr, u64 count, | 1931 | void *&inputDataPtr, void *&outputDataPtr, u64 count, |
| 1681 | HcclDataType dataType, HcclReduceOp reduceType, u32 root, | 1932 | HcclDataType dataType, HcclReduceOp reduceType, u32 root, |
| 1682 | - rtStream_t streamMain) { | 1933 | + rtStream_t streamMain, HcclOpExecResParams &resParams) { |
| 1683 | // 获取 in ccl buf | 1934 | // 获取 in ccl buf |
| 1684 | u64 commInputSize; | 1935 | u64 commInputSize; |
| 1685 | CHK_RET(GetHcomInCCLbufferSize(commInputSize, shapeType, comm, group)); | 1936 | CHK_RET(GetHcomInCCLbufferSize(commInputSize, shapeType, comm, group)); |
| @@ -1743,15 +1994,29 @@ HcclResult HcomOpsKernelInfoStore::HcomReduceLoop(const ge::GETaskInfo &task, co | |||
| 1743 | CHK_RET(CleanIntervalMemoryOpKernel(task, tagVec[loopTime], reinterpret_cast<uintptr_t>(commInputPtr), | 1994 | CHK_RET(CleanIntervalMemoryOpKernel(task, tagVec[loopTime], reinterpret_cast<uintptr_t>(commInputPtr), |
| 1744 | inputOffset, streamMain, HcclCMDType::HCCL_CMD_REDUCE)); | 1995 | inputOffset, streamMain, HcclCMDType::HCCL_CMD_REDUCE)); |
| 1745 | } | 1996 | } |
| 1997 | + | ||
| 1746 | // 执行 hcom 算子 | 1998 | // 执行 hcom 算子 |
| 1999 | + const char *groupName = nullptr; | ||
| 1747 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 2000 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 1748 | - CHK_RET(HcomReduce(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, reduceType, root, | 2001 | + groupName = group.c_str(); |
| 1749 | - group.c_str(), streamMain)); | 2002 | + |
| 1750 | } else { | 2003 | } else { |
| 1751 | - char *groupname = nullptr; | 2004 | + char *tmp = nullptr; |
| 1752 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 2005 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 1753 | - CHK_RET(HcomReduce(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, reduceType, root, | 2006 | + groupName = tmp; |
| 1754 | - groupname, streamMain)); | 2007 | + } |
| 2008 | + | ||
| 2009 | + HCCL_INFO("[HcomReduceLoop] groupName: [%s]", groupName); | ||
| 2010 | + bool openSourceTag = false; | ||
| 2011 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 2012 | + if (openSourceTag) { | ||
| 2013 | + HCCL_INFO("[HcomReduceLoop] enter opensource produce, call HcceReduceGraphMode"); | ||
| 2014 | + CHK_RET(HcceReduceGraphMode( | ||
| 2015 | + commInputPtr, commOutputPtr, curCount, dataType, reduceType, root, groupName, streamMain, tagVec[loopTime].c_str(), | ||
| 2016 | + resParams.streamArray, resParams.streamCount, resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 2017 | + HCCL_INFO("[HcomReduceLoop] HcceReduceGraphMode end"); | ||
| 2018 | + } else { | ||
| 2019 | + CHK_RET(HcomReduce(tagVec[loopTime].c_str(), commInputPtr, commOutputPtr, curCount, dataType, reduceType, root, groupName, streamMain)); | ||
| 1755 | } | 2020 | } |
| 1756 | 2021 | ||
| 1757 | // 只root rank将结果拷回二级指针上 | 2022 | // 只root rank将结果拷回二级指针上 |
| @@ -1806,31 +2071,52 @@ HcclResult HcomOpsKernelInfoStore::HcomSendOpKernel(const ge::GETaskInfo &task, | |||
| 1806 | CHK_RET(GetOriginalGraphShapeTypeFromTaskInfo(task, shapeType)); | 2071 | CHK_RET(GetOriginalGraphShapeTypeFromTaskInfo(task, shapeType)); |
| 1807 | 2072 | ||
| 1808 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); | 2073 | void *inputDataPtr = reinterpret_cast<void *>(inputAddr); |
| 2074 | + | ||
| 2075 | + std::string groupName; | ||
| 2076 | + if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | ||
| 2077 | + groupName = group; | ||
| 2078 | + } else { | ||
| 2079 | + char *tmp = nullptr; | ||
| 2080 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); | ||
| 2081 | + groupName = tmp; | ||
| 2082 | + } | ||
| 2083 | + HCCL_INFO("[HcomSendOpKernel] groupName: [%s]", groupName.c_str()); | ||
| 2084 | + | ||
| 2085 | + // 准备执行参数 | ||
| 2086 | + HcclOpExecResParams resParams; | ||
| 2087 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); | ||
| 1809 | 2088 | ||
| 1810 | if (task.needRefresh) { | 2089 | if (task.needRefresh) { |
| 1811 | - CHK_RET(HcomSendLoop(tagVec, srTag, shapeType, comm, group, inputDataPtr, count, dataType, destRank, streamMain)); | 2090 | + CHK_RET(HcomSendLoop( |
| 2091 | + tagVec, srTag, shapeType, comm, group, inputDataPtr, count, dataType, destRank, | ||
| 2092 | + groupName, streamMain, resParams)); | ||
| 1812 | } else { | 2093 | } else { |
| 1813 | - // 执行 hcom 算子 | 2094 | + bool openSourceTag = false; |
| 1814 | - if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 2095 | + CHK_RET(IsUsingOpenSource(openSourceTag)); |
| 1815 | - CHK_RET(HcomSend(tagVec[0].c_str(), inputDataPtr, count, dataType, destRank, srTag, group.c_str(), streamMain)); | 2096 | + if (openSourceTag) { |
| 2097 | + HCCL_INFO("[HcomSendOpKernel] enter opensource produce, call HcceSendGraphMode"); | ||
| 2098 | + CHK_RET(HcceSendGraphMode( | ||
| 2099 | + inputDataPtr, count, dataType, destRank, groupName.c_str(), streamMain, | ||
| 2100 | + resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 2101 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 2102 | + HCCL_INFO("[HcomSendOpKernel] HcceSendGraphMode end"); | ||
| 1816 | } else { | 2103 | } else { |
| 1817 | - char *groupname = nullptr; | 2104 | + CHK_RET(HcomSend( |
| 1818 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 2105 | + tagVec[0].c_str(), inputDataPtr, count, dataType, destRank, srTag, groupName.c_str(), streamMain)); |
| 1819 | - CHK_RET(HcomSend(tagVec[0].c_str(), inputDataPtr, count, dataType, destRank, srTag, groupname, streamMain)); | ||
| 1820 | } | 2106 | } |
| 1821 | } | 2107 | } |
| 1822 | 2108 | ||
| 1823 | return HCCL_SUCCESS; | 2109 | return HCCL_SUCCESS; |
| 1824 | } | 2110 | } |
| 1825 | 2111 | ||
| 1826 | -HcclResult HcomOpsKernelInfoStore::HcomSendLoop(const std::vector<std::string> &tagVec, u32 &srTag, u32 shapeType, | 2112 | +HcclResult HcomOpsKernelInfoStore::HcomSendLoop( |
| 1827 | - const int64_t &comm, const std::string &group, void *&inputDataPtr, | 2113 | + const std::vector<std::string> &tagVec, u32 &srTag, u32 shapeType, const int64_t &comm, const std::string &group, |
| 1828 | - u64 count, HcclDataType dataType, u32 &destRank, | 2114 | + void *&inputDataPtr, u64 count, HcclDataType dataType, u32 &destRank, |
| 1829 | - rtStream_t streamMain) { | 2115 | + const std::string &groupName, rtStream_t streamMain, HcclOpExecResParams &resParams) |
| 2116 | +{ | ||
| 1830 | // 获取 in ccl buf | 2117 | // 获取 in ccl buf |
| 1831 | u64 commInputSize; | 2118 | u64 commInputSize; |
| 1832 | CHK_RET(GetHcomInCCLbufferSize(commInputSize, shapeType, comm, group)); | 2119 | CHK_RET(GetHcomInCCLbufferSize(commInputSize, shapeType, comm, group)); |
| 1833 | - | ||
| 1834 | // 计算出cclbuffer支持最大的count数量 | 2120 | // 计算出cclbuffer支持最大的count数量 |
| 1835 | u32 unitSize = SIZE_TABLE[dataType]; | 2121 | u32 unitSize = SIZE_TABLE[dataType]; |
| 1836 | u64 maxCountPerLoop = commInputSize / unitSize; // ccl buffer内存单次最多能够接受的input count | 2122 | u64 maxCountPerLoop = commInputSize / unitSize; // ccl buffer内存单次最多能够接受的input count |
| @@ -1843,6 +2129,13 @@ HcclResult HcomOpsKernelInfoStore::HcomSendLoop(const std::vector<std::string> & | |||
| 1843 | if (count * unitSize <= commInputSize) { | 2129 | if (count * unitSize <= commInputSize) { |
| 1844 | secAddrCopyWithoutOffset = true; | 2130 | secAddrCopyWithoutOffset = true; |
| 1845 | } | 2131 | } |
| 2132 | + bool openSourceTag = false; | ||
| 2133 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 2134 | + if (openSourceTag) { | ||
| 2135 | + HCCL_INFO("[HcomSendLoop] opensource produce, call HcceSendGraphMode"); | ||
| 2136 | + } else { | ||
| 2137 | + HCCL_INFO("[HcomSendLoop] normal produce, call HcomSend"); | ||
| 2138 | + } | ||
| 1846 | 2139 | ||
| 1847 | for (u64 countLeft = count, inputOffset = 0, loopTime = 0; countLeft > 0; countLeft -= curCount) { | 2140 | for (u64 countLeft = count, inputOffset = 0, loopTime = 0; countLeft > 0; countLeft -= curCount) { |
| 1848 | HCCL_INFO("[HcomSendLoop]:inputOffset[%llu] countLeft[%llu] curCount[%llu] cclbuffer[%llu].", inputOffset, | 2141 | HCCL_INFO("[HcomSendLoop]:inputOffset[%llu] countLeft[%llu] curCount[%llu] cclbuffer[%llu].", inputOffset, |
| @@ -1875,15 +2168,14 @@ HcclResult HcomOpsKernelInfoStore::HcomSendLoop(const std::vector<std::string> & | |||
| 1875 | } | 2168 | } |
| 1876 | } | 2169 | } |
| 1877 | 2170 | ||
| 1878 | - // 执行 hcom 算子 | 2171 | + if (openSourceTag) { |
| 1879 | - if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 2172 | + CHK_RET(HcceSendGraphMode( |
| 1880 | - CHK_RET(HcomSend(tagVec[loopTime].c_str(), commInputPtr, curCount, dataType, destRank, srTag, group.c_str(), | 2173 | + commInputPtr, curCount, dataType, destRank, groupName.c_str(), streamMain, |
| 1881 | - streamMain)); | 2174 | + tagVec[loopTime].c_str(), resParams.streamArray, resParams.streamCount, |
| 2175 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 1882 | } else { | 2176 | } else { |
| 1883 | - char *groupname = nullptr; | 2177 | + CHK_RET(HcomSend( |
| 1884 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 2178 | + tagVec[loopTime].c_str(), commInputPtr, curCount, dataType, destRank, srTag, groupName.c_str(), streamMain)); |
| 1885 | - CHK_RET( | ||
| 1886 | - HcomSend(tagVec[loopTime].c_str(), commInputPtr, curCount, dataType, destRank, srTag, groupname, streamMain)); | ||
| 1887 | } | 2179 | } |
| 1888 | 2180 | ||
| 1889 | // 更新偏移量 | 2181 | // 更新偏移量 |
| @@ -1930,32 +2222,50 @@ HcclResult HcomOpsKernelInfoStore::HcomReceiveOpKernel(const ge::GETaskInfo &tas | |||
| 1930 | 2222 | ||
| 1931 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); | 2223 | void *outputDataPtr = reinterpret_cast<void *>(outputAddr); |
| 1932 | 2224 | ||
| 1933 | - if (task.needRefresh) { | 2225 | + std::string groupName; |
| 1934 | - CHK_RET( | 2226 | + if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 1935 | - HcomReceiveLoop(tagVec, srTag, shapeType, comm, group, outputDataPtr, count, dataType, srcRank, streamMain)); | 2227 | + groupName = group; |
| 1936 | } else { | 2228 | } else { |
| 1937 | - // 执行 hcom 算子 | 2229 | + char *tmp = nullptr; |
| 1938 | - if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 2230 | + CHK_RET(GetGroupNameByOpBaseHcom(comm, &tmp)); |
| 1939 | - CHK_RET( | 2231 | + groupName = tmp; |
| 1940 | - HcomReceive(tagVec[0].c_str(), outputDataPtr, count, dataType, srcRank, srTag, group.c_str(), streamMain)); | 2232 | + } |
| 2233 | + HCCL_INFO("[HcomReceiveOpKernel] groupName: [%s]", groupName.c_str()); | ||
| 2234 | + | ||
| 2235 | + // 准备执行参数 | ||
| 2236 | + HcclOpExecResParams resParams; | ||
| 2237 | + CHK_RET(PrepareOpExecutionParams(tagVec, hcclInfo, resParams)); | ||
| 2238 | + | ||
| 2239 | + if (task.needRefresh) { | ||
| 2240 | + CHK_RET(HcomReceiveLoop( | ||
| 2241 | + tagVec, srTag, shapeType, comm, group, outputDataPtr, count, dataType, srcRank, | ||
| 2242 | + groupName, streamMain, resParams)); | ||
| 2243 | + } else { | ||
| 2244 | + bool openSourceTag = false; | ||
| 2245 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 2246 | + if (openSourceTag) { | ||
| 2247 | + HCCL_INFO("[HcomReceiveOpKernel] enter opensource produce, call HcceRecvGraphMode"); | ||
| 2248 | + CHK_RET(HcceRecvGraphMode( | ||
| 2249 | + outputDataPtr, count, dataType, srcRank, groupName.c_str(), streamMain, | ||
| 2250 | + resParams.tag.c_str(), resParams.streamArray, resParams.streamCount, | ||
| 2251 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 2252 | + HCCL_INFO("[HcomReceiveOpKernel] HcceRecvGraphMode end"); | ||
| 1941 | } else { | 2253 | } else { |
| 1942 | - char *groupname = nullptr; | 2254 | + CHK_RET(HcomReceive(tagVec[0].c_str(), outputDataPtr, count, dataType, srcRank, srTag, groupName.c_str(), streamMain)); |
| 1943 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | ||
| 1944 | - CHK_RET(HcomReceive(tagVec[0].c_str(), outputDataPtr, count, dataType, srcRank, srTag, groupname, streamMain)); | ||
| 1945 | } | 2255 | } |
| 1946 | } | 2256 | } |
| 1947 | 2257 | ||
| 1948 | return HCCL_SUCCESS; | 2258 | return HCCL_SUCCESS; |
| 1949 | } | 2259 | } |
| 1950 | 2260 | ||
| 1951 | -HcclResult HcomOpsKernelInfoStore::HcomReceiveLoop(const std::vector<std::string> &tagVec, u32 &srTag, u32 shapeType, | 2261 | +HcclResult HcomOpsKernelInfoStore::HcomReceiveLoop( |
| 1952 | - const int64_t &comm, const std::string &group, void *&outputDataPtr, | 2262 | + const std::vector<std::string> &tagVec, u32 &srTag, u32 shapeType, const int64_t &comm, const std::string &group, |
| 1953 | - u64 count, HcclDataType dataType, u32 &srcRank, | 2263 | + void *&outputDataPtr, u64 count, HcclDataType dataType, u32 &srcRank, |
| 1954 | - rtStream_t streamMain) { | 2264 | + const std::string &groupName, rtStream_t streamMain, HcclOpExecResParams &resParams) |
| 2265 | +{ | ||
| 1955 | // 获取 in ccl buf | 2266 | // 获取 in ccl buf |
| 1956 | u64 commOutputSize; | 2267 | u64 commOutputSize; |
| 1957 | GetHcomOutCCLbufferSize(commOutputSize, shapeType, comm, group); | 2268 | GetHcomOutCCLbufferSize(commOutputSize, shapeType, comm, group); |
| 1958 | - | ||
| 1959 | // 计算出cclbuffer支持最大的count数量 | 2269 | // 计算出cclbuffer支持最大的count数量 |
| 1960 | u32 unitSize = SIZE_TABLE[dataType]; | 2270 | u32 unitSize = SIZE_TABLE[dataType]; |
| 1961 | u64 maxCountPerLoop = commOutputSize / unitSize; // ccl buffer内存单次最多能够接受的input count | 2271 | u64 maxCountPerLoop = commOutputSize / unitSize; // ccl buffer内存单次最多能够接受的input count |
| @@ -1969,6 +2279,13 @@ HcclResult HcomOpsKernelInfoStore::HcomReceiveLoop(const std::vector<std::string | |||
| 1969 | if (count * unitSize <= commOutputSize) { | 2279 | if (count * unitSize <= commOutputSize) { |
| 1970 | secAddrCopyWithoutOffset = true; | 2280 | secAddrCopyWithoutOffset = true; |
| 1971 | } | 2281 | } |
| 2282 | + bool openSourceTag = false; | ||
| 2283 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 2284 | + if (openSourceTag) { | ||
| 2285 | + HCCL_INFO("[HcomReceiveLoop] opensource produce, call HcceRecvGraphMode"); | ||
| 2286 | + } else { | ||
| 2287 | + HCCL_INFO("[HcomReceiveLoop] normal produce, call HcomRecv"); | ||
| 2288 | + } | ||
| 1972 | 2289 | ||
| 1973 | for (u64 countLeft = count, outputOffset = 0, loopTime = 0; countLeft > 0; countLeft -= curCount) { | 2290 | for (u64 countLeft = count, outputOffset = 0, loopTime = 0; countLeft > 0; countLeft -= curCount) { |
| 1974 | HCCL_INFO("[HcomReceiveLoop]:outputOffset[%llu] countLeft[%llu] curCount[%llu] cclbuffer[%llu].", outputOffset, | 2291 | HCCL_INFO("[HcomReceiveLoop]:outputOffset[%llu] countLeft[%llu] curCount[%llu] cclbuffer[%llu].", outputOffset, |
| @@ -1998,15 +2315,14 @@ HcclResult HcomOpsKernelInfoStore::HcomReceiveLoop(const std::vector<std::string | |||
| 1998 | } | 2315 | } |
| 1999 | } | 2316 | } |
| 2000 | 2317 | ||
| 2001 | - // 执行 hcom 算子 | 2318 | + if (openSourceTag) { |
| 2002 | - if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 2319 | + CHK_RET(HcceRecvGraphMode( |
| 2003 | - CHK_RET(HcomReceive(tagVec[loopTime].c_str(), commOutputPtr, curCount, dataType, srcRank, srTag, group.c_str(), | 2320 | + commOutputPtr, curCount, dataType, srcRank, groupName.c_str(), streamMain, |
| 2004 | - streamMain)); | 2321 | + tagVec[loopTime].c_str(), resParams.streamArray, resParams.streamCount, |
| 2322 | + resParams.scratchMemAddr, resParams.scratchMemSize)); | ||
| 2005 | } else { | 2323 | } else { |
| 2006 | - char *groupname = nullptr; | 2324 | + CHK_RET(HcomReceive( |
| 2007 | - CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 2325 | + tagVec[loopTime].c_str(), commOutputPtr, curCount, dataType, srcRank, srTag, groupName.c_str(), streamMain)); |
| 2008 | - CHK_RET(HcomReceive(tagVec[loopTime].c_str(), commOutputPtr, curCount, dataType, srcRank, srTag, groupname, | ||
| 2009 | - streamMain)); | ||
| 2010 | } | 2326 | } |
| 2011 | 2327 | ||
| 2012 | // 将结果拷回二级指针上 | 2328 | // 将结果拷回二级指针上 |
| @@ -2750,6 +3066,94 @@ HcclResult HcomOpsKernelInfoStore::GetTagVectorInfo(const ge::GETaskInfo &task, | |||
| 2750 | return HCCL_SUCCESS; | 3066 | return HCCL_SUCCESS; |
| 2751 | } | 3067 | } |
| 2752 | 3068 | ||
| 3069 | +HcclResult HcomOpsKernelInfoStore::ActivateSubStreams(const ge::GETaskInfo &task) { | ||
| 3070 | + // 检查是否使用开源模式 | ||
| 3071 | + bool openSourceTag = false; | ||
| 3072 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 3073 | + | ||
| 3074 | + // 非开源模式,返回成功 | ||
| 3075 | + if (!openSourceTag) { | ||
| 3076 | + return HCCL_SUCCESS; | ||
| 3077 | + } | ||
| 3078 | + | ||
| 3079 | + // 检查 kernelHcclInfo 是否为空 | ||
| 3080 | + CHK_PRT_RET(task.kernelHcclInfo.empty(), HCCL_ERROR("[ActivateSubStreams] kernelHcclInfo is empty"), HCCL_E_PARA); | ||
| 3081 | + | ||
| 3082 | + // 获取需要激活的从流列表 | ||
| 3083 | + const std::vector<rtStream_t> &streams = task.kernelHcclInfo[0].hcclStreamList; | ||
| 3084 | + | ||
| 3085 | + // 没有需要激活的从流,返回成功 | ||
| 3086 | + if (streams.empty()) { | ||
| 3087 | + return HCCL_SUCCESS; | ||
| 3088 | + } | ||
| 3089 | + // 获取主流 | ||
| 3090 | + rtStream_t streamMain; | ||
| 3091 | + CHK_RET(GetStreamMainFromTaskInfo(task, streamMain)); | ||
| 3092 | + | ||
| 3093 | + // 遍历所有需要激活的从流 | ||
| 3094 | + for (auto &stream : streams) { | ||
| 3095 | + rtStream_t attachedStream = stream; | ||
| 3096 | + | ||
| 3097 | + // 判断从流是否已经在set中 | ||
| 3098 | + auto it = activatedStreams_.find(attachedStream); | ||
| 3099 | + if (it != activatedStreams_.end()) { | ||
| 3100 | + // 从流已激活 | ||
| 3101 | + HCCL_INFO("[ActivateSubStreams] Attached stream [%p] already activated, skip", attachedStream); | ||
| 3102 | + continue; | ||
| 3103 | + } | ||
| 3104 | + | ||
| 3105 | + // 从流未激活,需要激活 | ||
| 3106 | + auto ret = aclrtActiveStream(attachedStream, streamMain); | ||
| 3107 | + if (ret != ACL_SUCCESS) { | ||
| 3108 | + HCCL_ERROR("[ActivateSubStreams] Activate attached stream [%p] with main stream [%p] failed, ret[%d]", | ||
| 3109 | + attachedStream, streamMain, ret); | ||
| 3110 | + return HCCL_E_RUNTIME; | ||
| 3111 | + } | ||
| 3112 | + | ||
| 3113 | + // 激活成功,插入set | ||
| 3114 | + activatedStreams_.insert(attachedStream); | ||
| 3115 | + HCCL_INFO("[ActivateSubStreams] Activate attached stream [%p] with main stream [%p] success", | ||
| 3116 | + attachedStream, streamMain); | ||
| 3117 | + } | ||
| 3118 | + return HCCL_SUCCESS; | ||
| 3119 | +} | ||
| 3120 | + | ||
| 3121 | + | ||
| 3122 | +HcclResult HcomOpsKernelInfoStore::DeactivateSubStreams(const ge::GETaskInfo &task) { | ||
| 3123 | + // 检查是否使用开源模式 | ||
| 3124 | + bool openSourceTag = false; | ||
| 3125 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 3126 | + | ||
| 3127 | + // 非开源模式,返回成功 | ||
| 3128 | + if (!openSourceTag) { | ||
| 3129 | + return HCCL_SUCCESS; | ||
| 3130 | + } | ||
| 3131 | + | ||
| 3132 | + // 检查 kernelHcclInfo 是否为空 | ||
| 3133 | + CHK_PRT_RET(task.kernelHcclInfo.empty(), HCCL_ERROR("[DeactivateSubStreams] kernelHcclInfo is empty"), HCCL_E_PARA); | ||
| 3134 | + // 获取需要反激活的从流列表 | ||
| 3135 | + const std::vector<rtStream_t> &streams = task.kernelHcclInfo[0].hcclStreamList; | ||
| 3136 | + | ||
| 3137 | + // 没有需要反激活的从流,返回成功 | ||
| 3138 | + if (streams.empty()) { | ||
| 3139 | + return HCCL_SUCCESS; | ||
| 3140 | + } | ||
| 3141 | + | ||
| 3142 | + // 遍历所有需要反激活的从流 | ||
| 3143 | + for (auto &stream : streams) { | ||
| 3144 | + rtStream_t rtStream = stream; | ||
| 3145 | + | ||
| 3146 | + // 从set中删除,即为反激活 | ||
| 3147 | + auto it = activatedStreams_.find(rtStream); | ||
| 3148 | + if (it != activatedStreams_.end()) { | ||
| 3149 | + activatedStreams_.erase(it); | ||
| 3150 | + HCCL_INFO("[DeactivateSubStreams] Deactivate attached stream [%p] success", rtStream); | ||
| 3151 | + } | ||
| 3152 | + } | ||
| 3153 | + return HCCL_SUCCESS; | ||
| 3154 | +} | ||
| 3155 | + | ||
| 3156 | + | ||
| 2753 | ge::Status HcomOpsKernelInfoStore::LoadTask(ge::GETaskInfo &task) { | 3157 | ge::Status HcomOpsKernelInfoStore::LoadTask(ge::GETaskInfo &task) { |
| 2754 | s32 deviceLogicId; // 防止编译阶段和加载阶段deviceLogicId变更,此处重新刷一下 | 3158 | s32 deviceLogicId; // 防止编译阶段和加载阶段deviceLogicId变更,此处重新刷一下 |
| 2755 | CHK_RET(hrtGetDeviceRefresh(&deviceLogicId)); | 3159 | CHK_RET(hrtGetDeviceRefresh(&deviceLogicId)); |
| @@ -2823,11 +3227,14 @@ ge::Status HcomOpsKernelInfoStore::LoadTask(ge::GETaskInfo &task) { | |||
| 2823 | ret = GetOriginalGraphShapeTypeFromTaskInfo(task, shapeType); | 3227 | ret = GetOriginalGraphShapeTypeFromTaskInfo(task, shapeType); |
| 2824 | CHK_PRT_RET(ret != HCCL_SUCCESS, HCCL_ERROR("[Load][Task]errNo[0x%016llx] get shapeType fail", HCOM_ERROR_CODE(ret)), | 3228 | CHK_PRT_RET(ret != HCCL_SUCCESS, HCCL_ERROR("[Load][Task]errNo[0x%016llx] get shapeType fail", HCOM_ERROR_CODE(ret)), |
| 2825 | ge::INTERNAL_ERROR); | 3229 | ge::INTERNAL_ERROR); |
| 2826 | - | 3230 | + bool openSourceTag = false; |
| 2827 | - if (!IsRefresh(task, sCollectiveType, shapeType)) { | 3231 | + CHK_RET(IsUsingOpenSource(openSourceTag)); |
| 2828 | - ret = SetKnownShapeWorkspaceResource(task, sCollectiveType, tagVec); | 3232 | + if (!openSourceTag) { |
| 2829 | - } else { | 3233 | + if (!IsRefresh(task, sCollectiveType, shapeType)) { |
| 2830 | - ret = SetUnknownShapeWorkspaceResource(task, sCollectiveType, tagVec); | 3234 | + ret = SetKnownShapeWorkspaceResource(task, sCollectiveType, tagVec); |
| 3235 | + } else { | ||
| 3236 | + ret = SetUnknownShapeWorkspaceResource(task, sCollectiveType, tagVec); | ||
| 3237 | + } | ||
| 2831 | } | 3238 | } |
| 2832 | CHK_PRT_RET( | 3239 | CHK_PRT_RET( |
| 2833 | ret != HCCL_SUCCESS, | 3240 | ret != HCCL_SUCCESS, |
| @@ -2841,6 +3248,9 @@ ge::Status HcomOpsKernelInfoStore::LoadTask(ge::GETaskInfo &task) { | |||
| 2841 | // 设置附属从流信息 | 3248 | // 设置附属从流信息 |
| 2842 | CHK_RET(SetAttachedStream(task)); | 3249 | CHK_RET(SetAttachedStream(task)); |
| 2843 | 3250 | ||
| 3251 | + // 激活从流 | ||
| 3252 | + CHK_RET(ActivateSubStreams(task)); | ||
| 3253 | + | ||
| 2844 | // 清空aiv buffer | 3254 | // 清空aiv buffer |
| 2845 | rtStream_t streamMain; | 3255 | rtStream_t streamMain; |
| 2846 | CHK_RET(GetStreamMainFromTaskInfo(task, streamMain)); | 3256 | CHK_RET(GetStreamMainFromTaskInfo(task, streamMain)); |
| @@ -2926,6 +3336,9 @@ ge::Status HcomOpsKernelInfoStore::UnloadTask(ge::GETaskInfo &task) { | |||
| 2926 | CHK_RET(HcomAicpuStreamUnRegister(task)); | 3336 | CHK_RET(HcomAicpuStreamUnRegister(task)); |
| 2927 | CHK_RET(HcomSetWorkflowMode(lastWorkflowMode)); | 3337 | CHK_RET(HcomSetWorkflowMode(lastWorkflowMode)); |
| 2928 | 3338 | ||
| 3339 | + // 反激活从流 | ||
| 3340 | + CHK_RET(DeactivateSubStreams(task)); | ||
| 3341 | + | ||
| 2929 | taskIdLock.lock(); | 3342 | taskIdLock.lock(); |
| 2930 | taskIDtoTag_.erase(task.id); | 3343 | taskIDtoTag_.erase(task.id); |
| 2931 | HCCL_INFO("UnloadTask success taskID[%u].", task.id); | 3344 | HCCL_INFO("UnloadTask success taskID[%u].", task.id); |
| @@ -3062,8 +3475,14 @@ HcclResult HcomOpsKernelInfoStore::SetAivCoreLimit(const ge::GETaskInfo &task) { | |||
| 3062 | HCCL_ERROR("[HcomOpsKernelInfoStore][SetAivCoreLimit] aivCoreLimit shouledn't be 0"), HCCL_E_PARA); | 3475 | HCCL_ERROR("[HcomOpsKernelInfoStore][SetAivCoreLimit] aivCoreLimit shouledn't be 0"), HCCL_E_PARA); |
| 3063 | CHK_RET(GetCommFromTaskInfo(task, comm)); | 3476 | CHK_RET(GetCommFromTaskInfo(task, comm)); |
| 3064 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { | 3477 | if (comm == static_cast<int64_t>(CommNumHcom::COMM_VALUE_DEFAULT)) { |
| 3478 | + bool openSourceTag = false; | ||
| 3479 | + CHK_RET(IsUsingOpenSource(openSourceTag)); | ||
| 3065 | CHK_RET(GetGroupFromTaskInfo(task, group)); | 3480 | CHK_RET(GetGroupFromTaskInfo(task, group)); |
| 3066 | - CHK_RET(HcomSetAivCoreLimit(group.c_str(), privateDefBuf->aivCoreLimit)); | 3481 | + if (openSourceTag) { |
| 3482 | + CHK_RET(HcceSetAivCoreLimitGraphMode(group.c_str(), privateDefBuf->aivCoreLimit)); | ||
| 3483 | + } else { | ||
| 3484 | + CHK_RET(HcomSetAivCoreLimit(group.c_str(), privateDefBuf->aivCoreLimit)); | ||
| 3485 | + } | ||
| 3067 | } else { | 3486 | } else { |
| 3068 | char *groupname = nullptr; | 3487 | char *groupname = nullptr; |
| 3069 | CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); | 3488 | CHK_RET(GetGroupNameByOpBaseHcom(comm, &groupname)); |
| @@ -3161,5 +3580,8 @@ HcclResult HcomOpsKernelInfoStore::CleanInterMemoryV2(std::vector<std::int64_t> | |||
| 3161 | } | 3580 | } |
| 3162 | return HCCL_SUCCESS; | 3581 | return HCCL_SUCCESS; |
| 3163 | } | 3582 | } |
| 3583 | + | ||
| 3164 | 3584 | ||
| 3585 | + | ||
| 3586 | + | ||
| 3165 | } // namespace hccl | 3587 | } // namespace hccl |
| @@ -20,6 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | + | ||
| 23 | 24 | ||
| 24 | namespace hccl { | 25 | namespace hccl { |
| 25 | constexpr u32 CRACK_MEMORY_SIZE = 32; // 申请32B内存,当缝隙SIZE小于32B时,用D2D Memcopy进行清零操作 | 26 | constexpr u32 CRACK_MEMORY_SIZE = 32; // 申请32B内存,当缝隙SIZE小于32B时,用D2D Memcopy进行清零操作 |
| @@ -38,6 +39,15 @@ enum UpdatePairedInputIndex { | |||
| 38 | UPDATE_PRD_IT_IDX_NUM = 7 | 39 | UPDATE_PRD_IT_IDX_NUM = 7 |
| 39 | }; | 40 | }; |
| 40 | 41 | ||
| 42 | +struct HcclOpExecResParams { | ||
| 43 | + std::string tag; | ||
| 44 | + std::vector<rtStream_t> streams; | ||
| 45 | + void** streamArray; | ||
| 46 | + size_t streamCount; | ||
| 47 | + void* scratchMemAddr; | ||
| 48 | + uint64_t scratchMemSize; | ||
| 49 | +}; | ||
| 50 | + | ||
| 41 | // Ge适配的类 | 51 | // Ge适配的类 |
| 42 | class HcomOpsKernelInfoStore : public HCCLOpsKernelInfoStore { | 52 | class HcomOpsKernelInfoStore : public HCCLOpsKernelInfoStore { |
| 43 | public: | 53 | public: |
| @@ -141,13 +151,17 @@ class HcomOpsKernelInfoStore : public HCCLOpsKernelInfoStore { | |||
| 141 | u32 &propValue); | 151 | u32 &propValue); |
| 142 | HcclResult GetJsonProperty(const nlohmann::json &obj, const char *propName, nlohmann::json &propValue); | 152 | HcclResult GetJsonProperty(const nlohmann::json &obj, const char *propName, nlohmann::json &propValue); |
| 143 | HcclResult CheckOfflineDevTypeIsSame(const ge::GETaskInfo &task); | 153 | HcclResult CheckOfflineDevTypeIsSame(const ge::GETaskInfo &task); |
| 154 | + HcclResult PrepareOpExecutionParams(const std::vector<std::string> &tagVec, | ||
| 155 | + const ge::GETaskKernelHcclInfo &hcclInfo, | ||
| 156 | + HcclOpExecResParams &resParams); | ||
| 144 | 157 | ||
| 145 | HcclResult HcomAllGatherLoop(const std::vector<std::string> &tagVec, u32 shapeType, const int64_t &comm, | 158 | HcclResult HcomAllGatherLoop(const std::vector<std::string> &tagVec, u32 shapeType, const int64_t &comm, |
| 146 | const std::string &group, void *&inputDataPtr, void *&outputDataPtr, u64 count, | 159 | const std::string &group, void *&inputDataPtr, void *&outputDataPtr, u64 count, |
| 147 | - HcclDataType dataType, rtStream_t streamMain); | 160 | + HcclDataType dataType, rtStream_t streamMain, HcclOpExecResParams &resParams); |
| 148 | HcclResult HcomAllReduceLoop(const ge::GETaskInfo &task, const std::vector<std::string> &tagVec, u32 shapeType, | 161 | HcclResult HcomAllReduceLoop(const ge::GETaskInfo &task, const std::vector<std::string> &tagVec, u32 shapeType, |
| 149 | const int64_t &comm, const std::string &group, void *&inputDataPtr, void *&outputDataPtr, | 162 | const int64_t &comm, const std::string &group, void *&inputDataPtr, void *&outputDataPtr, |
| 150 | - u64 count, HcclDataType dataType, HcclReduceOp reduceType, rtStream_t streamMain); | 163 | + u64 count, HcclDataType dataType, HcclReduceOp reduceType, rtStream_t streamMain, |
| 164 | + HcclOpExecResParams &resParams); | ||
| 151 | HcclResult RefreshAllgatherOutputAddr(DevType deviceType, u32 shapeType, const int64_t &hcomComm, | 165 | HcclResult RefreshAllgatherOutputAddr(DevType deviceType, u32 shapeType, const int64_t &hcomComm, |
| 152 | const std::string &sGroup, void *&outputAddr, u64 outputOffset, u64 curSize, | 166 | const std::string &sGroup, void *&outputAddr, u64 outputOffset, u64 curSize, |
| 153 | u64 count, u32 unitSize, u32 rankSize, bool secAddrCopyWithoutOffset, | 167 | u64 count, u32 unitSize, u32 rankSize, bool secAddrCopyWithoutOffset, |
| @@ -165,23 +179,26 @@ class HcomOpsKernelInfoStore : public HCCLOpsKernelInfoStore { | |||
| 165 | HcclResult HcomReduceScatterLoop(const ge::GETaskInfo &task, const std::vector<std::string> &tagVec, u32 shapeType, | 179 | HcclResult HcomReduceScatterLoop(const ge::GETaskInfo &task, const std::vector<std::string> &tagVec, u32 shapeType, |
| 166 | const int64_t &comm, const std::string &group, void *&inputDataPtr, | 180 | const int64_t &comm, const std::string &group, void *&inputDataPtr, |
| 167 | void *&outputDataPtr, u64 count, HcclDataType dataType, HcclReduceOp reduceType, | 181 | void *&outputDataPtr, u64 count, HcclDataType dataType, HcclReduceOp reduceType, |
| 168 | - rtStream_t streamMain); | 182 | + rtStream_t streamMain, HcclOpExecResParams &resParams); |
| 169 | HcclResult RefreshReduceScatterInputAddr(DevType deviceType, u32 shapeType, const int64_t &hcomComm, | 183 | HcclResult RefreshReduceScatterInputAddr(DevType deviceType, u32 shapeType, const int64_t &hcomComm, |
| 170 | const std::string &sGroup, void *&inputAddr, u64 inputOffset, u64 curSize, | 184 | const std::string &sGroup, void *&inputAddr, u64 inputOffset, u64 curSize, |
| 171 | u64 count, u32 unitSize, u32 rankSize, bool secAddrCopyWithoutOffset, | 185 | u64 count, u32 unitSize, u32 rankSize, bool secAddrCopyWithoutOffset, |
| 172 | rtStream_t stream); | 186 | rtStream_t stream); |
| 173 | HcclResult HcomReduceLoop(const ge::GETaskInfo &task, const std::vector<std::string> &tagVec, u32 shapeType, | 187 | HcclResult HcomReduceLoop(const ge::GETaskInfo &task, const std::vector<std::string> &tagVec, u32 shapeType, |
| 174 | const int64_t &comm, const std::string &group, void *&inputDataPtr, void *&outputDataPtr, | 188 | const int64_t &comm, const std::string &group, void *&inputDataPtr, void *&outputDataPtr, |
| 175 | - u64 count, HcclDataType dataType, HcclReduceOp reduceType, u32 root, rtStream_t streamMain); | 189 | + u64 count, HcclDataType dataType, HcclReduceOp reduceType, u32 root, rtStream_t streamMain, |
| 176 | - HcclResult HcomSendLoop(const std::vector<std::string> &tagVec, u32 &srTag, u32 shapeType, const int64_t &comm, | 190 | + HcclOpExecResParams &resParams); |
| 177 | - const std::string &group, void *&inputDataPtr, u64 count, HcclDataType dataType, | 191 | + HcclResult HcomSendLoop( |
| 178 | - u32 &destRank, rtStream_t streamMain); | 192 | + const std::vector<std::string> &tagVec, u32 &srTag, u32 shapeType, const int64_t &comm, const std::string &group, |
| 179 | - HcclResult HcomReceiveLoop(const std::vector<std::string> &tagVec, u32 &srTag, u32 shapeType, const int64_t &comm, | 193 | + void *&inputDataPtr, u64 count, HcclDataType dataType, u32 &destRank, |
| 180 | - const std::string &group, void *&outputDataPtr, u64 count, HcclDataType dataType, | 194 | + const std::string &groupName, rtStream_t streamMain, HcclOpExecResParams &resParams); |
| 181 | - u32 &srcRank, rtStream_t streamMain); | 195 | + HcclResult HcomReceiveLoop( |
| 196 | + const std::vector<std::string> &tagVec, u32 &srTag, u32 shapeType, const int64_t &comm, const std::string &group, | ||
| 197 | + void *&outputDataPtr, u64 count, HcclDataType dataType, u32 &srcRank, | ||
| 198 | + const std::string &groupName, rtStream_t streamMain, HcclOpExecResParams &resParams); | ||
| 182 | HcclResult HcomBroadcastLoop(const std::vector<std::string> &tagVec, u32 shapeType, const int64_t &comm, | 199 | HcclResult HcomBroadcastLoop(const std::vector<std::string> &tagVec, u32 shapeType, const int64_t &comm, |
| 183 | const std::string &group, void *&inputDataPtr, u64 count, HcclDataType dataType, | 200 | const std::string &group, void *&inputDataPtr, u64 count, HcclDataType dataType, |
| 184 | - u32 root, rtStream_t streamMain); | 201 | + u32 root, rtStream_t streamMain, HcclOpExecResParams &resParams); |
| 185 | HcclResult CheckHcomOpMemSize(DevType deviceType, u64 countLeft, u32 unitSize, u64 cclBufferSize); | 202 | HcclResult CheckHcomOpMemSize(DevType deviceType, u64 countLeft, u32 unitSize, u64 cclBufferSize); |
| 186 | HcclResult CheckTensorNumAndTensorSize(const ge::GETaskInfo &task, u64 count, u32 unitSize, u64 commInputSize); | 203 | HcclResult CheckTensorNumAndTensorSize(const ge::GETaskInfo &task, u64 count, u32 unitSize, u64 commInputSize); |
| 187 | HcclResult CreateIndirectCCLbuf(); | 204 | HcclResult CreateIndirectCCLbuf(); |
| @@ -204,6 +221,8 @@ class HcomOpsKernelInfoStore : public HCCLOpsKernelInfoStore { | |||
| 204 | HcclResult HcomAicpuStreamUnRegister(ge::GETaskInfo &task); | 221 | HcclResult HcomAicpuStreamUnRegister(ge::GETaskInfo &task); |
| 205 | HcclResult SetAivCoreLimit(const ge::GETaskInfo &task); | 222 | HcclResult SetAivCoreLimit(const ge::GETaskInfo &task); |
| 206 | HcclResult SetGlobalWorkSpace(const int64_t &hcomComm, const string &sGroup, std::vector<void *> globalWorkSpaceAddr); | 223 | HcclResult SetGlobalWorkSpace(const int64_t &hcomComm, const string &sGroup, std::vector<void *> globalWorkSpaceAddr); |
| 224 | + HcclResult ActivateSubStreams(const ge::GETaskInfo &task); | ||
| 225 | + HcclResult DeactivateSubStreams(const ge::GETaskInfo &task); | ||
| 207 | 226 | ||
| 208 | HcclResult CleanInterMemoryV2(std::vector<std::int64_t> &crackSize, | 227 | HcclResult CleanInterMemoryV2(std::vector<std::int64_t> &crackSize, |
| 209 | std::vector<std::int64_t> &crackAddr, rtStream_t stream); | 228 | std::vector<std::int64_t> &crackAddr, rtStream_t stream); |
| @@ -268,6 +287,7 @@ class HcomOpsKernelInfoStore : public HCCLOpsKernelInfoStore { | |||
| 268 | std::unordered_map<s64, u32> graphIdByCommId_; | 287 | std::unordered_map<s64, u32> graphIdByCommId_; |
| 269 | std::unique_ptr<void, Deleter> indirectInCCLbufferPtr_; | 288 | std::unique_ptr<void, Deleter> indirectInCCLbufferPtr_; |
| 270 | std::unique_ptr<void, Deleter> indirectOutCCLbufferPtr_; | 289 | std::unique_ptr<void, Deleter> indirectOutCCLbufferPtr_; |
| 290 | + std::unordered_set<rtStream_t> activatedStreams_; | ||
| 271 | }; | 291 | }; |
| 272 | } // namespace hccl | 292 | } // namespace hccl |
| 273 | 293 | ||
| @@ -1394,6 +1394,95 @@ HcclResult GetOffDeviceTypeWithoutDevMock(DevType &devType) | |||
| 1394 | return HCCL_SUCCESS; | 1394 | return HCCL_SUCCESS; |
| 1395 | } | 1395 | } |
| 1396 | 1396 | ||
| 1397 | +TEST_F(HcomGraphOptimizerTest, ut_CalcOpRunningResources_OpenSource) | ||
| 1398 | +{ | ||
| 1399 | + // 测试开源版本的CalcOpRunningResources | ||
| 1400 | + HcomGraphOptimizer graphOptimizer; | ||
| 1401 | + ge::ComputeGraphPtr graph = std::make_shared<ge::ComputeGraph>("test_graph"); | ||
| 1402 | + auto descPtr0 = std::make_shared<ge::OpDesc>("Allreduce0", HCCL_KERNEL_OP_TYPE_ALLREDUCE); | ||
| 1403 | + auto addedNodePtr0 = graph->AddNode(descPtr0); | ||
| 1404 | + EXPECT_NE(addedNodePtr0, nullptr); | ||
| 1405 | + | ||
| 1406 | + std::string sCollectiveType; | ||
| 1407 | + u32 streamNum = 0; | ||
| 1408 | + u64 opMemSize = 0; | ||
| 1409 | + u32 taskNum = 0; | ||
| 1410 | + u32 aivCoreNum = 0; | ||
| 1411 | + | ||
| 1412 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 1413 | + MOCKER(IsUsingOpenSource) | ||
| 1414 | + .expects(atMost(1)) | ||
| 1415 | + .with(outBound(true)) | ||
| 1416 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1417 | + | ||
| 1418 | + // 模拟HcceCreateOpParamGraphMode函数 | ||
| 1419 | + OpParamGraphModePtr opParamPtr = reinterpret_cast<OpParamGraphModePtr>(0x12345678); | ||
| 1420 | + MOCKER(HcceCreateOpParamGraphMode) | ||
| 1421 | + .expects(atMost(1)) | ||
| 1422 | + .with(outBound(opParamPtr)) | ||
| 1423 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1424 | + | ||
| 1425 | + // 模拟SetHcclOpParam函数 | ||
| 1426 | + MOCKER(SetHcclOpParam) | ||
| 1427 | + .expects(atMost(1)) | ||
| 1428 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1429 | + | ||
| 1430 | + // 模拟HcceCalcOpResOfflineGraphMode函数 | ||
| 1431 | + MOCKER(HcceCalcOpResOfflineGraphMode) | ||
| 1432 | + .expects(atMost(1)) | ||
| 1433 | + .with(mockcpp::any(), outBound(&opMemSize), outBound(&streamNum), outBound(&taskNum), outBound(&aivCoreNum)) | ||
| 1434 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1435 | + | ||
| 1436 | + // 模拟IsOfflineCompilation返回true | ||
| 1437 | + MOCKER(IsOfflineCompilation) | ||
| 1438 | + .expects(atMost(1)) | ||
| 1439 | + .will(returnValue(true)); | ||
| 1440 | + | ||
| 1441 | + // 测试CalcOpRunningResources方法 | ||
| 1442 | + HcclResult ret = graphOptimizer.CalcOpRunningResources(*addedNodePtr0, sCollectiveType, streamNum, opMemSize, taskNum, aivCoreNum); | ||
| 1443 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 1444 | + | ||
| 1445 | + GlobalMockObject::verify(); | ||
| 1446 | +} | ||
| 1447 | + | ||
| 1448 | +TEST_F(HcomGraphOptimizerTest, ut_SetHcclOpParam) | ||
| 1449 | +{ | ||
| 1450 | + // 测试SetHcclOpParam函数 | ||
| 1451 | + HcomGraphOptimizer graphOptimizer; | ||
| 1452 | + ge::ComputeGraphPtr graph = std::make_shared<ge::ComputeGraph>("test_graph"); | ||
| 1453 | + auto descPtr0 = std::make_shared<ge::OpDesc>("Allreduce0", HCCL_KERNEL_OP_TYPE_ALLREDUCE); | ||
| 1454 | + auto addedNodePtr0 = graph->AddNode(descPtr0); | ||
| 1455 | + EXPECT_NE(addedNodePtr0, nullptr); | ||
| 1456 | + | ||
| 1457 | + // 准备测试参数 | ||
| 1458 | + HcomOpParam hcomOpParam; | ||
| 1459 | + std::string sCollectiveType; | ||
| 1460 | + OpParamGraphModePtr opParamPtr = reinterpret_cast<OpParamGraphModePtr>(0x12345678); | ||
| 1461 | + std::vector<int64_t> sendCounts; | ||
| 1462 | + std::vector<int64_t> sendDispls; | ||
| 1463 | + std::vector<int64_t> recvCounts; | ||
| 1464 | + std::vector<int64_t> recvDispls; | ||
| 1465 | + const char* group = "aiv"; | ||
| 1466 | + | ||
| 1467 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 1468 | + MOCKER(IsUsingOpenSource) | ||
| 1469 | + .expects(atMost(1)) | ||
| 1470 | + .with(outBound(true)) | ||
| 1471 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1472 | + | ||
| 1473 | + // 模拟HcceCreateOpParamGraphMode函数 | ||
| 1474 | + MOCKER(HcceCreateOpParamGraphMode) | ||
| 1475 | + .expects(atMost(1)) | ||
| 1476 | + .with(outBound(opParamPtr)) | ||
| 1477 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1478 | + | ||
| 1479 | + HcclResult ret = graphOptimizer.SetHcclOpParam(*addedNodePtr0, &hcomOpParam, opParamPtr, sCollectiveType, | ||
| 1480 | + sendCounts, sendDispls, recvCounts, recvDispls, group); | ||
| 1481 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 1482 | + | ||
| 1483 | + GlobalMockObject::verify(); | ||
| 1484 | +} | ||
| 1485 | + | ||
| 1397 | TEST_F(HcomGraphOptimizerTest, ut_OptimizeFusedGraph_allreduce) | 1486 | TEST_F(HcomGraphOptimizerTest, ut_OptimizeFusedGraph_allreduce) |
| 1398 | { | 1487 | { |
| 1399 | ge::ComputeGraphPtr graph = std::make_shared<ge::ComputeGraph>("test_graph"); | 1488 | ge::ComputeGraphPtr graph = std::make_shared<ge::ComputeGraph>("test_graph"); |
| @@ -1193,6 +1193,97 @@ TEST_F(HcomKernelBuilderTest, ut_CheckAlltoAllvcRank) | |||
| 1193 | GlobalMockObject::verify(); | 1193 | GlobalMockObject::verify(); |
| 1194 | } | 1194 | } |
| 1195 | 1195 | ||
| 1196 | +TEST_F(HcomKernelBuilderTest, ut_CalcOpRunningResources_OpenSource) | ||
| 1197 | +{ | ||
| 1198 | + // 测试开源版本的CalcOpRunningResources | ||
| 1199 | + HcomOpsKernelBuilder kernelBuilder; | ||
| 1200 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 1201 | + std::string sCollectiveType = HCCL_KERNEL_OP_TYPE_ALLREDUCE; | ||
| 1202 | + std::string sGroup = "test_group"; | ||
| 1203 | + u32 streamNum = 0; | ||
| 1204 | + u64 opMemSize = 0; | ||
| 1205 | + u32 taskNum = 0; | ||
| 1206 | + u32 aivCoreNum = 0; | ||
| 1207 | + | ||
| 1208 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 1209 | + MOCKER(IsUsingOpenSource) | ||
| 1210 | + .expects(atMost(1)) | ||
| 1211 | + .with(outBound(true)) | ||
| 1212 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1213 | + | ||
| 1214 | + // 模拟SetHcomOpParam函数 | ||
| 1215 | + MOCKER(SetHcomOpParam) | ||
| 1216 | + .expects(atMost(1)) | ||
| 1217 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1218 | + | ||
| 1219 | + // 模拟HcceCreateOpParamGraphMode函数 | ||
| 1220 | + OpParamGraphModePtr opParamPtr = reinterpret_cast<OpParamGraphModePtr>(0x12345678); | ||
| 1221 | + MOCKER(HcceCreateOpParamGraphMode) | ||
| 1222 | + .expects(atMost(1)) | ||
| 1223 | + .with(outBound(opParamPtr)) | ||
| 1224 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1225 | + | ||
| 1226 | + // 模拟SetHcclOpParam函数 | ||
| 1227 | + MOCKER(SetHcclOpParam) | ||
| 1228 | + .expects(atMost(1)) | ||
| 1229 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1230 | + | ||
| 1231 | + // 模拟HcceCalcOpResOfflineGraphMode函数 | ||
| 1232 | + MOCKER(HcceCalcOpResOfflineGraphMode) | ||
| 1233 | + .expects(atMost(1)) | ||
| 1234 | + .with(mockcpp::any(), outBound(&opMemSize), outBound(&streamNum), outBound(&taskNum), outBound(&aivCoreNum)) | ||
| 1235 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1236 | + | ||
| 1237 | + // 模拟IsOfflineCompilation返回true | ||
| 1238 | + MOCKER(IsOfflineCompilation) | ||
| 1239 | + .expects(atMost(1)) | ||
| 1240 | + .will(returnValue(true)); | ||
| 1241 | + | ||
| 1242 | + // 测试CalcOpRunningResources方法 | ||
| 1243 | + HcclResult ret = kernelBuilder.CalcOpRunningResources(*nodeptr, sCollectiveType, sGroup, streamNum, opMemSize, taskNum, aivCoreNum); | ||
| 1244 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 1245 | + | ||
| 1246 | + GlobalMockObject::verify(); | ||
| 1247 | +} | ||
| 1248 | + | ||
| 1249 | +TEST_F(HcomGraphOptimizerTest, ut_SetHcclOpParam) | ||
| 1250 | +{ | ||
| 1251 | + // 测试SetHcclOpParam函数 | ||
| 1252 | + HcomGraphOptimizer graphOptimizer; | ||
| 1253 | + ge::ComputeGraphPtr graph = std::make_shared<ge::ComputeGraph>("test_graph"); | ||
| 1254 | + auto descPtr0 = std::make_shared<ge::OpDesc>("Allreduce0", HCCL_KERNEL_OP_TYPE_ALLREDUCE); | ||
| 1255 | + auto addedNodePtr0 = graph->AddNode(descPtr0); | ||
| 1256 | + EXPECT_NE(addedNodePtr0, nullptr); | ||
| 1257 | + | ||
| 1258 | + // 准备测试参数 | ||
| 1259 | + HcomOpParam hcomOpParam; | ||
| 1260 | + std::string sCollectiveType; | ||
| 1261 | + OpParamGraphModePtr opParamPtr = reinterpret_cast<OpParamGraphModePtr>(0x12345678); | ||
| 1262 | + std::vector<int64_t> sendCounts; | ||
| 1263 | + std::vector<int64_t> sendDispls; | ||
| 1264 | + std::vector<int64_t> recvCounts; | ||
| 1265 | + std::vector<int64_t> recvDispls; | ||
| 1266 | + const char* group = "aiv"; | ||
| 1267 | + | ||
| 1268 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 1269 | + MOCKER(IsUsingOpenSource) | ||
| 1270 | + .expects(atMost(1)) | ||
| 1271 | + .with(outBound(true)) | ||
| 1272 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1273 | + | ||
| 1274 | + // 模拟HcceCreateOpParamGraphMode函数 | ||
| 1275 | + MOCKER(HcceCreateOpParamGraphMode) | ||
| 1276 | + .expects(atMost(1)) | ||
| 1277 | + .with(outBound(opParamPtr)) | ||
| 1278 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 1279 | + | ||
| 1280 | + HcclResult ret = graphOptimizer.SetHcclOpParam(*addedNodePtr0, &hcomOpParam, opParamPtr, sCollectiveType, | ||
| 1281 | + sendCounts, sendDispls, recvCounts, recvDispls, group); | ||
| 1282 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 1283 | + | ||
| 1284 | + GlobalMockObject::verify(); | ||
| 1285 | +} | ||
| 1286 | + | ||
| 1196 | TEST_F(HcomKernelBuilderTest, ut_getAlltoAllCountsDispl_across_graph) | 1287 | TEST_F(HcomKernelBuilderTest, ut_getAlltoAllCountsDispl_across_graph) |
| 1197 | { | 1288 | { |
| 1198 | ge::NodePtr nodeptr(new NodeTest); | 1289 | ge::NodePtr nodeptr(new NodeTest); |
| @@ -3193,6 +3193,272 @@ TEST_F(HcomKernelInfoTest, ut_CleanInterMemoryV2_When_MemSyncCopyFail_Expect_Ret | |||
| 3193 | GlobalMockObject::verify(); | 3193 | GlobalMockObject::verify(); |
| 3194 | } | 3194 | } |
| 3195 | 3195 | ||
| 3196 | +TEST_F(HcomKernelInfoTest, ut_CleanInterMemoryV2_When_MemAsyncCopyFail_Expect_ReturnHCCL_E_INTERNAL) | ||
| 3197 | +{ | ||
| 3198 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3199 | + rtStream_t stream = NULL; | ||
| 3200 | +} | ||
| 3201 | + | ||
| 3202 | +TEST_F(HcomKernelInfoTest, ut_AllReduceOpKernel_OpenSource) | ||
| 3203 | +{ | ||
| 3204 | + // 测试开源版本的HcomAllReduceOpKernel | ||
| 3205 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3206 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 3207 | + ge::RunContext runContext; | ||
| 3208 | + std::vector<domi::TaskDef> taskDefList; | ||
| 3209 | + | ||
| 3210 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 3211 | + MOCKER(IsUsingOpenSource) | ||
| 3212 | + .expects(atMost(1)) | ||
| 3213 | + .with(outBound(true)) | ||
| 3214 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3215 | + | ||
| 3216 | + // 模拟HcceAllReduceGraphMode函数 | ||
| 3217 | + MOCKER(HcceAllReduceGraphMode) | ||
| 3218 | + .expects(atMost(1)) | ||
| 3219 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3220 | + | ||
| 3221 | + // 测试HcomAllReduceOpKernel方法 | ||
| 3222 | + HcclResult ret = hcomKernelInfo.HcomAllReduceOpKernel(*nodeptr, runContext, taskDefList); | ||
| 3223 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 3224 | + | ||
| 3225 | + GlobalMockObject::verify(); | ||
| 3226 | +} | ||
| 3227 | + | ||
| 3228 | +TEST_F(HcomKernelInfoTest, ut_AllGatherOpKernel_OpenSource) | ||
| 3229 | +{ | ||
| 3230 | + // 测试开源版本的HcomAllGatherOpKernel | ||
| 3231 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3232 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 3233 | + ge::RunContext runContext; | ||
| 3234 | + std::vector<domi::TaskDef> taskDefList; | ||
| 3235 | + | ||
| 3236 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 3237 | + MOCKER(IsUsingOpenSource) | ||
| 3238 | + .expects(atMost(1)) | ||
| 3239 | + .with(outBound(true)) | ||
| 3240 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3241 | + | ||
| 3242 | + // 模拟HcceAllGatherGraphMode函数 | ||
| 3243 | + MOCKER(HcceAllGatherGraphMode) | ||
| 3244 | + .expects(atMost(1)) | ||
| 3245 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3246 | + | ||
| 3247 | + // 测试HcomAllGatherOpKernel方法 | ||
| 3248 | + HcclResult ret = hcomKernelInfo.HcomAllGatherOpKernel(*nodeptr, runContext, taskDefList); | ||
| 3249 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 3250 | + | ||
| 3251 | + GlobalMockObject::verify(); | ||
| 3252 | +} | ||
| 3253 | + | ||
| 3254 | +TEST_F(HcomKernelInfoTest, ut_ReduceScatterOpKernel_OpenSource) | ||
| 3255 | +{ | ||
| 3256 | + // 测试开源版本的HcomReduceScatterOpKernel | ||
| 3257 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3258 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 3259 | + ge::RunContext runContext; | ||
| 3260 | + std::vector<domi::TaskDef> taskDefList; | ||
| 3261 | + | ||
| 3262 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 3263 | + MOCKER(IsUsingOpenSource) | ||
| 3264 | + .expects(atMost(1)) | ||
| 3265 | + .with(outBound(true)) | ||
| 3266 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3267 | + | ||
| 3268 | + // 模拟HcceReduceScatterGraphMode函数 | ||
| 3269 | + MOCKER(HcceReduceScatterGraphMode) | ||
| 3270 | + .expects(atMost(1)) | ||
| 3271 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3272 | + | ||
| 3273 | + // 测试HcomReduceScatterOpKernel方法 | ||
| 3274 | + HcclResult ret = hcomKernelInfo.HcomReduceScatterOpKernel(*nodeptr, runContext, taskDefList); | ||
| 3275 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 3276 | + | ||
| 3277 | + GlobalMockObject::verify(); | ||
| 3278 | +} | ||
| 3279 | + | ||
| 3280 | +TEST_F(HcomKernelInfoTest, ut_BroadcastOpKernel_OpenSource) | ||
| 3281 | +{ | ||
| 3282 | + // 测试开源版本的HcomBroadcastOpKernel | ||
| 3283 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3284 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 3285 | + ge::RunContext runContext; | ||
| 3286 | + std::vector<domi::TaskDef> taskDefList; | ||
| 3287 | + | ||
| 3288 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 3289 | + MOCKER(IsUsingOpenSource) | ||
| 3290 | + .expects(atMost(1)) | ||
| 3291 | + .with(outBound(true)) | ||
| 3292 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3293 | + | ||
| 3294 | + // 模拟HcceBroadcastGraphMode函数 | ||
| 3295 | + MOCKER(HcceBroadcastGraphMode) | ||
| 3296 | + .expects(atMost(1)) | ||
| 3297 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3298 | + | ||
| 3299 | + // 测试HcomBroadcastOpKernel方法 | ||
| 3300 | + HcclResult ret = hcomKernelInfo.HcomBroadcastOpKernel(*nodeptr, runContext, taskDefList); | ||
| 3301 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 3302 | + | ||
| 3303 | + GlobalMockObject::verify(); | ||
| 3304 | +} | ||
| 3305 | + | ||
| 3306 | +TEST_F(HcomKernelInfoTest, ut_AlltoAllOpKernel_OpenSource) | ||
| 3307 | +{ | ||
| 3308 | + // 测试开源版本的HcomAlltoAllOpKernel | ||
| 3309 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3310 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 3311 | + ge::RunContext runContext; | ||
| 3312 | + std::vector<domi::TaskDef> taskDefList; | ||
| 3313 | + | ||
| 3314 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 3315 | + MOCKER(IsUsingOpenSource) | ||
| 3316 | + .expects(atMost(1)) | ||
| 3317 | + .with(outBound(true)) | ||
| 3318 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3319 | + | ||
| 3320 | + // 模拟HcceAlltoAllGraphMode函数 | ||
| 3321 | + MOCKER(HcceAlltoAllGraphMode) | ||
| 3322 | + .expects(atMost(1)) | ||
| 3323 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3324 | + | ||
| 3325 | + // 测试HcomAlltoAllOpKernel方法 | ||
| 3326 | + HcclResult ret = hcomKernelInfo.HcomAlltoAllOpKernel(*nodeptr, runContext, taskDefList); | ||
| 3327 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 3328 | + | ||
| 3329 | + GlobalMockObject::verify(); | ||
| 3330 | +} | ||
| 3331 | + | ||
| 3332 | +TEST_F(HcomKernelInfoTest, ut_AlltoAllVOpKernel_OpenSource) | ||
| 3333 | +{ | ||
| 3334 | + // 测试开源版本的HcomAlltoAllVOpKernel | ||
| 3335 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3336 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 3337 | + ge::RunContext runContext; | ||
| 3338 | + std::vector<domi::TaskDef> taskDefList; | ||
| 3339 | + | ||
| 3340 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 3341 | + MOCKER(IsUsingOpenSource) | ||
| 3342 | + .expects(atMost(1)) | ||
| 3343 | + .with(outBound(true)) | ||
| 3344 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3345 | + | ||
| 3346 | + // 模拟HcceAlltoAllVGraphMode函数 | ||
| 3347 | + MOCKER(HcceAlltoAllVGraphMode) | ||
| 3348 | + .expects(atMost(1)) | ||
| 3349 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3350 | + | ||
| 3351 | + // 测试HcomAlltoAllVOpKernel方法 | ||
| 3352 | + HcclResult ret = hcomKernelInfo.HcomAlltoAllVOpKernel(*nodeptr, runContext, taskDefList); | ||
| 3353 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 3354 | + | ||
| 3355 | + GlobalMockObject::verify(); | ||
| 3356 | +} | ||
| 3357 | + | ||
| 3358 | +TEST_F(HcomKernelInfoTest, ut_AlltoAllVCOpKernel_OpenSource) | ||
| 3359 | +{ | ||
| 3360 | + // 测试开源版本的HcomAlltoAllVCOpKernel | ||
| 3361 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3362 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 3363 | + ge::RunContext runContext; | ||
| 3364 | + std::vector<domi::TaskDef> taskDefList; | ||
| 3365 | + | ||
| 3366 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 3367 | + MOCKER(IsUsingOpenSource) | ||
| 3368 | + .expects(atMost(1)) | ||
| 3369 | + .with(outBound(true)) | ||
| 3370 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3371 | + | ||
| 3372 | + // 模拟HcceAlltoAllVCGraphMode函数 | ||
| 3373 | + MOCKER(HcceAlltoAllVCGraphMode) | ||
| 3374 | + .expects(atMost(1)) | ||
| 3375 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3376 | + | ||
| 3377 | + // 测试HcomAlltoAllVCOpKernel方法 | ||
| 3378 | + HcclResult ret = hcomKernelInfo.HcomAlltoAllVCOpKernel(*nodeptr, runContext, taskDefList); | ||
| 3379 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 3380 | + | ||
| 3381 | + GlobalMockObject::verify(); | ||
| 3382 | +} | ||
| 3383 | + | ||
| 3384 | +TEST_F(HcomKernelInfoTest, ut_ReduceScatterVOpKernel_OpenSource) | ||
| 3385 | +{ | ||
| 3386 | + // 测试开源版本的HcomReduceScatterVOpKernel | ||
| 3387 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3388 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 3389 | + ge::RunContext runContext; | ||
| 3390 | + std::vector<domi::TaskDef> taskDefList; | ||
| 3391 | + | ||
| 3392 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 3393 | + MOCKER(IsUsingOpenSource) | ||
| 3394 | + .expects(atMost(1)) | ||
| 3395 | + .with(outBound(true)) | ||
| 3396 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3397 | + | ||
| 3398 | + // 模拟HcceReduceScatterVGraphMode函数 | ||
| 3399 | + MOCKER(HcceReduceScatterVGraphMode) | ||
| 3400 | + .expects(atMost(1)) | ||
| 3401 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3402 | + | ||
| 3403 | + // 测试HcomReduceScatterVOpKernel方法 | ||
| 3404 | + HcclResult ret = hcomKernelInfo.HcomReduceScatterVOpKernel(*nodeptr, runContext, taskDefList); | ||
| 3405 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 3406 | + | ||
| 3407 | + GlobalMockObject::verify(); | ||
| 3408 | +} | ||
| 3409 | + | ||
| 3410 | +TEST_F(HcomKernelInfoTest, ut_SendOpKernel_OpenSource) | ||
| 3411 | +{ | ||
| 3412 | + // 测试开源版本的HcomSendOpKernel | ||
| 3413 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3414 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 3415 | + ge::RunContext runContext; | ||
| 3416 | + std::vector<domi::TaskDef> taskDefList; | ||
| 3417 | + | ||
| 3418 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 3419 | + MOCKER(IsUsingOpenSource) | ||
| 3420 | + .expects(atMost(1)) | ||
| 3421 | + .with(outBound(true)) | ||
| 3422 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3423 | + | ||
| 3424 | + // 模拟HcceSendGraphMode函数 | ||
| 3425 | + MOCKER(HcceSendGraphMode) | ||
| 3426 | + .expects(atMost(1)) | ||
| 3427 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3428 | + | ||
| 3429 | + // 测试HcomSendOpKernel方法 | ||
| 3430 | + HcclResult ret = hcomKernelInfo.HcomSendOpKernel(*nodeptr, runContext, taskDefList); | ||
| 3431 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 3432 | + | ||
| 3433 | + GlobalMockObject::verify(); | ||
| 3434 | +} | ||
| 3435 | + | ||
| 3436 | +TEST_F(HcomKernelInfoTest, ut_ReceiveOpKernel_OpenSource) | ||
| 3437 | +{ | ||
| 3438 | + // 测试开源版本的HcomReceiveOpKernel | ||
| 3439 | + HcomOpsKernelInfoStore hcomKernelInfo; | ||
| 3440 | + ge::NodePtr nodeptr(new NodeTest); | ||
| 3441 | + ge::RunContext runContext; | ||
| 3442 | + std::vector<domi::TaskDef> taskDefList; | ||
| 3443 | + | ||
| 3444 | + // 模拟IsUsingOpenSource返回true,使用开源版本 | ||
| 3445 | + MOCKER(IsUsingOpenSource) | ||
| 3446 | + .expects(atMost(1)) | ||
| 3447 | + .with(outBound(true)) | ||
| 3448 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3449 | + | ||
| 3450 | + // 模拟HcceRecvGraphMode函数 | ||
| 3451 | + MOCKER(HcceRecvGraphMode) | ||
| 3452 | + .expects(atMost(1)) | ||
| 3453 | + .will(returnValue(HCCL_SUCCESS)); | ||
| 3454 | + | ||
| 3455 | + // 测试HcomReceiveOpKernel方法 | ||
| 3456 | + HcclResult ret = hcomKernelInfo.HcomReceiveOpKernel(*nodeptr, runContext, taskDefList); | ||
| 3457 | + EXPECT_EQ(ret, HCCL_SUCCESS); | ||
| 3458 | + | ||
| 3459 | + GlobalMockObject::verify(); | ||
| 3460 | +} | ||
| 3461 | + | ||
| 3196 | TEST_F(HcomKernelInfoTest, ut_CleanInterMemoryV2_When_MemAsyncCopyFail_Expect_ReturnHCCL_E_INTERNAL) | 3462 | TEST_F(HcomKernelInfoTest, ut_CleanInterMemoryV2_When_MemAsyncCopyFail_Expect_ReturnHCCL_E_INTERNAL) |
| 3197 | { | 3463 | { |
| 3198 | HcomOpsKernelInfoStore hcomKernelInfo; | 3464 | HcomOpsKernelInfoStore hcomKernelInfo; |


是否需要返回错误?会不会影响老流程