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 : #include "detour_rules.h"
12 :
13 : namespace Hccl {
14 : namespace {
15 :
16 : /*
17 : 2P节点间链路规划:
18 :
19 : 0->2->1; 0->4->1; 0->6->1;
20 : 1->3->0; 1->5->0; 1->7->0;
21 : 2->0->3; 2->4->3; 2->6->3;
22 : 3->1->2; 3->5->2; 3->7->2;
23 : 4->0->5; 4->2->5; 4->6->5;
24 : 5->1->4; 5->3->4; 5->7->4;
25 : 6->0->7; 6->2->7; 6->4->7;
26 : 7->1->6; 7->3->6; 7->5->6;
27 : */
28 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_2P_TABLE_01
29 : = { {0, {{1, {2, 4, 6}}}},
30 : {1, {{0, {3, 5, 7}}}},
31 : {2, {{3, {0, 4, 6}}}},
32 : {3, {{2, {1, 5, 7}}}},
33 : {4, {{5, {0, 2, 6}}}},
34 : {5, {{4, {1, 3, 7}}}},
35 : {6, {{7, {0, 2, 4}}}},
36 : {7, {{6, {1, 3, 5}}}}};
37 :
38 : /*
39 : 0/1/2/3通信借道4/5/6/7节点间链路规划:
40 :
41 : 0->4->1; 0->5->2; 0->6->3;
42 : 1->4->0; 1->6->2; 1->7->3;
43 : 2->5->0; 2->6->1; 2->4->3;
44 : 3->6->0; 3->7->1; 3->4->2;
45 : */
46 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_2P_TABLE_04
47 : = { {0, {{4, {1, 2, 3}}}},
48 : {4, {{0, {5, 6, 7}}}},
49 : {1, {{5, {0, 2, 3}}}},
50 : {5, {{1, {4, 6, 7}}}},
51 : {2, {{6, {0, 1, 3}}}},
52 : {6, {{2, {4, 5, 7}}}},
53 : {3, {{7, {0, 1, 2}}}},
54 : {7, {{3, {4, 5, 6}}}}};
55 :
56 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_4P_TABLE_0123
57 : = { {0, {{1, {4}}}},
58 : {0, {{2, {5}}}},
59 : {0, {{3, {6}}}},
60 : {1, {{0, {4}}}},
61 : {1, {{2, {6}}}},
62 : {1, {{3, {7}}}},
63 : {2, {{0, {5}}}},
64 : {2, {{1, {6}}}},
65 : {2, {{3, {4}}}},
66 : {3, {{0, {6}}}},
67 : {3, {{1, {7}}}},
68 : {3, {{2, {4}}}}};
69 : /*
70 : 4/5/6/7通信借道0/1/2/3节点间链路规划:
71 :
72 : 4->0->5; 4->1->6; 4->2->7;
73 : 5->0->4; 5->2->6; 5->3->7;
74 : 6->1->4; 6->2->5; 6->0->7;
75 : 7->2->4; 7->3->5; 7->0->6;
76 : */
77 :
78 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_4P_TABLE_4567
79 : = { {4, {{5, {0}}}},
80 : {4, {{6, {1}}}},
81 : {4, {{7, {2}}}},
82 : {5, {{4, {0}}}},
83 : {5, {{6, {2}}}},
84 : {5, {{7, {3}}}},
85 : {6, {{4, {1}}}},
86 : {6, {{5, {2}}}},
87 : {6, {{7, {0}}}},
88 : {7, {{4, {2}}}},
89 : {7, {{5, {3}}}},
90 : {7, {{6, {0}}}}};
91 :
92 : /*
93 : 0/2/4/6通信借道1/3/5/7节点间链路规划:
94 :
95 : 0->1->2; 0->3->4; 0->5->6;
96 : 2->1->0; 2->5->4; 2->7->6;
97 : 4->3->0; 4->5->2; 4->1->6;
98 : 6->5->0; 6->7->2; 6->1->4;
99 : */
100 :
101 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_4P_TABLE_0246
102 : = { {0, {{2, {1}}}},
103 : {0, {{4, {3}}}},
104 : {0, {{6, {5}}}},
105 : {2, {{1, {0}}}},
106 : {2, {{4, {5}}}},
107 : {2, {{6, {7}}}},
108 : {4, {{0, {3}}}},
109 : {4, {{2, {5}}}},
110 : {4, {{6, {1}}}},
111 : {6, {{0, {5}}}},
112 : {6, {{2, {7}}}},
113 : {6, {{4, {1}}}}};
114 :
115 : /*
116 : 1/3/5/7通信借道0/2/4/6节点间链路规划:
117 :
118 : 1->0->3; 1->2->5; 1->4->7;
119 : 3->0->1; 3->4->5; 3->6->7;
120 : 5->2->1; 5->4->3; 5->0->7;
121 : 7->4->1; 7->6->3; 7->0->5;
122 : */
123 :
124 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_4P_TABLE_1357
125 : = { {1, {{3, {0}}}},
126 : {1, {{5, {2}}}},
127 : {1, {{7, {4}}}},
128 : {3, {{1, {0}}}},
129 : {3, {{5, {4}}}},
130 : {3, {{7, {6}}}},
131 : {5, {{1, {2}}}},
132 : {5, {{3, {4}}}},
133 : {5, {{7, {0}}}},
134 : {7, {{1, {4}}}},
135 : {7, {{3, {6}}}},
136 : {7, {{5, {0}}}}};
137 :
138 : } // namespace
139 :
140 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> &GetDetour2PTable01()
141 : {
142 2 : return DETOUR_2P_TABLE_01;
143 : }
144 :
145 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> &GetDetour2PTable04()
146 : {
147 2 : return DETOUR_2P_TABLE_04;
148 : }
149 :
150 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> &GetDetour4PTable0123()
151 : {
152 2 : return DETOUR_4P_TABLE_0123;
153 : }
154 :
155 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> &GetDetour4PTable4567()
156 : {
157 2 : return DETOUR_4P_TABLE_4567;
158 : }
159 :
160 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> &GetDetour4PTable0246()
161 : {
162 2 : return DETOUR_4P_TABLE_0246;
163 : }
164 :
165 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> &GetDetour4PTable1357()
166 : {
167 2 : return DETOUR_4P_TABLE_1357;
168 : }
169 :
170 : } // namespace Hccl
|