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_GATHER_MESH_2D_H_
12 : #define HCCLV2_CCU_CONTEXT_ALL_GATHER_MESH_2D_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 :
21 : namespace Hccl {
22 :
23 : class CcuContextAllGatherMesh2D : public CcuContextAlgBase {
24 : public:
25 : CcuContextAllGatherMesh2D(
26 : const CcuCtxArg& arg, const std::vector<CcuTransport*>& transports, const CcuTransportGroup& group);
27 0 : ~CcuContextAllGatherMesh2D() override {}
28 :
29 : void Algorithm() override;
30 : std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
31 :
32 : private:
33 : void InitResources();
34 : void LoadArgs();
35 : void ExchangeInfoAndSync();
36 : void RankSync(uint32_t signalIndex);
37 : void AxisSync(uint32_t signalIndex);
38 : void FirstStep();
39 : void SecondStep();
40 :
41 : std::vector<uint64_t> dimSize_;
42 : uint32_t axisId_{0}; // 0 : X轴, 1 : Y轴
43 : uint32_t rankId_{0};
44 : std::vector<uint32_t> dimId_; // 本rank所在行或列的编号
45 : uint32_t localId_{0}; // 本chip所在行或列的编号
46 : uint32_t localSize_{0}; // 本rank所在行或列的总rank数
47 :
48 : // 从外部获取的参数
49 : std::vector<CcuRep::Variable> input_;
50 : std::vector<CcuRep::Variable> output_;
51 : std::vector<CcuRep::Variable> token_;
52 :
53 : CcuRep::Variable xAxisSize_; // 沿X轴搬移的数据量大小
54 : CcuRep::Variable yAxisSize_; // 沿Y轴搬移的数据量大小
55 : CcuRep::Variable offset_; // Rank偏移+loop偏移
56 : CcuRep::Variable sliceSize_; // aSize + bSize 应该可以去掉
57 :
58 : CcuRep::Variable firstInOffset_;
59 : CcuRep::Variable firstOutOffset_;
60 : CcuRep::Variable secondInOutBaseOffset_;
61 : CcuRep::Variable secondInOutStepOffset_;
62 :
63 : GroupOpSize goASize_;
64 : GroupOpSize goBSize_;
65 :
66 : // 跨轴同步信号
67 : std::string localAxisSignalName_;
68 : std::string anotherAxisSignalName_;
69 : CcuRep::MaskSignal localAxisSignal_;
70 : CcuRep::MaskSignal anotherAxisSignal_;
71 : };
72 : } // namespace Hccl
73 :
74 : #endif // HCCLV2_CCU_CONTEXT_ALL_GATHER_MESH_2D_H_
|