26 #include <catch2/catch.hpp>
30 Module god_module(
"god",
"");
32 auto makeCGRA_otho(
int w,
int h,
ConfigStore options = {}) {
36 {
"homogeneous_fu",
"1"},
42 std::unique_ptr<CGRA> makeCGRA_diag(
int w,
int h,
ConfigStore options = {}) {
46 {
"homogeneous_fu",
"1"},
52 std::unique_ptr<CGRA> makeCGRA_hycube(
int w,
int h,
ConfigStore options = {}) {
60 {
"num_const_addresses",
"1"},
64 std::unique_ptr<CGRA> makeCGRA_clustered(
int w,
int h,
ConfigStore options = {}) {
70 {
"num_const_addresses",
"1"},
74 std::unique_ptr<CGRA> makeCGRA_adres(
int w,
int h,
ConfigStore options = {}) {
78 {
"num_const_addresses",
"1"},
82 std::unordered_map<std::string, std::function<std::unique_ptr<CGRA>(
int,
int,
ConfigStore)>> cgra_makers {
83 {
"makeCGRA_otho", makeCGRA_otho },
84 {
"makeCGRA_diag", makeCGRA_diag },
85 {
"makeCGRA_hycube", makeCGRA_hycube },
86 {
"makeCGRA_clustered", makeCGRA_clustered },
87 {
"makeCGRA_adres", makeCGRA_adres },
90 MRRG makeMRRG_112221DAG(
int II,
int latency_of_a,
int latency_of_c) {
91 const int cycle_after_a = (0 + latency_of_a) % II;
92 const int cycle_after_c = (cycle_after_a + latency_of_c) % II;
96 const auto c1 = mrrg.insert(b,
MRRGNode::make_routing(&god_module, 32, cycle_after_a,
"c1", latency_of_c)).first;
97 const auto c2 = mrrg.insert(b,
MRRGNode::make_routing(&god_module, 32, cycle_after_a,
"c2", latency_of_c)).first;
109 MRRG makeMRRG_1212DAG(
int II,
int latency_of_a,
int latency_of_b,
int extra_trip_counts_on_b2) {
110 const int cycle_after_a = (0 + latency_of_a) % II;
111 const int cycle_after_b = (cycle_after_a + latency_of_b) % II;
112 const auto latency_of_b1 = latency_of_b;
113 const auto latency_of_b2 = latency_of_b + II*extra_trip_counts_on_b2;
116 const auto b1 = mrrg.insert(a,
MRRGNode::make_routing (&god_module, 32, cycle_after_a,
"b1", latency_of_b1)).first;
117 const auto b2 = mrrg.insert(a,
MRRGNode::make_routing (&god_module, 32, cycle_after_a,
"b2", latency_of_b2)).first;
118 const auto c = mrrg.insertMultiFanin({b1,b2},
MRRGNode::make_routing(&god_module, 32, cycle_after_b,
"c", 0)).first;
128 MRRG makeMRRG_1112DAG(
int II,
int latency_of_a,
int latency_of_b) {
129 const int cycle_after_a = (0 + latency_of_a) % II;
130 const int cycle_after_b = (cycle_after_a + latency_of_b) % II;
133 const auto b = mrrg.insert(a,
MRRGNode::make_routing (&god_module, 32, cycle_after_a,
"b", latency_of_b)).first;
153 MRRG makeMRRG_Loop3NodeMaybeExtraFU(
int II,
bool has_extra_fu,
int num_shared_nodes,
int latency_of_a,
int latency_of_b) {
154 const int cycle_after_a = (0 + latency_of_a) % II;
155 const int cycle_after_b = (cycle_after_a + latency_of_b) % II;
158 const auto b = mrrg.insert(a,
MRRGNode::make_routing (&god_module, 32, cycle_after_a,
"b", latency_of_b)).first;
163 const auto fanin = [&,fname=__func__]() {
164 if (num_shared_nodes == 0) {
return mrrg.insert(a,
MRRGNode::make_routing(&god_module, 32, 0,
"b2", 0)).first; }
165 if (num_shared_nodes == 1) {
return b; }
166 if (num_shared_nodes == 2) {
return c; }
167 throw std::logic_error(fname + (
": trying to share too many nodes: " +
std::to_string(num_shared_nodes)));
176 std::unordered_map<std::string, EdgeCoster> edgeCosters {
183 (void)src_op; (void)sink_op;
188 {
"all-zero", [](
auto&,
auto&,
auto&,
auto&,
auto&) ->
double {
return 0; } },
191 struct MapOpsJustByConnectivityTestDescription {
193 std::string cgra_description;
194 std::pair<int,int> cgra_II_min_max;
195 std::string opgraph_description;
196 std::string neighbour_finder_description;
197 std::function<std::unique_ptr<CGRA>()> cgra_generator;
198 std::function<
OpGraph()> opgraph_generator;
205 const auto& simpO2x2 =
"simple 2-by-2 grid";
206 const auto& make_simpO2x2 = []{
return makeCGRA_otho(2,2);};
207 const auto& simpO3x3 =
"simple 3-by-3 grid";
208 const auto& make_simpO3x3 = []{
return makeCGRA_otho(3,3);};
209 std::unordered_map<std::string, std::string> fix_port;
210 const auto& test = GENERATE_REF(values<MapOpsJustByConnectivityTestDescription>({
229 GIVEN(
"A " << test.cgra_description <<
" CGRA") {
230 const auto cgra = test.cgra_generator();
231 const auto cgra_II = GENERATE_REF(range(test.cgra_II_min_max.first, test.cgra_II_min_max.second+1));
232 GIVEN (
"A CGRA II of " << cgra_II) {
233 const auto& mrrg = cgra->getMRRG(cgra_II);
235 GIVEN(
"A " << test.opgraph_description <<
" DFG") {
236 const auto opgraph = test.opgraph_generator();
238 WHEN (
"Placed with a " << test.neighbour_finder_description <<
" neighbour finder") {
241 test.neighbour_finder,
249 THEN (
"Placement will " << (test.expect_to_map ?
"succeed" :
"fail")) {
250 CHECK(test.expect_to_map == mapping.isMapped());
258 template<
typename PLACEMENTS>
260 const std::size_t nplace,
261 const PLACEMENTS& placements,
264 THEN (
"Placement should fail after " << nplace <<
" placements") {
265 CHECK(final_mapping.
isMapped() ==
false);
266 CHECK(placements.size() == nplace);
270 template<
typename NFINDER,
typename EDGE_COSTER>
272 const std::size_t nplace,
274 const NFINDER& neighbour_finder,
const EDGE_COSTER& edge_coster,
277 std::vector<Mapping> placements;
278 std::unordered_map<std::string, std::string> fix_port;
279 const auto placement_recorder = [&](
const Mapping& m) ->
Mapping {
280 placements.push_back(m);
284 return placements.back();
295 const int rotational_symmetry = 4;
297 {
const int w = 2;
const int h = 2;
298 GIVEN(
"A simple " << w <<
"-by-" << h <<
" grid CGRA") {
299 const auto cgra = makeCGRA_otho(w,h);
301 const int num_contexts = 1;
302 GIVEN (
"A CGRA II of " << num_contexts) {
303 const auto mrrg = cgra->getMRRG(num_contexts);
305 GIVEN(
"A linear 3-node DFG") {
314 GIVEN(
"A Converging 121 DFG") {
316 const int dfg_symmetry = 2;
319 (1)*num_contexts*rotational_symmetry*dfg_symmetry,
324 GIVEN(
"A Self Loop 3 Node DFG") {
326 const int dfg_symmetry = 2;
329 (1)*num_contexts*rotational_symmetry*dfg_symmetry,
334 GIVEN(
"A Loop 4 Node DFG") {
336 const int dfg_symmetry = 2;
339 (1)*num_contexts*rotational_symmetry*dfg_symmetry,
346 {
const int w = 2;
const int h = 2;
const int fu_lat = 1;
347 GIVEN(
"A simple " << w <<
"-by-" << h <<
" with FU latency " << fu_lat <<
" grid CGRA") {
348 const auto cgra = makeCGRA_otho(w,h,{ {
"fu_latency",
std::to_string(fu_lat)} });
350 const int num_contexts = 2;
351 GIVEN (
"A CGRA II of " << num_contexts) {
352 const auto mrrg = cgra->getMRRG(num_contexts);
354 GIVEN(
"A linear 3-node DFG") {
358 6*num_contexts*rotational_symmetry,
363 GIVEN(
"A Converging 121 DFG") {
365 const int dfg_symmetry = 2;
368 3*num_contexts*rotational_symmetry*dfg_symmetry,
373 GIVEN(
"A Self Loop 3 Node DFG") {
375 const int dfg_symmetry = 2;
378 3*num_contexts*rotational_symmetry*dfg_symmetry,
383 GIVEN(
"A Loop 4 Node DFG") {
385 const int dfg_symmetry = 2;
388 6*num_contexts*rotational_symmetry*dfg_symmetry,
395 {
const int w = 3;
const int h = 3;
396 GIVEN(
"A simple " << w <<
"-by-" << h <<
" grid CGRA") {
397 const auto cgra = makeCGRA_otho(w,h);
399 const int num_contexts = 2;
400 GIVEN (
"A CGRA II of " << num_contexts) {
401 const auto mrrg = cgra->getMRRG(num_contexts);
403 GIVEN(
"A Converging 121 DFG") {
405 const int dfg_symmetry = 2;
408 (3 + 5 + 2)*num_contexts*rotational_symmetry*dfg_symmetry,
413 GIVEN(
"A Large DFG only requiring NN FUs") {
417 num_contexts*rotational_symmetry*135,
423 GIVEN(
"A Tree 112 DFG") {
425 const int dfg_symmetry = 2;
429 ((7 + 11 + 4)*rotational_symmetry + 2)*num_contexts*dfg_symmetry,
437 SCENARIO (
"routeOpMappingByChoosingPaths Tests",
"") {
438 std::unordered_map<std::string, std::string> fix_port;
439 GIVEN(
"A simple 2-by-2 grid CGRA") {
440 const auto cgra = makeCGRA_otho(2,2);
442 auto cgra_II = GENERATE(1,2);
443 GIVEN (
"A CGRA II of " << cgra_II) {
444 const auto mrrg = cgra->getMRRG(cgra_II);
446 GIVEN(
"A linear 3-node DFG") {
449 GIVEN(
"An op mapping that should work") {
458 THEN (
"Mapping should map") {
459 CHECK(mapping.isMapped());
465 GIVEN(
"A Converging 121 DFG") {
468 GIVEN(
"An op mapping that should work") {
478 THEN (
"Mapping should map") {
479 CHECK(mapping.isMapped());
485 GIVEN(
"A Self Loop 3 Node DFG") {
495 THEN (
"Mapping should map") {
496 CHECK(mapping.isMapped());
501 GIVEN(
"A Loop 4 Node DFG") {
512 THEN (
"Mapping should map") {
513 CHECK(mapping.isMapped());
518 GIVEN(
"A MultiEdge 11 DFG") {
527 THEN (
"Mapping should map") {
528 CHECK(mapping.isMapped());
535 GIVEN(
"A simple 2-by-3 grid CGRA") {
536 const auto cgra = makeCGRA_otho(2,2);
538 GIVEN (
"A CGRA II of 3") {
539 const auto mrrg = cgra->getMRRG(3);
541 GIVEN(
"A DeviceFiller DFG") {
543 {
"width",
"2"}, {
"height",
"2"}, {
"num_contexts",
"3"}
546 GIVEN(
"An op mapping that should work") {
566 THEN (
"Mapping should map") {
567 CHECK(mapping.isMapped());
576 SCENARIO (
"Try op mappings until one routes - Easy",
"") {
577 std::unordered_map<std::string, std::string> fix_port;
578 GIVEN(
"A simple 2-by-2 grid CGRA") {
579 const auto cgra = makeCGRA_otho(2,2);
581 GIVEN (
"A CGRA II of 1") {
582 const auto mrrg = cgra->getMRRG(1);
584 GIVEN(
"A linear 3-node DFG") {
592 THEN (
"Mapping should map") {
593 CHECK(mapping.isMapped());
598 GIVEN(
"A Converging 121 DFG") {
606 THEN (
"Mapping should map") {
607 CHECK(mapping.isMapped());
614 GIVEN(
"A simple 2-by-2 grid CGRA") {
615 const auto cgra = makeCGRA_otho(2,2);
617 {
const int num_contexts = GENERATE(1,2,3);
618 GIVEN (
"A CGRA II of " << num_contexts) {
619 const auto mrrg = cgra->getMRRG(num_contexts);
621 GIVEN(
"A DeviceFiller DFG") {
623 {
"width",
"2"}, {
"height",
"2"}, {
"num_contexts",
std::to_string(num_contexts)}
627 const int nneigh = 1;
632 THEN (
"Mapping should map") {
633 CHECK(mapping.isMapped());
644 SCENARIO (
"Try op mappings until one routes - Sometimes hard",
"[!hide]") {
645 std::unordered_map<std::string, std::string> fix_port;
646 GIVEN(
"A simple 2-by-3 grid CGRA") {
647 const auto cgra = makeCGRA_otho(2,3);
649 GIVEN (
"A CGRA II of 3") {
650 const auto mrrg = cgra->getMRRG(3);
652 GIVEN(
"A Large DFG") {
659 while (nneigh < 16 && not mapping.
isMapped()) {
666 THEN (
"Mapping should map with 8 NNs") {
704 GIVEN(
"A simple 4-by-4 grid+diag CGRA") {
705 const auto cgra = makeCGRA_diag(4,4);
707 GIVEN (
"A CGRA II of 2") {
708 const auto mrrg = cgra->getMRRG(2);
710 GIVEN(
"A Larger DFG") {
717 while (nneigh < 10 && not mapping.
isMapped()) {
724 THEN (
"Mapping should map with 6 NNs") {
736 struct PathMergingTest {
737 std::string description, mrrg_description, dfg_description;
742 std::map<std::string,int> expected_op_output_val_mapping_sizes;
744 int expected_number_of_mappings;
752 std::unordered_map<std::string, std::string> fix_port;
753 const PathMergingTest tests[] {
754 {
"No choices",
"1112",
"Tree12",makeMRRG_1112DAG(1,0,0),
makeDFG_Tree12(),
757 {
"No choices -- latency on b",
"1112",
"Tree12",makeMRRG_1112DAG(1,0,1),
makeDFG_Tree12(),
760 {
"Two choices",
"1212",
"Tree12",makeMRRG_1212DAG(1,0,0,0),
makeDFG_Tree12(),
763 {
"Two choices -- only one path",
"1212",
"Tree12",makeMRRG_1212DAG(1,0,0,0),
makeDFG_Tree12(),
764 {{
"op_a",2}}, 2, {{
"max_num_paths_between_FUs",
"1"}},
766 {
"Two choices -- matched latency",
"1212",
"Tree12",makeMRRG_1212DAG(1,0,1,0),
makeDFG_Tree12(),
769 {
"Two choices -- mismatched latency",
"1212",
"Tree12",makeMRRG_1212DAG(1,0,1,1),
makeDFG_Tree12(),
770 {{
"op_a",2}}, 4, {{
"path_exclusivity_constraints_are_pairwise",
"yes"}},
772 {
"Loop",
"3NodeLoop",
"self-loop", makeMRRG_Loop3NodeMaybeExtraFU(1,
false,0,1,0),
makeDFG_SelfLoop1Node(),
775 {
"Loop with leg, sharing",
"3NodeLoop-extra-FU",
"self-loop", makeMRRG_Loop3NodeMaybeExtraFU(1,
true,0,1,0),
makeDFG_SelfLoop1Node(),
778 {
"Loop with leg, no sharing",
"3NodeLoop-extra-FU",
"self-loop with extra fanout", makeMRRG_Loop3NodeMaybeExtraFU(1,
true,0,1,0),
makeDFG_SelfLoop1NodeWith1ExtraFanout(),
783 const auto name_and_mapper_config = GENERATE(values<std::pair<std::string,ConfigStore>>({
784 {
"pairwise pathex", {{
"path_exclusivity_constraints_are_pairwise",
"yes"}}},
785 {
"non-pairwise pathex", {{
"path_exclusivity_constraints_are_pairwise",
"no"}}},
788 const auto& test = tests[GENERATE_REF(range<std::ptrdiff_t>(0, std::distance(
std::begin(tests),
std::end(tests))))];
790 const auto& opgraph = test.opgraph;
792 DYNAMIC_SECTION(
"A '" << test.description <<
"' test") {
793 GIVEN(
"A '" << name_and_mapper_config.first <<
"' mapper configuration") {
794 GIVEN(
"A '" << test.dfg_description <<
"' DFG") {
795 GIVEN(
"A '" << test.mrrg_description <<
"' MRRG") {
797 {
"model_IIS_dump_filename",
"non-pairwise-no-solution"},
798 }, name_and_mapper_config.second), test.custom_mapping_options);
800 const auto initial_mapping =
Mapping{
nullptr, test.mrrg.initiationInterval(),
nullptr};
801 int num_mappings = 0;
804 makeNClosestNeighbourFinder(2),
807 for (const auto& op_name_and_expected_val_size : test.expected_op_output_val_mapping_sizes) {
808 const auto& op = opgraph.getOp(op_name_and_expected_val_size.first);
809 const auto& op_output_val_mapping = m.getMappingList(opgraph.outputVal(op));
811 "for mapping #" << num_mappings <<
", the output val of "
812 << opgraph.getNodeRef(op).getName() <<
" should map to the expected number of MRRG nodes"
814 CHECK(op_output_val_mapping.size() == op_name_and_expected_val_size.second);
816 m.setStatus(MappingStatus::failure);
823 THEN(
"The number of mappings should be as expected, to make sure no cases were missed") {
825 CHECK(num_mappings == test.expected_number_of_mappings);
832 {
"partition_method",
"0"},
835 {
"filter_consts",
"no"},
836 {
"do_test_placement",
"no"},
839 const auto possibly_print_and_dump_dfg = [](
const OpGraph& opgraph,
auto&& name,
const ConfigStore& options) {
840 if (options.getBool(
"dump_DFG")) {
841 std::ofstream dfg_ofstream {
string_from_stream([&](
auto&&s) { s << name <<
"-DFG.dot"; })};
843 dfg_ofstream.flush();
845 if (options.getBool(
"print_DFG")) { opgraph.
serialize(std::cout); }
849 GIVEN(
"A 4-by-4 HyCUBE CGRA") {
850 const auto cgra = makeCGRA_hycube(4,4);
852 SECTION(
"loopAllOpMappings test") {
855 for (
int numc = 16; numc <= 16; numc += 4) {
856 bool mapping_worked =
true;
857 const auto mrrg = cgra->getMRRG(numc);
861 std::unordered_map<std::string, std::string> fix_port;
862 for (; i <= 269 && mapping_worked; i += 1) {
863 std::vector<int> ops_wanted(i + 1);
864 std::iota(ops_wanted.begin(), ops_wanted.end(), 0);
869 const auto opgraph =
makeDFG_Huge(ops_wanted, test_options);
870 possibly_print_and_dump_dfg(opgraph,
"P0", test_options);
873 {
"path_exclusivity_modelling",
"off"},
874 {
"print_solve_progress",
"yes"},
875 {
"max_threads",
"1"},
879 {
"path_exclusivity_modelling",
"on"},
880 {
"max_num_paths_between_FUs",
"3"},
881 {
"allowable_routing_usage_multiplier",
"2"},
883 {
"print_configuration_and_statistics",
"yes"},
884 {
"print_solve_progress",
"yes"},
885 {
"max_threads",
"1"},
889 {
"max_threads",
"1"},
892 const auto edge_coster_name =
"no-cost";
893 const EdgeCoster edgeCoster = edgeCosters.at(edge_coster_name);
895 std::cout <<
"trying to place & route ops 0-" << i <<
" with coster " << edge_coster_name <<
'\n';
897 std::cout <<
"\nA CGRA II of " << numc <<
'\n';
898 std::cout <<
"with outer options " << outer_options <<
'\n';
904 const int nneigh_step = 1;
905 int nneigh = 18 - nneigh_step;
906 while (nneigh < 20 && not mapping.
isMapped()) {
907 nneigh += nneigh_step;
908 std::cout <<
"trying to place & route with NN = " << nneigh <<
'\n';
909 if (test_options.getInt(
"partition_method") == 0) {
910 if (test_options.getBool(
"do_test_placement")) {
917 if (not test_placement.isMapped()) {
925 }, edgeCoster, outer_options}, ilphm_caches);
926 }
else if (test_options.getInt(
"partition_method") == 1) {
927 const int num_partitions = 2;
929 const auto map_partitions = [&](
932 const auto& mapping_so_far
935 if (level > num_partitions) {
936 auto local_inner_options = inner_options;
937 local_inner_options.
setString(
"solve_approach_name",
"Final Route");
946 const auto input_nodes =
filter_collection(opgraph.
opNodes(), [&](
const auto& op) { return opgraph.inputVals(op).empty(); });
948 const auto opgraph_filter_result =
filter(opgraph, ops_to_use);
949 const auto mapping_so_far_for_filtered_opgraph =
withRemappedOps(mapping_so_far, opgraph_filter_result.forward_mappings);
951 auto local_outer_options = outer_options;
952 local_outer_options.setString(
"solve_approach_name",
"Place Partition " + level_string);
953 if (local_outer_options.getStringOr(
"model_IIS_dump_filename",
"") !=
"") { local_outer_options.setString(
"model_IIS_dump_filename", level_string +
'-' + local_outer_options.getString(
"model_IIS_dump_filename")); }
954 if (local_outer_options.getStringOr(
"model_dump_filename",
"") !=
"") { local_outer_options.setString(
"model_dump_filename", level_string +
'-' + local_outer_options.getString(
"model_dump_filename")); }
957 local_outer_options.setInt(
"max_solutions", 10);
960 possibly_print_and_dump_dfg(opgraph, level_string, test_options);
964 opgraph_filter_result.transform_result,
966 mapping_so_far_for_filtered_opgraph,
968 makeNClosestNeighbourFinder(nneigh + 10*(level-1)),
969 [&](auto& proposed_mapping) {
970 const auto proposed_mapping_for_original_opgraph = withRemappedOps(proposed_mapping, opgraph_filter_result.reverse_mappings);
971 return map_rest(level+1, map_rest, proposed_mapping_for_original_opgraph);
981 mapping = map_partitions(1, map_partitions, empty_mapping);
985 mapping_worked = mapping.isMapped();
986 if (mapping.isMapped()) {
987 std::cout <<
": PASSED: with NN " << nneigh <<
"\n";
989 std::cout <<
": FAILED: with NN " << nneigh <<
"\n";
1036 {
"do_cache_warmups",
"yes"},
1039 const std::string demo_path_prefix = std::getenv(
"CGRA_ME_BENCHMARKDIR");
1040 const std::string demo_path_suffix =
"/graph_loop.dot";
1042 const std::vector<std::string> demo_names {
1043 "/microbench/accumulate",
1046 "/microbench/conv2",
1047 "/microbench/conv3",
1051 "/microbench/matrixmultiply",
1052 "/microbench/mults1",
1053 "/microbench/mults2",
1054 "/microbench/nomem1",
1055 "/microbench/simple",
1056 "/microbench/simple2",
1060 const std::vector<std::pair<int,int>> cgra_sizes {
1066 const std::vector<int> context_counts {
1072 struct DemoSettings {
1074 {
"path_exclusivity_modelling",
"off"},
1075 {
"print_solve_progress",
"yes"},
1078 {
"print_configuration_and_statistics",
"yes"},
1079 {
"path_exclusivity_modelling",
"on"},
1080 {
"max_num_paths_between_FUs",
"3"},
1081 {
"allowable_routing_usage_multiplier",
"2"},
1082 {
"print_solve_progress",
"yes"},
1083 {
"print_intermediate_mappings",
"yes"},
1085 std::string outer_edge_coster_name =
"no-cost";
1087 ConfigStore cgra_options = {{
"num_const_addresses",
"1"}};
1089 {
"cgra_maker",
"makeCGRA_clustered"},
1093 {
"nneigh_start",
"8"},
1094 {
"nneigh_stop",
"16"},
1095 {
"nneigh_step",
"1"},
1109 {
"do_test_placement",
"yes"},
1113 std::vector<DemoSettings> demo_settings_storage;
1114 std::vector<DemoSettings> cache_warm_up_demo_settings;
1116 for (
const auto& dims : cgra_sizes) {
1117 for (
const auto num_contexts : context_counts) {
1118 for (
const auto& name : demo_names) {
1119 DemoSettings settings;
1121 {
"cols", std::to_string(dims.first)},
1122 {
"rows", std::to_string(dims.second)},
1128 {
"num_contexts", std::to_string(num_contexts)},
1130 demo_settings_storage.push_back(std::move(settings));
1132 cache_warm_up_demo_settings.push_back(demo_settings_storage.back());
1133 auto& warm_up_settings = cache_warm_up_demo_settings.back();
1134 auto& warm_up_other_opts = warm_up_settings.other_options;
1135 warm_up_other_opts.
setString(
"name",
"/microbench/sum");
1136 warm_up_settings.outer_options.setInt(
"max_num_paths_between_FUs", 20);
1137 warm_up_other_opts.setInt(
"nneigh_start", warm_up_other_opts.getInt(
"nneigh_stop"));
1141 if (not test_options.getBool(
"do_cache_warmups")) {
1142 cache_warm_up_demo_settings.clear();
1145 const auto dfg_path_for = [&](
const DemoSettings& ds) {
1146 return demo_path_prefix + ds.other_options.getString(
"name") + demo_path_suffix;
1149 const auto mrrg_id_for = [&](
const DemoSettings& ds) {
1151 s << ds.cgra_options << ds.other_cgra_options;
1155 std::map<std::string, const MRRG> mrrgs;
1156 std::map<std::string, std::unique_ptr<MRRGProcedureCacheHandle>> mrrg_cache_handles;
1157 std::map<std::string, ILPHeuristicMapperCaches> ilphm_caches;
1158 std::map<std::string, OpGraph> opgraphs;
1159 std::unordered_map<std::string, std::string> fix_port;
1161 for (
const auto& demo_settings : demo_settings_storage) {
1162 const auto& num_contexts = demo_settings.other_cgra_options.getInt(
"num_contexts");
1163 const auto& cgra = cgra_makers.at(demo_settings.other_cgra_options.getString(
"cgra_maker"))(-1,-1,demo_settings.cgra_options);
1164 const auto mrrg_id = mrrg_id_for(demo_settings);
1165 mrrgs.emplace(mrrg_id, cgra->getMRRG(num_contexts));
1166 mrrg_cache_handles.emplace(mrrg_id, std::make_unique<MRRGProcedureCacheHandle>());
1168 auto dfg_ifstream = std::ifstream(dfg_path_for(demo_settings));
1169 const auto parsed_dfg_dot =
parseDot(dfg_ifstream, dfg_path_for(demo_settings));
1174 stats.
setInt(
"num mrrgs", mrrgs.size());
1175 stats.
setInt(
"num mrrg_caches", mrrg_cache_handles.size());
1176 stats.
setInt(
"num ilphm caches", ilphm_caches.size());
1177 stats.
setInt(
"num opgraphs", opgraphs.size());
1178 std::cout <<
"Demo Stats = " << stats <<
'\n';
1180 for (
const auto& demo_settings_list : {cache_warm_up_demo_settings, demo_settings_storage}) {
1181 for (
const auto& demo_settings : demo_settings_list) {
1183 std::cout <<
"with other_options = " << demo_settings.other_options <<
'\n';
1184 std::cout <<
"with cgra_options = " << demo_settings.cgra_options <<
'\n';
1185 std::cout <<
"with other_cgra_options = " << demo_settings.other_cgra_options <<
'\n';
1188 const auto mrrg_id = mrrg_id_for(demo_settings);
1189 const auto& mrrg = mrrgs.at(mrrg_id);
1190 const auto& caches = ilphm_caches.at(mrrg_id);
1191 const auto& opgraph = opgraphs.at(dfg_path_for(demo_settings));
1195 timing_seq.tick(
"setup");
1196 const auto nneigh_step = demo_settings.other_options.getInt(
"nneigh_step");
1197 auto nneigh = demo_settings.other_options.getInt(
"nneigh_start") - nneigh_step;
1198 while (nneigh < demo_settings.other_options.getInt(
"nneigh_stop") && not mapping.isMapped()) {
1199 nneigh += nneigh_step;
1200 if (demo_settings.other_options.getBool(
"do_test_placement")) {
1203 timing_seq.tick(
"test placement for NN = " +
std::to_string(nneigh), 0.0, &std::cout);
1204 if (not test_placement.isMapped()) {
1211 }, edgeCosters.at(demo_settings.outer_edge_coster_name), demo_settings.outer_options}, caches);
1212 timing_seq.tick(
"tried NN = " +
std::to_string(nneigh), 0.0, &std::cout);
1215 CHECK(mapping.isMapped());