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 SetExcutorExtraInfo(const std::vector<SendRecvInfo> &allMeshAggregationSendRecvInfo, u64 cclbufferSize);
26 : HcclResult CalcResRequest(const OpParam& param, AlgResourceRequest &resourceRequest) override;
27 : virtual HcclResult CheckNeedCreateVirtualLinks(AlgResourceRequest &resourceRequest);
28 :
29 : HcclResult SetVirtualDispatcher(const HcclDispatcher virtualDispatcher);
30 :
31 : HcclResult SetParallelTaskLoader(ParallelTaskLoader *parallelTaskLoader);
32 :
33 : virtual HcclResult CheckNeedRecreateComm(u64 lastScratchMemSize, bool& needRecreateAlltoallComm);
34 : static HcclResult RunAlltoAllTemplate(const std::unique_ptr<AlgTemplateBase> &executor,
35 : const SubCommInfo &commInfo);
36 : static HcclResult RunAlltoAllVTemplateStaged(const std::unique_ptr<AlgTemplateBase> &executor,
37 : const SubCommInfo &commInfo);
38 : static HcclResult RunTemplateWithVirtualLink(const std::unique_ptr<AlgTemplateBase> &executor,
39 : const SubCommInfo &commInfo);
40 :
41 : protected:
42 : /* *************** 算法编排 *************** */
43 : // 公共接口
44 : virtual HcclOpMetaInfo GetOpMeta(HcclCMDType opType, const u64 size);
45 : void UpdateAlltoAllZCopyMode(std::vector<SendRecvInfo> &allMeshAggregationSendRecvInfo, u64 cclbufferSize);
46 : void CalcIntraMeshAggregationAlltoAllMemInfo(const AlltoAllUserRankInfo &userRankInfo,
47 : const std::vector<SendRecvInfo> &allSendRecvInfo,
48 : std::map<u32, std::list<OneSendRecvAddrInfo>> &sendAddrInfosIntra,
49 : std::map<u32, std::list<OneSendRecvAddrInfo>> &recvAddrInfosIntra, u32 meshAggregationRankSize,
50 : const bool &isSingleMesh);
51 : void CalcIntraMeshAggregationSendInfo(const AlltoAllUserRankInfo &userRankInfo,
52 : const SendRecvInfo &mySendRecvInfo, const std::vector<SendRecvInfo> &myMeshAggregationSendRecvInfo,
53 : u32 rankInMeshAggregation, u32 infoIndex, OneSendRecvAddrInfo &curSendInfo, u32 meshAggregationRankSize,
54 : const bool &isSingleMesh);
55 : void CalcIntraMeshAggregationRecvInfo(const AlltoAllUserRankInfo &userRankInfo,
56 : const std::vector<SendRecvInfo> &myMeshAggregationSendRecvInfo, u32 infoIndex, OneSendRecvAddrInfo &curRecvInfo,
57 : u32 meshAggregationRankSize, const bool &isSingleMesh);
58 : void CalcIntraMeshAggregationRecvInfoInMeshAggregation(u32 rankIndex, u32 infoIndex,
59 : const std::vector<SendRecvInfo> &myMeshAggregationSendRecvInfo, u64 &localOffset, u32 &offsetCounter,
60 : u64 &localLength, u64 &remoteOffset, u32 meshAggregationRankSize);
61 : u64 CalAlltoAllVScratchMemSize(u64 &workSpaceMemSize);
62 : bool HasMassTasks(std::vector<SendRecvInfo> &allMeshAggregationSendRecvInfo);
63 :
64 : OpParam AlltoAllVParam_;
65 : std::vector<SendRecvInfo> allMeshAggregationSendRecvInfo_;
66 : SendRecvInfo localSendRecvInfo_;
67 : bool isAlltoAllZCopyMode_ = false;
68 :
69 : HcclDispatcher vDispatcher_;
70 :
71 : ParallelTaskLoader* parallelTaskLoader_; // 并行下发taskloader管理
72 : };
73 :
74 : } // namespace hccl
75 :
76 : #endif
|