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_BROADCAST_MESH_2D_MEM2MEM_H_
12 : #define HCCLV2_CCU_CONTEXT_BROADCAST_MESH_2D_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 :
22 : class CcuContextBroadcastMeshMem2Mem2D : public CcuContextAlgBase {
23 : public:
24 : CcuContextBroadcastMeshMem2Mem2D(
25 : const CcuCtxArg& arg, const std::vector<CcuTransport*>& transports, const CcuTransportGroup& group);
26 0 : ~CcuContextBroadcastMeshMem2Mem2D() override {}
27 :
28 : void Algorithm() override;
29 : std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
30 :
31 : private:
32 : void InitResources();
33 : void PreSync();
34 : void PostSync(uint32_t signalIndex);
35 : void LoadArgs();
36 : void AxisSync(uint32_t signalIndex);
37 : void Step1BroadcastForRoot();
38 : void Step2BroadcastForRoot();
39 : void Step2Broadcast();
40 :
41 : // 构造函数中
42 : std::vector<uint64_t> dimSize_;
43 : uint32_t axisId_{0};
44 : std::vector<uint32_t> dimId_; // 本rank所在行或列的编号
45 : std::vector<uint32_t> rootDimId_; // root所在行或列的编号
46 : uint32_t localId_{0}; // 本rank所在行或列的编号
47 : uint32_t rootLocalId_{0}; // root所在行或列的编号
48 : uint32_t localSize_{0}; // 本rank所在行或列的总rank数
49 : DataType dataType_;
50 : uint32_t rootId_{0};
51 :
52 : // load进来参数
53 : std::vector<CcuRep::Variable> input_;
54 : std::vector<CcuRep::Variable> token_;
55 : CcuRep::Variable xAxisSize_;
56 : CcuRep::Variable yAxisSize_;
57 : CcuRep::Variable yAxisOffset_;
58 : CcuRep::Variable dataSize_;
59 :
60 : // 跨轴同步信号
61 : std::string localAxisSignalName_;
62 : std::string anotherAxisSignalName_;
63 : CcuRep::MaskSignal localAxisSignal_;
64 : CcuRep::MaskSignal anotherAxisSignal_;
65 : };
66 : } // namespace Hccl
67 :
68 : #endif // HCCLV2_CCU_CONTEXT_BROADCAST_MESH_2D_MEM2MEM_H_
|