Line data Source code
1 : /**
2 : * Copyright (c) 2026 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_REDUCE_SCATTER_MESH_1D_2Die_H_
12 : #define HCCLV2_CCU_CONTEXT_REDUCE_SCATTER_MESH_1D_2Die_H_
13 :
14 : #include <vector>
15 : #include <ios>
16 : #include "log.h"
17 : #include "ccu_context_alg_base.h"
18 : #include "ccu_datatype.h"
19 :
20 : namespace Hccl {
21 :
22 : class CcuContextReduceScatterMesh1D2Die : public CcuContextAlgBase {
23 : public:
24 : CcuContextReduceScatterMesh1D2Die(
25 : const CcuCtxArg& arg, const std::vector<CcuTransport*>& transports, const CcuTransportGroup& group);
26 0 : ~CcuContextReduceScatterMesh1D2Die() override {}
27 :
28 : void Algorithm() override;
29 : std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
30 :
31 : private:
32 : void InitResources();
33 : void LoadArgs();
34 : void PreSync();
35 : void PostSync(uint32_t signalIndex);
36 : void MissionSync(uint32_t signalIndex);
37 : void RmtReduce();
38 : std::string GetLoopBlockTag(std::string loopType, int32_t index) const;
39 : void CreateReduceLoop(uint32_t size, DataType dataType, DataType outputDataType, ReduceOp opType);
40 : void ReduceLoopGroup(
41 : CcuRep::Memory& outDstOrg, std::vector<CcuRep::Memory>& srcOrg, GroupOpSize goSize, DataType dataType,
42 : DataType outputDataType, ReduceOp opType);
43 : void DoLocalReduce();
44 :
45 : private:
46 : bool rmtReduceWithMyRank_{true};
47 :
48 : uint32_t myRankId_{0};
49 :
50 : uint32_t rmtReduceRankNum_{0};
51 : uint32_t rmtSyncMyBit_{0};
52 : uint32_t rmtSyncWaitBit_{0};
53 :
54 : DataType dataType_;
55 : DataType outputDataType_;
56 :
57 : std::string ctxName_ = "";
58 : ;
59 :
60 : uint32_t missionSyncMybit_{0};
61 : uint32_t missionSyncWaitBit_{0};
62 :
63 : std::string myMissionSignalName_ = "";
64 : std::string otherMissionSignalName_ = "";
65 :
66 : CcuRep::Variable myInput_;
67 : CcuRep::Variable myOutput_;
68 : CcuRep::Variable myScratch_;
69 : CcuRep::Variable myToken_;
70 : std::vector<CcuRep::Variable> peerInput_;
71 : std::vector<CcuRep::Variable> peerToken_;
72 :
73 : CcuRep::Variable sliceSize_;
74 :
75 : CcuRep::Variable rmtReduceSliceOffset_;
76 :
77 : GroupOpSize rmtReduceGoSize_;
78 :
79 : CcuRep::MaskSignal myMissionSignal_;
80 : CcuRep::MaskSignal otherMissionSignal_;
81 : };
82 : } // namespace Hccl
83 :
84 : #endif // HCCLV2_CCU_CONTEXT_REDUCE_SCATTER_MESH_1D_2Die_H_
|