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