@@ -37,20 +37,6 @@ class BalancedPartitioningTest : public ::testing::Test {
37
37
Ids.push_back (N.Id );
38
38
return Ids;
39
39
}
40
-
41
- static testing::Matcher<BPFunctionNode> NodeIdIs (BPFunctionNode::IDT Id) {
42
- return Field (" Id" , &BPFunctionNode::Id, Id);
43
- };
44
-
45
- static testing::Matcher<BPFunctionNode>
46
- NodeBucketIs (std::optional<uint32_t > Bucket) {
47
- return Field (" Bucket" , &BPFunctionNode::Bucket, Bucket);
48
- };
49
-
50
- static testing::Matcher<BPFunctionNode>
51
- NodeIs (BPFunctionNode::IDT Id, std::optional<uint32_t > Bucket) {
52
- return AllOf (NodeIdIs (Id), NodeBucketIs (Bucket));
53
- };
54
40
};
55
41
56
42
TEST_F (BalancedPartitioningTest, Basic) {
@@ -62,6 +48,11 @@ TEST_F(BalancedPartitioningTest, Basic) {
62
48
63
49
Bp.run (Nodes);
64
50
51
+ auto NodeIs = [](BPFunctionNode::IDT Id, std::optional<uint32_t > Bucket) {
52
+ return AllOf (Field (" Id" , &BPFunctionNode::Id, Id),
53
+ Field (" Bucket" , &BPFunctionNode::Bucket, Bucket));
54
+ };
55
+
65
56
EXPECT_THAT (Nodes,
66
57
UnorderedElementsAre (NodeIs (0 , 0 ), NodeIs (1 , 1 ), NodeIs (2 , 2 ),
67
58
NodeIs (3 , 3 ), NodeIs (4 , 4 )));
@@ -88,7 +79,8 @@ TEST_F(BalancedPartitioningTest, Large) {
88
79
89
80
Bp.run (Nodes);
90
81
91
- EXPECT_THAT (Nodes, Each (Not (NodeBucketIs (std::nullopt ))));
82
+ EXPECT_THAT (
83
+ Nodes, Each (Not (Field (" Bucket" , &BPFunctionNode::Bucket, std::nullopt ))));
92
84
EXPECT_THAT (getIds (Nodes), UnorderedElementsAreArray (OrigIds));
93
85
}
94
86
@@ -105,55 +97,4 @@ TEST_F(BalancedPartitioningTest, MoveGain) {
105
97
30 .f );
106
98
}
107
99
108
- TEST_F (BalancedPartitioningTest, Weight1) {
109
- std::vector<BPFunctionNode::UtilityNodeT> UNs = {
110
- BPFunctionNode::UtilityNodeT (0 , 100 ),
111
- BPFunctionNode::UtilityNodeT (1 , 100 ),
112
- BPFunctionNode::UtilityNodeT (2 , 100 ),
113
- BPFunctionNode::UtilityNodeT (3 , 1 ),
114
- BPFunctionNode::UtilityNodeT (4 , 1 ),
115
- };
116
- std::vector<BPFunctionNode> Nodes = {
117
- BPFunctionNode (0 , {UNs[0 ], UNs[3 ]}), BPFunctionNode (1 , {UNs[1 ], UNs[3 ]}),
118
- BPFunctionNode (2 , {UNs[2 ], UNs[3 ]}), BPFunctionNode (3 , {UNs[0 ], UNs[4 ]}),
119
- BPFunctionNode (4 , {UNs[1 ], UNs[4 ]}), BPFunctionNode (5 , {UNs[2 ], UNs[4 ]}),
120
- };
121
-
122
- Bp.run (Nodes);
123
-
124
- // Check that nodes that share important UNs are ordered together
125
- auto NodesRef = ArrayRef (Nodes);
126
- auto Groups = {NodesRef.slice (0 , 2 ), NodesRef.slice (2 , 2 ),
127
- NodesRef.slice (4 , 2 )};
128
- EXPECT_THAT (Groups, UnorderedElementsAre (
129
- UnorderedElementsAre (NodeIdIs (0 ), NodeIdIs (3 )),
130
- UnorderedElementsAre (NodeIdIs (1 ), NodeIdIs (4 )),
131
- UnorderedElementsAre (NodeIdIs (2 ), NodeIdIs (5 ))));
132
- }
133
-
134
- TEST_F (BalancedPartitioningTest, Weight2) {
135
- std::vector<BPFunctionNode::UtilityNodeT> UNs = {
136
- BPFunctionNode::UtilityNodeT (0 , 1 ),
137
- BPFunctionNode::UtilityNodeT (1 , 1 ),
138
- BPFunctionNode::UtilityNodeT (2 , 1 ),
139
- BPFunctionNode::UtilityNodeT (3 , 100 ),
140
- BPFunctionNode::UtilityNodeT (4 , 100 ),
141
- };
142
- std::vector<BPFunctionNode> Nodes = {
143
- BPFunctionNode (0 , {UNs[0 ], UNs[3 ]}), BPFunctionNode (1 , {UNs[1 ], UNs[4 ]}),
144
- BPFunctionNode (2 , {UNs[2 ], UNs[3 ]}), BPFunctionNode (3 , {UNs[0 ], UNs[4 ]}),
145
- BPFunctionNode (4 , {UNs[1 ], UNs[3 ]}), BPFunctionNode (5 , {UNs[2 ], UNs[4 ]}),
146
- };
147
-
148
- Bp.run (Nodes);
149
-
150
- // Check that nodes that share important UNs are ordered together
151
- auto NodesRef = ArrayRef (Nodes);
152
- auto Groups = {NodesRef.slice (0 , 3 ), NodesRef.slice (3 , 3 )};
153
- EXPECT_THAT (Groups,
154
- UnorderedElementsAre (
155
- UnorderedElementsAre (NodeIdIs (0 ), NodeIdIs (2 ), NodeIdIs (4 )),
156
- UnorderedElementsAre (NodeIdIs (1 ), NodeIdIs (3 ), NodeIdIs (5 ))));
157
- }
158
-
159
100
} // end namespace llvm
0 commit comments