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_DETOUR_1D_H_
12 : #define HCCLV2_CCU_CONTEXT_ALL_REDUCE_MESH_DETOUR_1D_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 : #include "ccu_assist.h"
20 :
21 : namespace Hccl {
22 :
23 : class CcuContextAllReduceMeshDetour1D : public CcuContextAlgBase {
24 : public:
25 : CcuContextAllReduceMeshDetour1D(
26 : const CcuCtxArg& arg, const std::vector<CcuTransport*>& transports, const CcuTransportGroup& group);
27 0 : ~CcuContextAllReduceMeshDetour1D() override {}
28 :
29 : void Algorithm() override;
30 : std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
31 :
32 : private:
33 : void CreateMultiOpReduceDetour(DataType& dataType, DataType& outputDataType, ReduceOp& opType);
34 : void GroupReduceDetour(
35 : std::vector<CcuRep::Memory>& src, std::vector<CcuRep::Memory>& dst, DataType& dataType,
36 : DataType& outputDataType, ReduceOp& opType);
37 : void CreateMultiOpBroadcastDetour();
38 : void GroupBroadcastDetour(
39 : std::vector<CcuRep::Variable>& lengths, std::vector<CcuRep::Memory>& src, std::vector<CcuRep::Memory>& dst);
40 : void ReduceScatterFirstStep();
41 : void ReduceScatterSecondStep();
42 : void AllGatherFirstStep();
43 : void AllGatherSecondStep();
44 :
45 : uint64_t singleTransportSize{0}; // 每个loop单次传输的总数据量,通信域级别
46 : uint64_t detourPathNum{0};
47 : uint64_t pathNumPerPeer{0}; // 到每个rank有几个transport,包括重复的
48 : std::vector<std::vector<CcuTransport*>> detourTransports_;
49 : CcuRep::Variable tailOffset_; // 尾块相对偏移,singleTransportSize*128*iterNum
50 :
51 : DataType dataType_;
52 : DataType outputDataType_;
53 : std::vector<CcuRep::Variable> input_;
54 : std::vector<CcuRep::Variable> output_;
55 : std::vector<CcuRep::Variable> token_;
56 : CcuRep::Variable offset_;
57 : CcuRep::Variable iterNum_;
58 : CcuRep::Variable tailSize_;
59 : GroupOpSize groupOpSize_;
60 : std::vector<CcuRep::Variable> lengths_;
61 : };
62 : } // namespace Hccl
63 :
64 : #endif // HCCLV2_CCU_CONTEXT_ALL_REDUCE_MESH_DETOUR_1D_H_
|