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