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}}}}, {1, {{0, {3, 5, 7}}}}, {2, {{3, {0, 4, 6}}}}, {3, {{2, {1, 5, 7}}}},
30 : {4, {{5, {0, 2, 6}}}}, {5, {{4, {1, 3, 7}}}}, {6, {{7, {0, 2, 4}}}}, {7, {{6, {1, 3, 5}}}}};
31 :
32 : /*
33 : 0/1/2/3通信借道4/5/6/7节点间链路规划:
34 :
35 : 0->4->1; 0->5->2; 0->6->3;
36 : 1->4->0; 1->6->2; 1->7->3;
37 : 2->5->0; 2->6->1; 2->4->3;
38 : 3->6->0; 3->7->1; 3->4->2;
39 : */
40 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_2P_TABLE_04
41 : = {{0, {{4, {1, 2, 3}}}}, {4, {{0, {5, 6, 7}}}}, {1, {{5, {0, 2, 3}}}}, {5, {{1, {4, 6, 7}}}},
42 : {2, {{6, {0, 1, 3}}}}, {6, {{2, {4, 5, 7}}}}, {3, {{7, {0, 1, 2}}}}, {7, {{3, {4, 5, 6}}}}};
43 :
44 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_4P_TABLE_0123
45 : = {{0, {{1, {4}}}}, {0, {{2, {5}}}}, {0, {{3, {6}}}}, {1, {{0, {4}}}}, {1, {{2, {6}}}}, {1, {{3, {7}}}},
46 : {2, {{0, {5}}}}, {2, {{1, {6}}}}, {2, {{3, {4}}}}, {3, {{0, {6}}}}, {3, {{1, {7}}}}, {3, {{2, {4}}}}};
47 : /*
48 : 4/5/6/7通信借道0/1/2/3节点间链路规划:
49 :
50 : 4->0->5; 4->1->6; 4->2->7;
51 : 5->0->4; 5->2->6; 5->3->7;
52 : 6->1->4; 6->2->5; 6->0->7;
53 : 7->2->4; 7->3->5; 7->0->6;
54 : */
55 :
56 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_4P_TABLE_4567
57 : = {{4, {{5, {0}}}}, {4, {{6, {1}}}}, {4, {{7, {2}}}}, {5, {{4, {0}}}}, {5, {{6, {2}}}}, {5, {{7, {3}}}},
58 : {6, {{4, {1}}}}, {6, {{5, {2}}}}, {6, {{7, {0}}}}, {7, {{4, {2}}}}, {7, {{5, {3}}}}, {7, {{6, {0}}}}};
59 :
60 : /*
61 : 0/2/4/6通信借道1/3/5/7节点间链路规划:
62 :
63 : 0->1->2; 0->3->4; 0->5->6;
64 : 2->1->0; 2->5->4; 2->7->6;
65 : 4->3->0; 4->5->2; 4->1->6;
66 : 6->5->0; 6->7->2; 6->1->4;
67 : */
68 :
69 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_4P_TABLE_0246
70 : = {{0, {{2, {1}}}}, {0, {{4, {3}}}}, {0, {{6, {5}}}}, {2, {{1, {0}}}}, {2, {{4, {5}}}}, {2, {{6, {7}}}},
71 : {4, {{0, {3}}}}, {4, {{2, {5}}}}, {4, {{6, {1}}}}, {6, {{0, {5}}}}, {6, {{2, {7}}}}, {6, {{4, {1}}}}};
72 :
73 : /*
74 : 1/3/5/7通信借道0/2/4/6节点间链路规划:
75 :
76 : 1->0->3; 1->2->5; 1->4->7;
77 : 3->0->1; 3->4->5; 3->6->7;
78 : 5->2->1; 5->4->3; 5->0->7;
79 : 7->4->1; 7->6->3; 7->0->5;
80 : */
81 :
82 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>> DETOUR_4P_TABLE_1357
83 : = {{1, {{3, {0}}}}, {1, {{5, {2}}}}, {1, {{7, {4}}}}, {3, {{1, {0}}}}, {3, {{5, {4}}}}, {3, {{7, {6}}}},
84 : {5, {{1, {2}}}}, {5, {{3, {4}}}}, {5, {{7, {0}}}}, {7, {{1, {4}}}}, {7, {{3, {6}}}}, {7, {{5, {0}}}}};
85 :
86 : } // namespace
87 :
88 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>>& GetDetour2PTable01()
89 : {
90 2 : return DETOUR_2P_TABLE_01;
91 : }
92 :
93 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>>& GetDetour2PTable04()
94 : {
95 2 : return DETOUR_2P_TABLE_04;
96 : }
97 :
98 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>>& GetDetour4PTable0123()
99 : {
100 2 : return DETOUR_4P_TABLE_0123;
101 : }
102 :
103 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>>& GetDetour4PTable4567()
104 : {
105 2 : return DETOUR_4P_TABLE_4567;
106 : }
107 :
108 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>>& GetDetour4PTable0246()
109 : {
110 2 : return DETOUR_4P_TABLE_0246;
111 : }
112 :
113 2 : const std::unordered_map<LocalId, std::unordered_map<LocalId, std::vector<LocalId>>>& GetDetour4PTable1357()
114 : {
115 2 : return DETOUR_4P_TABLE_1357;
116 : }
117 :
118 : } // namespace Hccl
|