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 HCCLV2_CCU_CONTEXT_ALL_TO_ALL_V_MESH_1D_H_
12 : #define HCCLV2_CCU_CONTEXT_ALL_TO_ALL_V_MESH_1D_H_
13 :
14 : #include <vector>
15 :
16 : #include <ios>
17 : #include "log.h"
18 : #include "ccu_context_alg_base.h"
19 : #include "ccu_datatype.h"
20 : #include "hccl_params_pub.h"
21 :
22 : namespace Hccl {
23 :
24 : class CcuContextAllToAllVMesh1D : public CcuContextAlgBase {
25 : public:
26 : CcuContextAllToAllVMesh1D(
27 : const CcuCtxArg& arg, const std::vector<CcuTransport*>& transports, const CcuTransportGroup& group);
28 0 : ~CcuContextAllToAllVMesh1D() override {}
29 :
30 : void Algorithm() override;
31 : std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
32 : static void RefreshArgs(CollOpParams opParams, u32 rankSize, std::vector<uint64_t>& args, const u32 myRank);
33 :
34 : protected:
35 : // a2a 对每个对端的发送接收信息
36 : struct A2AsingleSendRecvInfo {
37 : CcuRep::Variable tailSize;
38 : CcuRep::Variable loopNum;
39 : CcuRep::Variable sendOffset;
40 : CcuRep::Variable recvOffset;
41 : GroupOpSize tailGoSize;
42 : };
43 : void CreateVariables();
44 : void LoadAll2allSendRecvInfo(std::vector<A2AsingleSendRecvInfo>& sendRecvInfo);
45 : void LoadArgs();
46 : void PreSync();
47 : void PostSync();
48 : void DoAll2AllVMultiLoop();
49 : void CalcGroupSrcDst();
50 :
51 : private:
52 : std::vector<CcuRep::Variable> input_;
53 : std::vector<CcuRep::Variable> output_;
54 : std::vector<CcuRep::Variable> token_;
55 : CcuRep::Variable srcOffset_;
56 : CcuRep::Variable dstOffset_;
57 : std::vector<A2AsingleSendRecvInfo> sendRecvInfo_;
58 :
59 : CcuRep::Variable a2avXnAddr_;
60 : bool loadFromMem = false;
61 :
62 : std::vector<CcuRep::Memory> src_;
63 : std::vector<CcuRep::Memory> dst_;
64 :
65 : uint16_t selfBit_{0};
66 : uint16_t allBit_{0};
67 : uint16_t allOtherBit_{0};
68 :
69 : CcuRep::MaskSignal locMask_;
70 : CcuRep::Variable completedRankCount_;
71 : CcuRep::Variable xnMaxTransportSize_;
72 : GroupOpSize xnMaxTransportGoSize_;
73 : GroupOpSize localTailGoSize_;
74 : CcuRep::Variable xnConst1_;
75 :
76 : // 以下参数用于加载 MC2 参数
77 : CcuRep::Variable xnLength_;
78 : };
79 : } // namespace Hccl
80 :
81 : #endif // HCCLV2_CCU_CONTEXT_ALL_TO_ALL_V_MESH_1D_H_
|