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_COLL_ALG_PARAMS
12 : #define HCCLV2_COLL_ALG_PARAMS
13 :
14 : #include <string>
15 : #include <vector>
16 : #include "op_mode.h"
17 : #include "types.h"
18 : #include "virtual_topo.h"
19 :
20 : namespace Hccl {
21 : using CollAlgParams = struct CollAlgParamsDef {
22 : OpMode opMode;
23 : u64 maxTmpMemSize;
24 : u32 maxQueue;
25 : u32 maxLink;
26 : u32 maxDepQueuePairs;
27 : u64 dataSize;
28 : bool isMc2{false};
29 : OpExecuteConfig opExecuteConfig;
30 : std::string algConfig;
31 : };
32 :
33 : using ResRequirement = struct ResRequirementDef {
34 : std::string algName;
35 : std::vector<LinkData> links;
36 : u32 primQueueNum;
37 : std::vector<std::tuple<QId, QId, u32>> queueNotifys;
38 : };
39 :
40 : // 算法拓扑
41 : using AlgTopoInfo = struct AlgTopoInfoDef {
42 : std::vector<std::vector<RankId>> virtRanks; // 各级通信内包含的Ranks
43 : std::vector<std::map<RankId, u32>> virtRankMap; // 为不保序的ReduceScatter和AllGather预留
44 : std::vector<std::vector<std::vector<RankId>>> vTopo; // 各级通信域内并行的包含本rank的各个通信平面
45 :
46 1 : void UpdateSingleLevelTopo(std::vector<RankId> tmpVirtRank, std::map<RankId, u32> tmpVirtRankMap,
47 : std::vector<std::vector<RankId>> tmpVTopo)
48 : {
49 1 : virtRanks.push_back(tmpVirtRank);
50 1 : virtRankMap.push_back(tmpVirtRankMap);
51 1 : vTopo.push_back(tmpVTopo);
52 1 : }
53 :
54 0 : void UpdateMultiLevelTopo(std::vector<std::vector<RankId>> tmpVirtRank,
55 : std::vector<std::map<RankId, u32>> tmpVirtRankMap,
56 : std::vector<std::vector<std::vector<RankId>>> tmpVTopo)
57 : {
58 0 : virtRanks = tmpVirtRank;
59 0 : virtRankMap = tmpVirtRankMap;
60 0 : vTopo = tmpVTopo;
61 0 : }
62 : };
63 :
64 : using CollAlgResReq = struct CollAlgResReqDef {
65 : std::vector<LinkData> links;
66 : u32 primQueueNum;
67 : std::vector<std::tuple<QId, QId, u32>> queueNotifys;
68 : AlgTopoInfo topoInfo;
69 : std::vector<std::pair<QId, u32>> localWaitGroupCntNotify;
70 : std::vector<std::pair<QId, u32>> localBcastPostCntNotify;
71 : std::vector<std::pair<u32, RankId>> levelRankPairs;
72 : };
73 :
74 : using CollAlgOpReq = struct CollAlgOpReqDef {
75 : std::string algName;
76 : CollAlgResReq resReq;
77 : };
78 :
79 : } // namespace Hccl
80 : #endif // !HCCLV2_COLL_ALG_PARAMS
|