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_ALL_REDUCE_MESH_2D_ONE_SHOT_H_
12 : #define HCCLV2_CCU_CONTEXT_ALL_REDUCE_MESH_2D_ONE_SHOT_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 CcuContextAllReduceMesh2DOneShot : public CcuContextAlgBase {
23 : public:
24 : CcuContextAllReduceMesh2DOneShot(
25 : const CcuCtxArg& arg, const std::vector<CcuTransport*>& transports, const CcuTransportGroup& group);
26 0 : ~CcuContextAllReduceMesh2DOneShot() override {}
27 :
28 : void Algorithm() override;
29 : std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
30 :
31 : private:
32 : void InitVariables();
33 : void LoadArgs();
34 : void DoAxisSync(uint32_t signalIdx);
35 : void DoGroupSync(int ckeIdx, uint16_t selfBit, uint16_t allBit);
36 : void DoGroupReduce(
37 : std::vector<CcuRep::Variable>& srcBase, CcuRep::Variable& dstBase, CcuRep::Variable& offset,
38 : GroupOpSize& goSize);
39 : std::vector<uint64_t> dimSize_;
40 : std::vector<uint64_t> myRankIdxInAxis_;
41 : uint64_t myRankIdxInCurrentAxis_{0};
42 : uint64_t currentAxisRankSize_{0};
43 :
44 : uint32_t axisId_{0};
45 : DataType dataType_;
46 : DataType outputDataType_;
47 :
48 : std::vector<CcuRep::Variable> inputAddr_;
49 : std::vector<CcuRep::Variable> outputAddr_;
50 : std::vector<CcuRep::Variable> scratchAddr_;
51 : std::vector<CcuRep::Variable> token_;
52 : CcuRep::Variable xSliceOffset_;
53 : CcuRep::Variable ySliceOffset_;
54 : GroupOpSize xGoSize_;
55 : GroupOpSize yGoSize_;
56 :
57 : std::string currAxisSignalName_;
58 : std::string otherAxisSignalName_;
59 : CcuRep::MaskSignal currAxisSignal_;
60 : CcuRep::MaskSignal otherAxisSignal_;
61 : };
62 : } // namespace Hccl
63 :
64 : #endif // HCCLV2_CCU_CONTEXT_ALL_REDUCE_MESH_2D_ONE_SHOT_H_
|