Skip to content

Commit dfa47af

Browse files
committed
indent 4 spaces
1 parent fd975ad commit dfa47af

File tree

1 file changed

+93
-93
lines changed

1 file changed

+93
-93
lines changed

test/partitioner/partitioner_test.cpp

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ static const std::string PARTITIONER_DATA_DIR = "../../partitioner/data/";
4242

4343
const std::string get_full_file_name(const std::string json_file)
4444
{
45-
const std::string FULL_FILE_NAME = PARTITIONER_DATA_DIR + json_file;
46-
return FULL_FILE_NAME;
45+
const std::string FULL_FILE_NAME = PARTITIONER_DATA_DIR + json_file;
46+
return FULL_FILE_NAME;
4747
}
4848

4949
/**
@@ -62,117 +62,117 @@ static void test_create_sb_graph(const std::string& filename, const std::vector<
6262
const std::vector<Interval>& lhs_map_domain, const std::vector<Exp>& lhs_map_exps,
6363
const std::vector<Interval>& rhs_map_domain, const std::vector<Exp>& rhs_map_exps)
6464
{
65-
auto sb_graph = sbg_partitioner::build_sb_graph(filename);
66-
67-
// create nodes of the expected graph
68-
auto expected_nodes = SET_FACT.createSet();
69-
for (const auto& n : node_intervals) {
70-
expected_nodes.emplaceBack(n);
71-
}
72-
EXPECT_EQ(expected_nodes, sb_graph.V());
73-
74-
// create edges of the expected graph through its maps
75-
PWMap lhs_maps = PW_FACT.createPWMap();
76-
for (size_t i = 0; i < lhs_map_domain.size(); i++) {
77-
lhs_maps.emplaceBack(Map(lhs_map_domain[i], lhs_map_exps[i]));
78-
}
79-
80-
PWMap rhs_maps = PW_FACT.createPWMap();
81-
for (size_t i = 0; i < rhs_map_domain.size(); i++) {
82-
rhs_maps.emplaceBack(Map(rhs_map_domain[i], rhs_map_exps[i]));
83-
}
84-
85-
// test edges are correct
86-
EXPECT_EQ(lhs_maps.dom(), sb_graph.E());
87-
EXPECT_EQ(rhs_maps.dom(), sb_graph.E());
88-
89-
// test that maps are as expected
90-
EXPECT_EQ(lhs_maps, sb_graph.map1());
91-
EXPECT_EQ(rhs_maps, sb_graph.map2());
65+
auto sb_graph = sbg_partitioner::build_sb_graph(filename);
66+
67+
// create nodes of the expected graph
68+
auto expected_nodes = SET_FACT.createSet();
69+
for (const auto& n : node_intervals) {
70+
expected_nodes.emplaceBack(n);
71+
}
72+
EXPECT_EQ(expected_nodes, sb_graph.V());
73+
74+
// create edges of the expected graph through its maps
75+
PWMap lhs_maps = PW_FACT.createPWMap();
76+
for (size_t i = 0; i < lhs_map_domain.size(); i++) {
77+
lhs_maps.emplaceBack(Map(lhs_map_domain[i], lhs_map_exps[i]));
78+
}
79+
80+
PWMap rhs_maps = PW_FACT.createPWMap();
81+
for (size_t i = 0; i < rhs_map_domain.size(); i++) {
82+
rhs_maps.emplaceBack(Map(rhs_map_domain[i], rhs_map_exps[i]));
83+
}
84+
85+
// test edges are correct
86+
EXPECT_EQ(lhs_maps.dom(), sb_graph.E());
87+
EXPECT_EQ(rhs_maps.dom(), sb_graph.E());
88+
89+
// test that maps are as expected
90+
EXPECT_EQ(lhs_maps, sb_graph.map1());
91+
EXPECT_EQ(rhs_maps, sb_graph.map2());
9292
}
9393

9494
TEST(create_sb_graph, PartitionerTests)
9595
{
96-
test_create_sb_graph(get_full_file_name("air_conditioners_1000.json"),
97-
{Interval(0, 1, 999), Interval(1000, 1, 1999), Interval(2000, 1, 2999), Interval(3000, 1, 3999)},
98-
{Interval(4000, 1, 4999), Interval(5000, 1, 5999), Interval(6000, 1, 6999), Interval(7000, 1, 7999)},
99-
{Exp(LExp(1, RATIONAL(-3000, 1))), Exp(LExp(1, RATIONAL(-2000, 1))), Exp(LExp(1, RATIONAL(-6000, 1))),
100-
Exp(LExp(1, RATIONAL(-5000, 1)))},
101-
{Interval(4000, 1, 4999), Interval(5000, 1, 5999), Interval(6000, 1, 6999), Interval(7000, 1, 7999)},
102-
{Exp(LExp(1, RATIONAL(-4000, 1))), Exp(LExp(1, RATIONAL(-5000, 1))), Exp(LExp(1, RATIONAL(-5000, 1))),
103-
Exp(LExp(1, RATIONAL(-6000, 1)))});
104-
105-
test_create_sb_graph(get_full_file_name("advection.json"), {Interval(0, 1, 0), Interval(1, 1, 99)},
106-
{Interval(100, 1, 100), Interval(101, 1, 198)}, {Exp(LExp(0, 0)), Exp(LExp(1, RATIONAL(-100, 1)))},
107-
{Interval(100, 1, 100), Interval(101, 1, 198)}, {Exp(LExp(1, RATIONAL(-99, 1))), Exp(LExp(1, RATIONAL(-99, 1)))});
96+
test_create_sb_graph(get_full_file_name("air_conditioners_1000.json"),
97+
{Interval(0, 1, 999), Interval(1000, 1, 1999), Interval(2000, 1, 2999), Interval(3000, 1, 3999)},
98+
{Interval(4000, 1, 4999), Interval(5000, 1, 5999), Interval(6000, 1, 6999), Interval(7000, 1, 7999)},
99+
{Exp(LExp(1, RATIONAL(-3000, 1))), Exp(LExp(1, RATIONAL(-2000, 1))), Exp(LExp(1, RATIONAL(-6000, 1))),
100+
Exp(LExp(1, RATIONAL(-5000, 1)))},
101+
{Interval(4000, 1, 4999), Interval(5000, 1, 5999), Interval(6000, 1, 6999), Interval(7000, 1, 7999)},
102+
{Exp(LExp(1, RATIONAL(-4000, 1))), Exp(LExp(1, RATIONAL(-5000, 1))), Exp(LExp(1, RATIONAL(-5000, 1))),
103+
Exp(LExp(1, RATIONAL(-6000, 1)))});
104+
105+
test_create_sb_graph(get_full_file_name("advection.json"), {Interval(0, 1, 0), Interval(1, 1, 99)},
106+
{Interval(100, 1, 100), Interval(101, 1, 198)}, {Exp(LExp(0, 0)), Exp(LExp(1, RATIONAL(-100, 1)))},
107+
{Interval(100, 1, 100), Interval(101, 1, 198)}, {Exp(LExp(1, RATIONAL(-99, 1))), Exp(LExp(1, RATIONAL(-99, 1)))});
108108
}
109109

110110
TEST(initial_partition, PartitionerTests)
111111
{
112-
auto sb_graph = sbg_partitioner::build_sb_graph(get_full_file_name("air_conditioners_1000.json"));
113-
114-
constexpr bool enable_multithreading = false;
115-
sbg_partitioner::PartitionMap partition = sbg_partitioner::best_initial_partition(sb_graph, 4, sbg_partitioner::InitialPartitionStrategy::ALL, enable_multithreading);
116-
117-
auto expected_distributed_pre_order_0 = SET_FACT.createSet();
118-
expected_distributed_pre_order_0.emplaceBack(Interval(0, 1, 249));
119-
expected_distributed_pre_order_0.emplaceBack(Interval(1000, 1, 1249));
120-
expected_distributed_pre_order_0.emplaceBack(Interval(2000, 1, 2249));
121-
expected_distributed_pre_order_0.emplaceBack(Interval(3000, 1, 3249));
122-
Set partition_0 = sbg_partitioner::from_vector(partition.at(0));
123-
EXPECT_EQ(expected_distributed_pre_order_0, partition_0);
124-
125-
auto expected_distributed_pre_order_1 = SET_FACT.createSet();
126-
expected_distributed_pre_order_1.emplaceBack(Interval(250, 1, 499));
127-
expected_distributed_pre_order_1.emplaceBack(Interval(1250, 1, 1499));
128-
expected_distributed_pre_order_1.emplaceBack(Interval(2250, 1, 2499));
129-
expected_distributed_pre_order_1.emplaceBack(Interval(3250, 1, 3499));
130-
Set partition_1 = sbg_partitioner::from_vector(partition.at(1));
131-
EXPECT_EQ(expected_distributed_pre_order_1, partition_1);
132-
133-
auto expected_distributed_pre_order_2 = SET_FACT.createSet();
134-
expected_distributed_pre_order_2.emplaceBack(Interval(500, 1, 749));
135-
expected_distributed_pre_order_2.emplaceBack(Interval(1500, 1, 1749));
136-
expected_distributed_pre_order_2.emplaceBack(Interval(2500, 1, 2749));
137-
expected_distributed_pre_order_2.emplaceBack(Interval(3500, 1, 3749));
138-
Set partition_2 = sbg_partitioner::from_vector(partition.at(2));
139-
EXPECT_EQ(expected_distributed_pre_order_2, partition_2);
140-
141-
auto expected_distributed_pre_order_3 = SET_FACT.createSet();
142-
expected_distributed_pre_order_3.emplaceBack(Interval(750, 1, 999));
143-
expected_distributed_pre_order_3.emplaceBack(Interval(1750, 1, 1999));
144-
expected_distributed_pre_order_3.emplaceBack(Interval(2750, 1, 2999));
145-
expected_distributed_pre_order_3.emplaceBack(Interval(3750, 1, 3999));
146-
Set partition_3 = sbg_partitioner::from_vector(partition.at(3));
147-
EXPECT_EQ(expected_distributed_pre_order_3, partition_3);
148-
149-
sbg_partitioner::get_communication_cost().clear_communication_cache();
112+
auto sb_graph = sbg_partitioner::build_sb_graph(get_full_file_name("air_conditioners_1000.json"));
113+
114+
constexpr bool enable_multithreading = false;
115+
sbg_partitioner::PartitionMap partition = sbg_partitioner::best_initial_partition(sb_graph, 4, sbg_partitioner::InitialPartitionStrategy::ALL, enable_multithreading);
116+
117+
auto expected_distributed_pre_order_0 = SET_FACT.createSet();
118+
expected_distributed_pre_order_0.emplaceBack(Interval(0, 1, 249));
119+
expected_distributed_pre_order_0.emplaceBack(Interval(1000, 1, 1249));
120+
expected_distributed_pre_order_0.emplaceBack(Interval(2000, 1, 2249));
121+
expected_distributed_pre_order_0.emplaceBack(Interval(3000, 1, 3249));
122+
Set partition_0 = sbg_partitioner::from_vector(partition.at(0));
123+
EXPECT_EQ(expected_distributed_pre_order_0, partition_0);
124+
125+
auto expected_distributed_pre_order_1 = SET_FACT.createSet();
126+
expected_distributed_pre_order_1.emplaceBack(Interval(250, 1, 499));
127+
expected_distributed_pre_order_1.emplaceBack(Interval(1250, 1, 1499));
128+
expected_distributed_pre_order_1.emplaceBack(Interval(2250, 1, 2499));
129+
expected_distributed_pre_order_1.emplaceBack(Interval(3250, 1, 3499));
130+
Set partition_1 = sbg_partitioner::from_vector(partition.at(1));
131+
EXPECT_EQ(expected_distributed_pre_order_1, partition_1);
132+
133+
auto expected_distributed_pre_order_2 = SET_FACT.createSet();
134+
expected_distributed_pre_order_2.emplaceBack(Interval(500, 1, 749));
135+
expected_distributed_pre_order_2.emplaceBack(Interval(1500, 1, 1749));
136+
expected_distributed_pre_order_2.emplaceBack(Interval(2500, 1, 2749));
137+
expected_distributed_pre_order_2.emplaceBack(Interval(3500, 1, 3749));
138+
Set partition_2 = sbg_partitioner::from_vector(partition.at(2));
139+
EXPECT_EQ(expected_distributed_pre_order_2, partition_2);
140+
141+
auto expected_distributed_pre_order_3 = SET_FACT.createSet();
142+
expected_distributed_pre_order_3.emplaceBack(Interval(750, 1, 999));
143+
expected_distributed_pre_order_3.emplaceBack(Interval(1750, 1, 1999));
144+
expected_distributed_pre_order_3.emplaceBack(Interval(2750, 1, 2999));
145+
expected_distributed_pre_order_3.emplaceBack(Interval(3750, 1, 3999));
146+
Set partition_3 = sbg_partitioner::from_vector(partition.at(3));
147+
EXPECT_EQ(expected_distributed_pre_order_3, partition_3);
148+
149+
sbg_partitioner::get_communication_cost().clear_communication_cache();
150150
}
151151

152152
static void test_partitioning(const std::string& filename, int number_of_partitions)
153153
{
154-
auto sb_graph = sbg_partitioner::build_sb_graph(filename);
155-
constexpr bool enable_multithreading = false;
156-
auto partitions = sbg_partitioner::best_initial_partition(sb_graph, number_of_partitions, sbg_partitioner::InitialPartitionStrategy::ALL, enable_multithreading);
157-
sbg_partitioner::kl_sbg_imbalance_partitioner(sb_graph, partitions, 0.0, enable_multithreading);
154+
auto sb_graph = sbg_partitioner::build_sb_graph(filename);
155+
constexpr bool enable_multithreading = false;
156+
auto partitions = sbg_partitioner::best_initial_partition(sb_graph, number_of_partitions, sbg_partitioner::InitialPartitionStrategy::ALL, enable_multithreading);
157+
sbg_partitioner::kl_sbg_imbalance_partitioner(sb_graph, partitions, 0.0, enable_multithreading);
158158

159-
sbg_partitioner::sanity_check(sb_graph, partitions, number_of_partitions);
159+
sbg_partitioner::sanity_check(sb_graph, partitions, number_of_partitions);
160160

161-
// clear cache after running it
162-
sbg_partitioner::get_communication_cost().clear_communication_cache();
161+
// clear cache after running it
162+
sbg_partitioner::get_communication_cost().clear_communication_cache();
163163
}
164164

165165
TEST(partitioning, PartitionerTests)
166166
{
167-
test_partitioning(get_full_file_name("advection.json"), 2);
168-
test_partitioning(get_full_file_name("advection.json"), 4);
169-
test_partitioning(get_full_file_name("advection.json"), 8);
167+
test_partitioning(get_full_file_name("advection.json"), 2);
168+
test_partitioning(get_full_file_name("advection.json"), 4);
169+
test_partitioning(get_full_file_name("advection.json"), 8);
170170

171-
test_partitioning(get_full_file_name("air_conditioners_1000.json"), 2);
172-
test_partitioning(get_full_file_name("air_conditioners_1000.json"), 4);
173-
test_partitioning(get_full_file_name("air_conditioners_1000.json"), 8);
171+
test_partitioning(get_full_file_name("air_conditioners_1000.json"), 2);
172+
test_partitioning(get_full_file_name("air_conditioners_1000.json"), 4);
173+
test_partitioning(get_full_file_name("air_conditioners_1000.json"), 8);
174174

175-
test_partitioning(get_full_file_name("air_conditioners_cont_4_1000.json"), 4);
175+
test_partitioning(get_full_file_name("air_conditioners_cont_4_1000.json"), 4);
176176
}
177177

178178
TEST(test_adjacency_matrix, PartitionerTests)

0 commit comments

Comments
 (0)