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 ALL_GATHER_SLIM_RING_PUB_H
12 : #define ALL_GATHER_SLIM_RING_PUB_H
13 :
14 : #include "alg_template_base_pub.h"
15 : #include "transport_pub.h"
16 :
17 : namespace hccl {
18 : class AllGatherSlimRing : public AlgTemplateBase {
19 : public:
20 : explicit AllGatherSlimRing(const HcclDispatcher dispatcher);
21 :
22 : ~AllGatherSlimRing() override;
23 :
24 : HcclResult RunAsync(const u32 rank, const u32 rankSize, const std::vector<LINK>& links) override;
25 :
26 : HcclResult SetNotifyIdx(u32 notifyIdx);
27 : HcclResult GetNotifyIdx(u32& notifyIdx);
28 :
29 : protected:
30 : private:
31 : // 获取向该rank往前的第i个rank
32 0 : inline u32 ForwordRank(u32 rank, u32 rankSize, u32 preNum) const { return (rank + rankSize - preNum) % rankSize; }
33 : HcclResult RunAllGather(u32 rank, u32 rankSize, const std::vector<Slice>& outputSlices);
34 :
35 : HcclResult TxVector(const LINK& link, const std::vector<Slice>& txSlices);
36 : HcclResult RxVector(const LINK& link, const std::vector<Slice>& rxSlices);
37 :
38 : HcclResult InitSlice(std::vector<Slice>& inputSlices, u32 rank, u32 rankSize, u32 unitSize);
39 :
40 : // 迭代6新增加
41 : std::shared_ptr<Transport> linkLeft_;
42 : std::shared_ptr<Transport> linkRight_;
43 : u32 notifyIdx_ = 0;
44 : };
45 : } // namespace hccl
46 :
47 : #endif /* ALL_GATHER_SLIM_RING_PUB_H */
|