Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "coll_all_gather_slim_for_310p_executor.h"
12 :
13 : namespace hccl {
14 0 : CollAllGatherSlimFor310PExecutor::CollAllGatherSlimFor310PExecutor(
15 0 : const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
16 0 : : CollAllGatherExecutor(dispatcher, topoMatcher)
17 : {
18 0 : DMAReduceFlag_ = false;
19 0 : }
20 :
21 0 : HcclResult CollAllGatherSlimFor310PExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
22 : {
23 0 : TransportMemType inputType = TransportMemType::RESERVED;
24 0 : TransportMemType outputType = TransportMemType::RESERVED;
25 0 : CHK_RET(CalcTransportMemType(inputType, outputType));
26 0 : CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
27 0 : return HCCL_SUCCESS;
28 : }
29 :
30 : HcclResult
31 0 : CollAllGatherSlimFor310PExecutor::CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType)
32 : {
33 0 : if (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
34 0 : inputType = TransportMemType::CCL_INPUT;
35 0 : outputType = TransportMemType::CCL_OUTPUT;
36 : } else {
37 0 : inputType = TransportMemType::PARAM_INPUT;
38 0 : outputType = TransportMemType::PARAM_OUTPUT;
39 : }
40 0 : HCCL_INFO(
41 : "[CollAllGatherSlimFor310PExecutor][CalcTransportMemType]"
42 : "tag[%s] inputType[%d], outputType[%d]",
43 : tag_.c_str(), inputType, outputType);
44 0 : return HCCL_SUCCESS;
45 : }
46 :
47 0 : HcclResult CollAllGatherSlimFor310PExecutor::CalcLevel0CommInfo(
48 : TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
49 : {
50 0 : CommParaInfo commParaInfo(COMM_LEVEL0, CommType::COMM_TAG_RING_INNER);
51 0 : CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[COMM_LEVEL0], inputType, outputType));
52 0 : LevelNSubCommTransport& commTransportLevel0 = opTransport[COMM_LEVEL0];
53 0 : for (u32 subCommIndex = 0; subCommIndex < commTransportLevel0.size(); subCommIndex++) {
54 0 : for (auto& transportRequest : commTransportLevel0[subCommIndex].transportRequests) {
55 : // transportRequest.notifyNum = topoAttr_.nicList.size(); //卡间notify num数量
56 0 : transportRequest.notifyNum = HCCL_NIC_MAX_NUM; // 卡间notify num数量;
57 0 : HCCL_INFO(
58 : "[CollAllGatherSlimFor310PExecutor][CalcLevel0CommInfo] notifyNum[%u]", transportRequest.notifyNum);
59 : }
60 : }
61 0 : return HCCL_SUCCESS;
62 0 : }
63 :
64 0 : HcclResult CollAllGatherSlimFor310PExecutor::KernelRun(const OpParam& param, ExecMem& execMem)
65 : {
66 0 : HCCL_CONFIG_INFO(HCCL_ALG, "[CollAllGatherSlimFor310PExecutor] AllGather starts.");
67 0 : CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
68 0 : SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
69 :
70 : std::unique_ptr<AlgTemplateBase> tempAlg
71 0 : = AlgTemplateRegistry::Instance().GetAlgTemplate(TemplateType::TEMPLATE_ALL_GATHER_SLIM_RING, dispatcher_);
72 0 : CHK_SMART_PTR_NULL(tempAlg);
73 :
74 0 : CHK_RET(tempAlg->Prepare(
75 : execMem.inputMem, execMem.outputMem, execMem.outputMem, execMem.count, param.DataDes.dataType, param.stream,
76 : param.reduceType));
77 :
78 0 : u32 rankSize = level0CommInfo.localRankSize;
79 0 : CHK_RET(tempAlg->RegisterProfiler(
80 : (rankSize << PROF_RANKSIZE_OFFSET_OF_PLANEID) + level0CommInfo.localRank, PROF_STAGE_0, HCCL_EXEC_STEP_NOT_SET,
81 : param.stream));
82 :
83 0 : CHK_RET(RunTemplate(tempAlg, level0CommInfo));
84 0 : HCCL_INFO("AllGather for 310P run success");
85 :
86 0 : return HCCL_SUCCESS;
87 0 : }
88 :
89 : REGISTER_EXEC("AllGatherSlimRingFor310PExecutor", AllGatherSlimFor310P, CollAllGatherSlimFor310PExecutor);
90 :
91 : } // namespace hccl
|