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