7 static constexpr
const char*
mapper_name =
"BothSmallTimeThenHeurFullTime";
31 std::cout <<
mapper_name <<
"mapper: " << msg <<
'\n';
35 Mapping mapOpGraph(std::shared_ptr<OpGraph> opgraph,
int II,
const MRRG& mrrg, std::unordered_map<std::string, std::string> fix_port)
override {
50 double last_solve_time = -1;
54 const auto advance_ilp_mapper_seed = [&] { ilp_mapper_seed += 1; };
56 for (
const auto& timeouts : {
60 const auto ilp_mapper_computed_options = [&] {
62 result.
setInt(
"ILPMapper.seed", ilp_mapper_seed);
66 const auto heur_mapper_computed_options = [&] {
72 auto ilp_future = std::async(std::launch::async, [&]() {
75 return ilp_mapper->mapOpGraph(opgraph, II, mrrg, fix_port);
78 if (
args.
getInt(
"max_threads") < 2) { ilp_future.wait(); }
80 if (timeouts.heur_wait > 0 && ilp_future.wait_for(std::chrono::seconds(timeouts.heur_wait)) == std::future_status::ready) {
82 auto ilp_mapping = ilp_future.get();
86 default: [[fallthrough]];
92 auto heur_future = std::async(std::launch::async, [&]() {
95 return heur_mapper->mapOpGraph(opgraph, II, mrrg, fix_port);
98 auto heur_mapping = heur_future.get();
99 if (heur_mapping.isMapped()) {
100 printStatus(
"Using successful ILPHeuristicMapper mapping");
105 if (ilp_future.valid()) {
106 auto ilp_mapping = ilp_future.get();
110 default: [[fallthrough]];
115 if (not heur_mapping.isTimeout()) {
116 printStatus(
"Everything returned failure without timing out, giving up");
120 last_solve_time = heur_mapping.solve_time_in_seconds;
125 failure_result.solve_time_in_seconds = last_solve_time;
126 return failure_result;
145 default: [[fallthrough]];
156 const auto final_mapping_graph =
removeIsolatedRoutingNodes(create_mapping_graph_result.mg, mrrg, create_mapping_graph_result.toMRRG);
157 const auto latency_check_result =
latencyCheck(final_mapping_graph, mrrg, create_mapping_graph_result.toMRRG);
158 return latency_check_result.first;
164 [](std::shared_ptr<CGRA> cgra,
int timelimit,
const ConfigStore& args) {
165 return std::make_unique<BothSmallTimeThenHeurFullTime>(cgra, timelimit, args);
168 "In parallel, runs both ILPHeuristicMapper and ILPMapper with a short timeout, "
169 "then ILPHeuristicMapper with the full timeout while running ILPMapper with a capped timeout. "
170 "Any successful & correct mapping is returned",
173 {
"verbosity", 0,
""},
174 {
"max_threads", 2,
""},
175 {
"initial_timeout", 25,
"Max time of the first iteration"},
176 {
"initial_heur_wait", 10,
177 "The first run of ILPHeuristicMapper will be launched this many seconds after ILPMapper\n"
178 "The point is to try to avoid the cache warm-up if possible, as that takes a while, and isn't included in the timeout."
179 "(cache warm-up can easily take tens of seconds)"
181 {
"secondary_limit", 3*60,
"Time limit applied to second run of ILPMapper"},