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_RUN_ALLTOALLV_TWO_LEVEL_PIPELINE_H
12 : #define COLL_RUN_ALLTOALLV_TWO_LEVEL_PIPELINE_H
13 : #include "coll_all_to_all_executor.h"
14 : namespace hccl {
15 : class CollRunAlltoAllVStaged : public CollAlltoAllExecutor {
16 :
17 : public:
18 : CollRunAlltoAllVStaged(const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher> &topoMatcher);
19 0 : ~CollRunAlltoAllVStaged() override = default;
20 :
21 : HcclResult CheckNeedRecreateComm(u64 lastScratchMemSize, bool& needRecreateAlltoallComm) override;
22 : HcclResult CheckNeedCreateVirtualLinks(AlgResourceRequest &resourceRequest) override;
23 : HcclResult ParallelTaskLoaderProcess(const std::string &tag, Stream &stream, SubCommInfo &level0CommInfo,
24 : std::vector<Stream> &ringStreams);
25 :
26 : private:
27 : HcclResult CalcStreamNum(u32& streamNum) override;
28 : void CalcWorkSpaceMemSize(const AlltoAllUserRankInfo &userRankInfo,
29 : const std::vector<SendRecvInfo> &allMeshAggregationSendRecvInfo, u64 &workspaceMemSize,
30 : u32 meshAggregationRankSize);
31 : HcclResult CalcScratchMemSize(u64& scratchMemSize) override;
32 :
33 : HcclResult CalcLevel0CommInfo(TransportMemType inputType, TransportMemType outputType,
34 : std::vector<LevelNSubCommTransport>& opTransport) override;
35 : HcclResult CalcLevel1CommInfo(TransportMemType inputType, TransportMemType outputType,
36 : std::vector<LevelNSubCommTransport>& opTransport) override;
37 : HcclResult CalcLevel2CommInfo(TransportMemType inputType, TransportMemType outputType,
38 : std::vector<LevelNSubCommTransport>& opTransport) override;
39 : HcclResult CalStagedAlltoallVCommInfo(TransportMemType inputType, TransportMemType outputType,
40 : std::vector<LevelNSubCommTransport>& opTransport);
41 : HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport) override;
42 : HcclResult KernelRun(const OpParam ¶m, ExecMem &execMem) override;
43 :
44 : HcclResult PrepareAlltoAllVStaged1(DeviceMem &sendBuf, DeviceMem &recvBuf, DeviceMem &scratchMem,
45 : std::map<u32, std::list<OneSendRecvAddrInfo>> &sendAddrInfosIntra,
46 : std::map<u32, std::list<OneSendRecvAddrInfo>> &recvAddrInfosIntra,
47 : Stream &stream, const std::string &tag, std::unique_ptr<AlgTemplateBase> &alltoallLevel0,
48 : ExecMem &execMem);
49 : void CalcInterMeshAggregationRecvRemoteOffset(const AlltoAllUserRankInfo &userRankInfo,
50 : const std::vector<SendRecvInfo> &allSendRecvInfo, u32 index, u64 &remoteOffset, u32 meshAggregationRankSize);
51 : void CalcInterMeshAggregationAlltoAllMemInfo(
52 : const AlltoAllUserRankInfo &userRankInfo, const std::vector<SendRecvInfo> &allSendRecvInfo,
53 : std::map<u32, std::list<OneSendRecvAddrInfo>> &sendAddrInfosInter,
54 : std::map<u32, std::list<OneSendRecvAddrInfo>> &recvAddrInfosInter,
55 : u32 meshAggregationRankSize);
56 : HcclResult PrepareAlltoAllVStaged2(DeviceMem &recvBuf, DeviceMem &scratchMem,
57 : std::map<u32, std::list<OneSendRecvAddrInfo>> &sendAddrInfosInter,
58 : std::map<u32, std::list<OneSendRecvAddrInfo>> &recvAddrInfosInter,
59 : Stream &stream, const std::string &tag, std::unique_ptr<AlgTemplateBase> &alltoallLevel1,
60 : ExecMem &execMem);
61 : };
62 :
63 : } // namespace hccl
64 :
65 : #endif
|