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_SCATTER_NHR_1D_H_
12 : #define CUPT_KERNEL_CCU_CONTEXT_SCATTER_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_scatter_nhr1d_mem2mem.h"
20 :
21 : namespace Hccl {
22 : class CcuContextScatterNHR1DMem2Mem : public CcuContextAlgBase {
23 : public:
24 : CcuContextScatterNHR1DMem2Mem(
25 : const CcuCtxArg& arg, const std::vector<CcuTransport*>& transports, const CcuTransportGroup& group);
26 0 : ~CcuContextScatterNHR1DMem2Mem() override {}
27 :
28 : void Algorithm() override;
29 : std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
30 :
31 : private:
32 : void LoadArgs();
33 : void InitResources();
34 : void PreSync();
35 : void PostSync();
36 :
37 : void AxisSync(uint32_t signalIndex);
38 : void DoScatterNHR();
39 : void DoScatterNHRSingleStep(const NHRStepInfo& nhrStepInfo);
40 : void DoSendRecvSlice(const u32& toRank, CcuRep::Memory& src, CcuRep::Memory& dst, u32 signalIndex);
41 :
42 : // 构造函数中
43 : uint32_t rootId_{0};
44 : uint64_t dimSize_{0};
45 : uint32_t axisId_{0};
46 : uint32_t axisSize_{0};
47 : uint32_t localSize_{0}; // 本rank所在行或列的总rank数
48 : uint32_t myRankIdx_{0};
49 : uint32_t signalNum_{0}; // 需要使用的signal数量
50 : uint32_t repeatNum_{0};
51 : DataType dataType_;
52 : // DataType outputDataType_;
53 : std::vector<NHRStepInfo> stepInfoVector_; // nhr算法执行过程中的参数
54 : std::map<u32, u32> indexMap_;
55 :
56 : // load进来参数
57 : CcuRep::Variable input_;
58 : CcuRep::Variable output_;
59 : std::vector<CcuRep::Variable> scratch_;
60 : std::vector<CcuRep::Variable> token_;
61 : CcuRep::Variable die0Size_;
62 : CcuRep::Variable die1Size_;
63 : CcuRep::Variable inputSliceStride_;
64 : CcuRep::Variable curScratchStride_;
65 : CcuRep::Variable inputRepeatStride_;
66 : CcuRep::Variable outputRepeatStride_;
67 : CcuRep::Variable repeatNumVar_;
68 : CcuRep::Variable isOutputScratch_;
69 :
70 : // 跨轴同步信号
71 : std::string localAxisSignalName_;
72 : std::string anotherAxisSignalName_;
73 : CcuRep::MaskSignal localAxisSignal_;
74 : CcuRep::MaskSignal anotherAxisSignal_;
75 : CcuRep::MaskSignal localSignal_;
76 :
77 : CcuRep::Variable repeatNumVarTemp_;
78 : CcuRep::Variable repeatTimeflag_;
79 : std::vector<CcuRep::Variable> inputOffset_;
80 : std::vector<CcuRep::Variable> ScratchOffset_;
81 : CcuRep::Variable curInputOffset_;
82 : CcuRep::Variable curScratchOffset_;
83 : CcuRep::Variable cursliceSize_;
84 : CcuRep::Memory srcMem_;
85 : CcuRep::Memory dstMem_;
86 : };
87 : } // namespace Hccl
88 :
89 : #endif // HCCLV2_CCU_CONTEXT_SCATTER_NHR_1D_H_
|