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_GATHER_MESH_1D_DETOUR_H
12 : #define HCCLV2_CCU_CONTEXT_ALL_GATHER_MESH_1D_DETOUR_H
13 :
14 : #include <vector>
15 :
16 : #include <ios>
17 : #include "log.h"
18 : #include "ccu_context_alg_base.h"
19 : #include "ccu_datatype.h"
20 :
21 : namespace Hccl {
22 :
23 : class CcuContextAllGatherMeshDetour1D : public CcuContextAlgBase {
24 : public:
25 : CcuContextAllGatherMeshDetour1D(const CcuCtxArg &arg, const std::vector<CcuTransport*> &transports,
26 : const CcuTransportGroup &group);
27 0 : ~CcuContextAllGatherMeshDetour1D() override {}
28 :
29 : void Algorithm() override;
30 : std::vector<uint64_t> GeneArgs(const CcuTaskArg &arg) override;
31 : private:
32 : void ProcessTransports(const std::vector<CcuTransport *> &transports);
33 : void AllocDetourRes();
34 : void CreateMultiOpBroadcastDetour();
35 : void GroupBroadcastDetour(std::vector<CcuRep::Variable> &lengths, std::vector<CcuRep::Memory> &src,
36 : std::vector<CcuRep::Memory> &dst);
37 : void FirstStep();
38 : void SecondStep();
39 :
40 : // ctx args
41 : uint64_t singleTransportSize_{0}; // 每个loop单次传输的总数据量,通信域级别
42 : uint64_t detourPathNum_{0};
43 : uint64_t pathNumPerPeer_{0}; // 到每个rank有几个transport,包括重复的
44 : std::vector<std::vector<CcuTransport*>> detourTransports_; // 默认是transport的每rankSize-1个为一组,第一组是直连链路
45 :
46 : // task args
47 : CcuRep::Variable input_;
48 : std::vector<CcuRep::Variable> output_;
49 : std::vector<CcuRep::Variable> token_;
50 : CcuRep::Variable baseOffset_; // rankId*sliceSize,待广播分片的基础偏移
51 : CcuRep::Variable tailOffset_; // 尾块相对偏移,singleTransportSize*128*iterNum
52 : CcuRep::Variable loopIterNum_; // for detour loopgroup only
53 : std::vector<CcuRep::Variable> lengths_; // 每组transport对应一个len
54 : GroupOpSize groupOpSize_; // 只处理尾块
55 : };
56 : } // namespace Hccl
57 :
58 : #endif // HCCLV2_CCU_CONTEXT_ALL_GATHER_MESH_1D_DETOUR_H
|