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_broadcast_for_310p_comm_executor.h"
12 :
13 : namespace hccl {
14 0 : CollBroadcastFor310PCommExecutor::CollBroadcastFor310PCommExecutor(const HcclDispatcher dispatcher,
15 0 : std::unique_ptr<TopoMatcher> &topoMatcher)
16 0 : : CollBroadcastExecutor(dispatcher, topoMatcher)
17 : {
18 0 : }
19 :
20 0 : HcclResult CollBroadcastFor310PCommExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
21 : {
22 0 : TransportMemType inputType = TransportMemType::RESERVED;
23 0 : TransportMemType outputType = TransportMemType::RESERVED;
24 0 : CHK_RET(CalcTransportMemType(inputType, outputType));
25 0 : CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
26 0 : return HCCL_SUCCESS;
27 : }
28 :
29 :
30 0 : HcclResult CollBroadcastFor310PCommExecutor::CalcLevel0CommInfo(TransportMemType inputType,
31 : TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
32 : {
33 0 : HCCL_INFO("[CollBroadcastFor310PCommExecutor][CalcLevel0CommInfo]tag[%s] start", tag_.c_str());
34 0 : CommParaInfo commParaLevel0(COMM_LEVEL0, CommType::COMM_TAG_RING_INNER);
35 0 : CHK_RET(CalcCommPlaneInfo(tag_, commParaLevel0, opTransport[COMM_LEVEL0], inputType, outputType));
36 0 : HCCL_INFO("[CollBroadcastFor310PCommExecutor][CalcLevel0CommInfo]tag[%s] Calc RingComm finish", tag_.c_str());
37 0 : return HCCL_SUCCESS;
38 0 : }
39 :
40 0 : HcclResult CollBroadcastFor310PCommExecutor::KernelRun(const OpParam ¶m, ExecMem &execMem)
41 : {
42 0 : HCCL_CONFIG_INFO(HCCL_ALG,
43 : "[CollBroadcastFor310PCommExecutor][KernelRun] userRank[%u] starts.", topoAttr_.userRank);
44 0 : CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
45 0 : SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
46 0 : std::unique_ptr<AlgTemplateBase> tempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
47 0 : TemplateType::TEMPLATE_BROADCAST_RING, dispatcher_);
48 0 : CHK_SMART_PTR_NULL(tempAlg);
49 : // 获取root
50 0 : u32 rootRank = 0;
51 0 : CHK_RET(GetRankByUserRank(COMM_LEVEL0, COMM_INDEX_0, param.root, rootRank));
52 :
53 0 : CHK_RET(tempAlg->Prepare(execMem.inputMem, execMem.outputMem, execMem.outputMem, execMem.count,
54 : param.DataDes.dataType, param.stream, HCCL_REDUCE_RESERVED, param.root));
55 :
56 0 : u32 rankSize = level0CommInfo.localRankSize;
57 0 : CHK_RET(tempAlg->RegisterProfiler(
58 : (rankSize << PROF_RANKSIZE_OFFSET_OF_PLANEID) + level0CommInfo.localRank,
59 : PROF_STAGE_0, HCCL_EXEC_STEP_NOT_SET, param.stream));
60 :
61 0 : CHK_RET(RunTemplate(tempAlg, level0CommInfo));
62 0 : return HCCL_SUCCESS;
63 0 : }
64 :
65 : REGISTER_EXEC("BroadCastCommFor310P", BroadcastFor310PComm, CollBroadcastFor310PCommExecutor);
66 : } // namespace hccl
|