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)
65 std::lock_guard guard(ctx.result_mutex);
70 for (
u32 current_id = start_id; current_id < end_id; ++current_id)
72 const auto& [current_state, current_pass] = ctx.current_passes[current_id];
74 if (
auto it = ctx.pass_outcome.find({current_state, current_pass.id}); it != ctx.pass_outcome.end())
78 std::lock_guard guard(ctx.result_mutex);
79 ctx.new_recurring_results.emplace_back(current_state, current_pass.id, it->second);
80 ctx.finished_passes++;
81 m_progress_printer.print_progress_to_stderr((
float)ctx.finished_passes / ctx.current_passes.size(),
82 std::to_string(ctx.finished_passes) +
"\\" + std::to_string(ctx.current_passes.size()) +
" ("
83 + std::to_string(ctx.new_unique_groupings.size()) +
" new results)");
85 m_progress_printer.print_progress_to_gui();
90 auto new_state = current_pass.function(current_state);
93 std::shared_ptr<Grouping> duplicate =
nullptr;
94 for (
const auto& other : ctx.result.unique_groupings)
96 if (*new_state == *other)
103 std::lock_guard guard(ctx.result_mutex);
104 if (duplicate ==
nullptr)
106 ctx.new_unique_groupings.emplace_back(current_state, current_pass.id, new_state);
110 ctx.new_recurring_results.emplace_back(current_state, current_pass.id, duplicate);
113 ctx.finished_passes++;
114 m_progress_printer.print_progress_to_stderr((
float)ctx.finished_passes / ctx.current_passes.size(),
115 std::to_string(ctx.finished_passes) +
"\\" + std::to_string(ctx.current_passes.size()) +
" ("
116 + std::to_string(ctx.new_unique_groupings.size()) +
" new results)");
118 m_progress_printer.print_progress_to_gui();
123 std::vector<std::pair<std::shared_ptr<Grouping>, PassConfiguration>>
124 generate_pass_combinations(Context& ctx,
const Configuration& config,
const std::shared_ptr<Grouping>& initial_grouping)
127 std::vector<std::pair<std::shared_ptr<Grouping>, PassConfiguration>>
output;
129 if (initial_grouping !=
nullptr)
133 output.emplace_back(initial_grouping, pass);
138 for (
const auto& state : ctx.result.unique_groupings)
142 output.emplace_back(state, pass);
163 log_info(
"dataflow",
"start processing layer {}", layer);
164 auto begin_time = std::chrono::high_resolution_clock::now();
167 ctx.
current_passes = generate_pass_combinations(ctx, config, (layer == 0) ? initial_grouping :
nullptr);
177 std::vector<std::thread> workers;
180 workers.emplace_back([&]() { process_pass_configuration(config, ctx); });
183 process_pass_configuration(config, ctx);
186 for (
auto& worker : workers)
191 m_progress_printer.clear();
197 begin_time = std::chrono::high_resolution_clock::now();
200 u32 num_unique_filtered = 0;
204 if (do_not_consider[i])
211 if (do_not_consider[j])
218 if (*new_state_i == *new_state_j)
220 do_not_consider[j] =
true;
221 all_new_results.emplace_back(start_state_j, pass_j, new_state_i);
226 num_unique_filtered++;
228 log_info(
"dataflow",
" filtered results in {:3.2f}s, got {} new unique results",
seconds_since(begin_time), num_unique_filtered);
230 begin_time = std::chrono::high_resolution_clock::now();
235 for (
const auto& [start_state, pass, new_state] : all_new_results)
241 if (start_pass_combinations.empty())
243 std::vector<pass_id> path{pass};
244 new_pass_combinations.push_back(path);
249 std::vector<std::vector<pass_id>> new_paths;
250 new_paths.reserve(start_pass_combinations.size());
251 for (
const auto& path : start_pass_combinations)
253 if (path.size() != layer)
257 std::vector<pass_id> new_path(path);
258 new_path.push_back(pass);
259 new_paths.push_back(new_path);
262 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