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 "all_gather_ahc_broke.h"
12 : #include "alg_template_register.h"
13 :
14 : namespace hccl {
15 :
16 0 : AllGatherAHCBroke::AllGatherAHCBroke(const HcclDispatcher dispatcher) : AllGatherAHCBase(dispatcher) {}
17 :
18 0 : AllGatherAHCBroke::~AllGatherAHCBroke() {}
19 :
20 0 : HcclResult AllGatherAHCBroke::DisposeSubGroups(const u32 rank)
21 : {
22 0 : CommAHCBaseInfo::DisposeSubGroups(rank, globalSubGroups_, level0SubGroups_, level1SubGroups_);
23 0 : return HCCL_SUCCESS;
24 : }
25 :
26 0 : HcclResult AllGatherAHCBroke::CommAHCInfoInit()
27 : {
28 0 : commAHCBaseInfo_.reset(new (std::nothrow) CommBrokeAlignInfo(level0SubGroups_));
29 0 : CHK_SMART_PTR_NULL(commAHCBaseInfo_);
30 0 : CHK_RET(commAHCBaseInfo_->Init(AHCOpType::AHC_OP_TYPE_ALLGATHER, ahcAlgOption_));
31 0 : return HCCL_SUCCESS;
32 : }
33 :
34 0 : HcclResult AllGatherAHCBroke::RunInterAllGather(
35 : const u32 rank, const std::vector<LINK>& links, const std::unique_ptr<CommAHCBaseInfo>& commAHCBaseInfo)
36 : {
37 0 : HCCL_INFO("[AllGatherAHCBroke][RunInterAllGather] begin inter AllGather rank[%u]", rank);
38 :
39 : // 创建执行算子实列
40 0 : std::unique_ptr<AlgTemplateBase> tempAlg;
41 0 : commAHCBaseInfo->GetInterAlgTemplateOpInstance(
42 0 : AHCOpType::AHC_OP_TYPE_ALLGATHER, tempAlg, dispatcher_, reduceAttr_, extendFlag_, ahcExtendPreparePara_);
43 :
44 0 : std::vector<std::vector<Slice>> interSlicesVector;
45 0 : std::vector<std::vector<LINK>> interLinksVector;
46 0 : std::vector<u32> interRankList;
47 0 : CHK_RET(commAHCBaseInfo->CalcInterSlicesAndLinks(
48 : rank, DataUnitSize(dataType_), count_, links, interLinksVector, interSlicesVector, interRankList));
49 :
50 0 : HCCL_DEBUG("[AllGatherAHCBroke][RunInterAllGather] run inst rank[%u]", rank);
51 :
52 0 : for (u32 i = 0; i < interLinksVector.size(); i++) {
53 0 : std::vector<Slice> interSlices = interSlicesVector[i];
54 0 : std::vector<LINK> interLinks = interLinksVector[i];
55 0 : if (interLinks.size() <= 1) {
56 0 : continue;
57 : }
58 0 : HCCL_DEBUG("[AllGatherAHCBroke][AHCDEBUG] rank[%u] group[%u] interRank[%u]", rank, i, interRankList[i]);
59 0 : CHK_RET(RunInstance(interRankList[i], interLinks, interSlices, tempAlg, AHCOpType::AHC_OP_TYPE_ALLGATHER));
60 0 : }
61 :
62 0 : HCCL_DEBUG("[AllGatherAHCBroke][RunInterAllGather] end inter AllGather rank[%u]", rank);
63 :
64 0 : return HCCL_SUCCESS;
65 0 : }
66 : REGISTER_TEMPLATE(TemplateType::TEMPLATE_ALL_GATHER_AHC_BROKE, AllGatherAHCBroke);
67 : } // namespace hccl
|