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 CUPT_KERNEL_CCU_CONTEXT_ALLGATHER_NHR_1D_H_
12 : #define CUPT_KERNEL_CCU_CONTEXT_ALLGATHER_NHR_1D_H_
13 : #include <vector>
14 :
15 : #include <ios>
16 : #include "log.h"
17 : #include "ccu_context_alg_base.h"
18 : #include "ccu_datatype.h"
19 : #include "ccu_instruction_all_gather_nhr1d_mem2mem.h"
20 :
21 : namespace Hccl {
22 :
23 : class CcuContextAllGatherNHR1D : public CcuContextAlgBase {
24 : public:
25 : CcuContextAllGatherNHR1D(const CcuCtxArg &arg, const std::vector<CcuTransport *> &transports,
26 : const CcuTransportGroup &group);
27 0 : ~CcuContextAllGatherNHR1D() override
28 0 : {
29 0 : }
30 :
31 : void Algorithm() override;
32 : std::vector<uint64_t> GeneArgs(const CcuTaskArg &arg) override;
33 :
34 : private:
35 : void LoadArgs();
36 : void InitResources();
37 : void PreSync();
38 : void PostSync();
39 : void AxisSync(uint32_t signalIndex);
40 : void DoRepeatAllGatherNHR();
41 : void DoRepeatAllGatherNHRSingleStep(const NHRStepInfo &nhrStepInfo);
42 : void DoRepeatSendRecvSlices(const u32 &toRank, CcuRep::Memory &src, CcuRep::Memory &dst, u32 signalIndex);
43 :
44 : // 构造函数中
45 : uint64_t dimSize_{0};
46 : uint32_t axisId_{0};
47 : uint32_t axisSize_{0};
48 : uint32_t localSize_{0}; // 本rank所在行或列的总rank数
49 : uint32_t myRankIdx_{0};
50 : uint32_t signalNum_{0}; // 需要使用的signal数量
51 :
52 : std::vector<NHRStepInfo> stepInfoVector_; // nhr算法执行过程中的参数
53 : std::map<u32, u32> indexMap_;
54 :
55 : // load进来参数
56 : CcuRep::Variable input_;
57 : std::vector<CcuRep::Variable> output_;
58 : std::vector<CcuRep::Variable> token_;
59 : CcuRep::Variable die0Size_;
60 : CcuRep::Variable die1Size_;
61 : CcuRep::Variable inputSliceStride_;
62 : CcuRep::Variable outputSliceStride_;
63 : CcuRep::Variable inputRepeatStride_;
64 : CcuRep::Variable outputRepeatStride_;
65 : CcuRep::Variable repeatNum_;
66 : CcuRep::Variable isInputOutputEqual_;
67 : CcuRep::Variable myrankInputSliceOffset_;
68 : CcuRep::Variable tmpSliceOffset_;
69 : std::vector<CcuRep::Variable> outputSliceOffset_;
70 : CcuRep::Variable tmpRepeatNum_;
71 : CcuRep::Variable tmpCopyRepeatNum_;
72 : CcuRep::Variable constVar1_;
73 : CcuRep::Variable ckeBitCounter_;
74 : CcuRep::Variable repeatTimeflag_;
75 :
76 : // 跨轴同步信号
77 : std::string localAxisSignalName_;
78 : std::string anotherAxisSignalName_;
79 : CcuRep::MaskSignal localAxisSignal_;
80 : CcuRep::MaskSignal anotherAxisSignal_;
81 : CcuRep::MaskSignal localSignal_;
82 :
83 : CcuRep::Memory srcMem_;
84 : CcuRep::Memory dstMem_;
85 : };
86 : } // namespace Hccl
87 :
88 : #endif // HCCLV2_CCU_CONTEXT_ALL_GATHER_NHR_1D_H_
|