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_REDUCE_SCATTER_MESH_1D_MEM2MEM_H_
12 : #define HCCLV2_CCU_CONTEXT_REDUCE_SCATTER_MESH_1D_MEM2MEM_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 : class CcuContextReduceScatterMeshMem2Mem1D : public CcuContextAlgBase {
22 : public:
23 : CcuContextReduceScatterMeshMem2Mem1D(
24 : const CcuCtxArg& arg, const std::vector<CcuTransport*>& transports, const CcuTransportGroup& group);
25 0 : ~CcuContextReduceScatterMeshMem2Mem1D() override {}
26 :
27 : void Algorithm() override;
28 : std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
29 :
30 : private:
31 : void InitResource();
32 : void LoadArgs();
33 : void PreSync();
34 : void PostSync();
35 : void DoRepeatReduceScatter();
36 : void DoReduceScatter();
37 :
38 : std::string GetLoopBlockTag(std::string loopType, int32_t index);
39 : void CreateReduceLoop(uint32_t size, DataType dataType, DataType outputDataType, ReduceOp opType);
40 : void ReduceLoopGroup(
41 : CcuRep::Memory outDstOrg, CcuRep::Memory srcOrg, std::vector<CcuRep::Memory>& scratchOrg, GroupOpSize goSize,
42 : DataType dataType, DataType outputDataType, ReduceOp opType);
43 :
44 : const std::string LOOP_BLOCK_TAG{"_local_copy_reduce_loop_"};
45 :
46 : DataType dataType_;
47 : DataType outputDataType_;
48 : CcuRep::Variable repeatNum_;
49 : std::vector<CcuRep::Variable> input_;
50 : CcuRep::Variable output_;
51 : std::vector<CcuRep::Variable> scratch_;
52 : std::vector<CcuRep::Variable> token_;
53 : CcuRep::Variable currentRankSliceInputOffset_;
54 : CcuRep::Variable inputRepeatStride_;
55 : CcuRep::Variable outputRepeatStride_;
56 : CcuRep::Variable normalSliceSize_;
57 : GroupOpSize normalGoSize_;
58 : uint16_t selfBit_{0};
59 : uint16_t allBit_{0};
60 : std::vector<CcuRep::Memory> localMem_;
61 : std::vector<CcuRep::Memory> remoteMem_;
62 : CcuRep::MaskSignal localSignal_;
63 : CcuRep::Variable flag_; // 用以判断是否是第一次重复
64 : };
65 : } // namespace Hccl
66 :
67 : #endif // HCCLV2_CCU_CONTEXT_REDUCE_SCATTER_MESH_1D_MEM2MEM_H_
|