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_for_310p_executor.h"
12 :
13 : namespace hccl {
14 4 : CollAllGatherFor310PExecutor::CollAllGatherFor310PExecutor(const HcclDispatcher dispatcher,
15 4 : std::unique_ptr<TopoMatcher> &topoMatcher)
16 4 : : CollAllGatherExecutor(dispatcher, topoMatcher)
17 : {
18 4 : DMAReduceFlag_ = false;
19 4 : }
20 :
21 4 : HcclResult CollAllGatherFor310PExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
22 : {
23 4 : TransportMemType inputType = TransportMemType::RESERVED;
24 4 : TransportMemType outputType = TransportMemType::RESERVED;
25 4 : CHK_RET(CalcTransportMemType(inputType, outputType));
26 4 : CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
27 3 : return HCCL_SUCCESS;
28 : }
29 :
30 4 : HcclResult CollAllGatherFor310PExecutor::CalcTransportMemType(TransportMemType &inputType,
31 : TransportMemType &outputType)
32 : {
33 4 : if (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
34 4 : inputType = TransportMemType::CCL_INPUT;
35 4 : outputType = TransportMemType::CCL_OUTPUT;
36 : } else {
37 0 : inputType = TransportMemType::PARAM_INPUT;
38 0 : outputType = TransportMemType::PARAM_OUTPUT;
39 : }
40 4 : HCCL_INFO("[CollAllGatherFor310PExecutor][CalcTransportMemType]" \
41 : "tag[%s] inputType[%d], outputType[%d]",
42 : tag_.c_str(), inputType, outputType);
43 4 : return HCCL_SUCCESS;
44 : }
45 :
46 4 : HcclResult CollAllGatherFor310PExecutor::CalcLevel0CommInfo(TransportMemType inputType,
47 : TransportMemType outputType,
48 : std::vector<LevelNSubCommTransport>& opTransport)
49 : {
50 4 : CommParaInfo commParaInfo(COMM_LEVEL0, CommType::COMM_TAG_RING_INNER);
51 4 : CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[COMM_LEVEL0], inputType, outputType));
52 4 : return HCCL_SUCCESS;
53 4 : }
54 :
55 0 : HcclResult CollAllGatherFor310PExecutor::KernelRun(const OpParam ¶m, ExecMem &execMem)
56 : {
57 0 : HCCL_CONFIG_INFO(HCCL_ALG, "[CollAllGatherFor310PExecutor] AllGather starts.");
58 0 : CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
59 0 : SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
60 :
61 0 : std::unique_ptr<AlgTemplateBase> tempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
62 0 : TemplateType::TEMPLATE_ALL_GATHER_RING, dispatcher_);
63 0 : CHK_SMART_PTR_NULL(tempAlg);
64 :
65 0 : CHK_RET(tempAlg->Prepare(execMem.inputMem, execMem.outputMem, execMem.outputMem, execMem.count,
66 : param.DataDes.dataType, param.stream, param.reduceType));
67 :
68 0 : u32 rankSize = level0CommInfo.localRankSize;
69 0 : CHK_RET(tempAlg->RegisterProfiler(
70 : (rankSize << PROF_RANKSIZE_OFFSET_OF_PLANEID) + level0CommInfo.localRank,
71 : PROF_STAGE_0, HCCL_EXEC_STEP_NOT_SET, param.stream));
72 :
73 0 : CHK_RET(RunTemplate(tempAlg, level0CommInfo));
74 0 : HCCL_INFO("[CollAllGatherFor310PExecutor]AllGather for 310P run success");
75 :
76 0 : return HCCL_SUCCESS;
77 0 : }
78 :
79 : REGISTER_EXEC("AllGatherFor310PExecutor", AllGatherFor310P, CollAllGatherFor310PExecutor);
80 :
81 : } // namespace hccl
|