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 : #ifndef COLL_ALLTOALL_COMM_EXECUTOR_H
12 : #define COLL_ALLTOALL_COMM_EXECUTOR_H
13 : #include "coll_comm_executor.h"
14 : namespace hccl {
15 : constexpr u32 MINORS_NUM_TWO = 2;
16 : constexpr u64 SMALL_SIZE_FULLMESH = 262144;
17 :
18 : class CollAlltoAllExecutor : public CollNativeExecutorBase {
19 : public:
20 : CollAlltoAllExecutor(const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher);
21 5 : ~CollAlltoAllExecutor() override = default;
22 :
23 : HcclResult Orchestrate(OpParam& param, AlgResourceResponse& algRes) override;
24 : HcclResult GetAdjInfo(AlgResourceResponse& algRes, AdjInfo& adjInfo) override;
25 : virtual HcclResult
26 : SetExcutorExtraInfo(const std::vector<SendRecvInfo>& allMeshAggregationSendRecvInfo, u64 cclbufferSize);
27 : HcclResult CalcResRequest(const OpParam& param, AlgResourceRequest& resourceRequest) override;
28 : virtual HcclResult CheckNeedCreateVirtualLinks(AlgResourceRequest& resourceRequest);
29 :
30 : HcclResult SetVirtualDispatcher(const HcclDispatcher virtualDispatcher);
31 :
32 : HcclResult SetParallelTaskLoader(ParallelTaskLoader* parallelTaskLoader);
33 :
34 : virtual HcclResult CheckNeedRecreateComm(u64 lastScratchMemSize, bool& needRecreateAlltoallComm);
35 : static HcclResult
36 : RunAlltoAllTemplate(const std::unique_ptr<AlgTemplateBase>& executor, const SubCommInfo& commInfo);
37 : static HcclResult
38 : RunAlltoAllVTemplateStaged(const std::unique_ptr<AlgTemplateBase>& executor, const SubCommInfo& commInfo);
39 : static HcclResult
40 : RunTemplateWithVirtualLink(const std::unique_ptr<AlgTemplateBase>& executor, const SubCommInfo& commInfo);
41 :
42 : protected:
43 : /* *************** 算法编排 *************** */
44 : // 公共接口
45 : virtual HcclOpMetaInfo GetOpMeta(HcclCMDType opType, const u64 size);
46 : void UpdateAlltoAllZCopyMode(std::vector<SendRecvInfo>& allMeshAggregationSendRecvInfo, u64 cclbufferSize);
47 : void CalcIntraMeshAggregationAlltoAllMemInfo(
48 : const AlltoAllUserRankInfo& userRankInfo, const std::vector<SendRecvInfo>& allSendRecvInfo,
49 : std::map<u32, std::list<OneSendRecvAddrInfo>>& sendAddrInfosIntra,
50 : std::map<u32, std::list<OneSendRecvAddrInfo>>& recvAddrInfosIntra, u32 meshAggregationRankSize,
51 : const bool& isSingleMesh);
52 : void CalcIntraMeshAggregationSendInfo(
53 : const AlltoAllUserRankInfo& userRankInfo, const SendRecvInfo& mySendRecvInfo,
54 : const std::vector<SendRecvInfo>& myMeshAggregationSendRecvInfo, u32 rankInMeshAggregation, u32 infoIndex,
55 : OneSendRecvAddrInfo& curSendInfo, u32 meshAggregationRankSize, const bool& isSingleMesh);
56 : void CalcIntraMeshAggregationRecvInfo(
57 : const AlltoAllUserRankInfo& userRankInfo, const std::vector<SendRecvInfo>& myMeshAggregationSendRecvInfo,
58 : u32 infoIndex, OneSendRecvAddrInfo& curRecvInfo, u32 meshAggregationRankSize, const bool& isSingleMesh);
59 : void CalcIntraMeshAggregationRecvInfoInMeshAggregation(
60 : u32 rankIndex, u32 infoIndex, const std::vector<SendRecvInfo>& myMeshAggregationSendRecvInfo, u64& localOffset,
61 : u32& offsetCounter, u64& localLength, u64& remoteOffset, u32 meshAggregationRankSize);
62 : u64 CalAlltoAllVScratchMemSize(u64& workSpaceMemSize);
63 : bool HasMassTasks(std::vector<SendRecvInfo>& allMeshAggregationSendRecvInfo);
64 :
65 : OpParam AlltoAllVParam_;
66 : std::vector<SendRecvInfo> allMeshAggregationSendRecvInfo_;
67 : SendRecvInfo localSendRecvInfo_;
68 : bool isAlltoAllZCopyMode_ = false;
69 :
70 : HcclDispatcher vDispatcher_;
71 :
72 : ParallelTaskLoader* parallelTaskLoader_; // 并行下发taskloader管理
73 : };
74 :
75 : } // namespace hccl
76 :
77 : #endif
|