27 ProgressPrinter m_progress_printer;
29 void process_pass_configuration(
const Configuration& config, Context& ctx)
31 u32 num_passes = ctx.current_passes.size();
40 std::lock_guard<std::mutex> guard(ctx.progress_mutex);
50 start_id = ctx.pass_counter;
51 u32 remaining_passes = num_passes - start_id;
55 if (remaining_passes < config.num_threads *
work / 2)
57 work = std::max(1u, remaining_passes / config.num_threads);
60 end_id = std::min(start_id +
work, (
u32)num_passes);
62 ctx.pass_counter = end_id;
63 if (ctx.pass_counter >= num_passes)
69 for (
u32 current_id = start_id; current_id < end_id; ++current_id)
71 const auto& [current_state, current_pass] = ctx.current_passes[current_id];
73 if (
auto it = ctx.pass_outcome.find({current_state, current_pass.id}); it != ctx.pass_outcome.end())
76 std::lock_guard guard(ctx.result_mutex);
77 ctx.new_recurring_results.emplace_back(current_state, current_pass.id, it->second);
78 ctx.finished_passes++;
79 m_progress_printer.print_progress((
float)ctx.finished_passes / ctx.current_passes.size(),
80 std::to_string(ctx.finished_passes) +
"\\" + std::to_string(ctx.current_passes.size()) +
" ("
81 + std::to_string(ctx.new_unique_groupings.size()) +
" new results)");
86 auto new_state = current_pass.function(current_state);
89 std::shared_ptr<Grouping> duplicate =
nullptr;
90 for (
const auto& other : ctx.result.unique_groupings)
92 if (*new_state == *other)
99 std::lock_guard guard(ctx.result_mutex);
100 if (duplicate ==
nullptr)
102 ctx.new_unique_groupings.emplace_back(current_state, current_pass.id, new_state);
106 ctx.new_recurring_results.emplace_back(current_state, current_pass.id, duplicate);
109 ctx.finished_passes++;
110 m_progress_printer.print_progress((
float)ctx.finished_passes / ctx.current_passes.size(),
111 std::to_string(ctx.finished_passes) +
"\\" + std::to_string(ctx.current_passes.size()) +
" ("
112 + std::to_string(ctx.new_unique_groupings.size()) +
" new results)");
118 std::vector<std::pair<std::shared_ptr<Grouping>, PassConfiguration>>
119 generate_pass_combinations(Context& ctx,
const Configuration& config,
const std::shared_ptr<Grouping>& initial_grouping)
122 std::vector<std::pair<std::shared_ptr<Grouping>, PassConfiguration>>
output;
124 if (initial_grouping !=
nullptr)
128 output.emplace_back(initial_grouping, pass);
133 for (
const auto& state : ctx.result.unique_groupings)
137 output.emplace_back(state, pass);
158 log_info(
"dataflow",
"start processing layer {}", layer);
159 auto begin_time = std::chrono::high_resolution_clock::now();
162 ctx.
current_passes = generate_pass_combinations(ctx, config, (layer == 0) ? initial_grouping :
nullptr);
172 std::vector<std::thread> workers;
175 workers.emplace_back([&]() { process_pass_configuration(config, ctx); });
178 process_pass_configuration(config, ctx);
181 for (
auto& worker : workers)
186 m_progress_printer.clear();
192 begin_time = std::chrono::high_resolution_clock::now();
195 u32 num_unique_filtered = 0;
199 if (do_not_consider[i])
206 if (do_not_consider[j])
213 if (*new_state_i == *new_state_j)
215 do_not_consider[j] =
true;
216 all_new_results.emplace_back(start_state_j, pass_j, new_state_i);
221 num_unique_filtered++;
223 log_info(
"dataflow",
" filtered results in {:3.2f}s, got {} new unique results",
seconds_since(begin_time), num_unique_filtered);
225 begin_time = std::chrono::high_resolution_clock::now();
230 for (
const auto& [start_state, pass, new_state] : all_new_results)
236 if (start_pass_combinations.empty())
238 std::vector<pass_id> path{pass};
239 new_pass_combinations.push_back(path);
244 std::vector<std::vector<pass_id>> new_paths;
245 new_paths.reserve(start_pass_combinations.size());
246 for (
const auto& path : start_pass_combinations)
248 if (path.size() != layer)
252 std::vector<pass_id> new_path(path);
253 new_path.push_back(pass);
254 new_paths.push_back(new_path);
257 new_pass_combinations.insert(new_pass_combinations.end(), new_paths.begin(), new_paths.end());
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the work(an example is provided in the Appendix below). "Derivative Works" shall mean any work
#define log_info(channel,...)
std::vector< PassConfiguration > get_passes(const Configuration &config, const std::vector< std::vector< pass_id >> &previous_passes)
processing::Result run(const processing::Configuration &config, const std::shared_ptr< Grouping > &initial_grouping)
This file contains the struct that holds all information on the netlist abstraction used for dataflow...
This file contains the class that holds all information of a dataflow analysis grouping.
std::vector< std::pair< std::shared_ptr< Grouping >, PassConfiguration > > current_passes
std::vector< std::tuple< std::shared_ptr< Grouping >, pass_id, std::shared_ptr< Grouping > > > new_recurring_results
std::map< std::pair< std::shared_ptr< Grouping >, pass_id >, std::shared_ptr< Grouping > > pass_outcome
std::vector< std::tuple< std::shared_ptr< Grouping >, pass_id, std::shared_ptr< Grouping > > > new_unique_groupings
processing::Result result
std::map< std::shared_ptr< Grouping >, std::vector< std::vector< pass_id > > > pass_combinations_leading_to_grouping
std::map< std::vector< pass_id >, std::shared_ptr< Grouping > > groupings
std::vector< std::shared_ptr< Grouping > > unique_groupings