diff --git a/experiments/legalization/legalization.cpp b/experiments/legalization/legalization.cpp index ddf6cea39..59bf40c77 100644 --- a/experiments/legalization/legalization.cpp +++ b/experiments/legalization/legalization.cpp @@ -5,31 +5,30 @@ #include "experiments.hpp" #include "fiction/algorithms/network_transformation/fanout_substitution.hpp" #include "fiction/algorithms/properties/check_planarity_balanced.hpp" -#include "fiction/utils/debug/network_writer.hpp" +#include "fiction/layouts/clocked_layout.hpp" +#include "fiction/layouts/cartesian_layout.hpp" +#include "fiction/layouts/tile_based_layout.hpp" +#include "fiction/layouts/gate_level_layout.hpp" +#include "fiction/layouts/coordinates.hpp" #include "fiction_experiments.hpp" #include #include -#include // scalable heuristic for physical design -#include // wiring reduction algorithm -#include // critical path and throughput calculations -#include // SAT-based equivalence checking +#include // scalable heuristic for physical design +#include #include -#include #include // read networks from files #include #include #include -#include // output formatting #include -#include -#include -#include +#include +#include #include #include -#include +#include #include #include @@ -49,12 +48,11 @@ Ntk read_ntk(const std::string& name) int main() // NOLINT { - experiments::experiment + experiments::experiment wiring_reduction_exp{"planarization", "benchmark", "inputs", "virt_inputs", "outputs", "initial nodes", "nodes buffered", "nodes planarized", "is_planar", "equivalent(ntk)", "equivalent(lyt)"}; - int x = 0; for (const auto& entry : std::filesystem::directory_iterator("/home/benjamin/Documents/Repositories/working/fiction/benchmarks/IWLS93")) { @@ -90,29 +88,10 @@ int main() // NOLINT auto benchmark_network = *nets.front(); - bool cont = false; - benchmark_network.foreach_pi( - [&benchmark_network, &cont](auto pi) - { - if (benchmark_network.is_po(pi)) - { - cont = true; - // std::cout << "Pi is Po\n"; - } - }); - if (cont) - { - continue; - } - - // fiction::debug::write_dot_network(benchmark_network); - - // std::cout << benchmark_network.num_gates() << std::endl; - fiction::network_balancing_params ps; ps.unify_outputs = true; - const auto _b = fiction::network_balancing( + const auto b = fiction::network_balancing( fiction::fanout_substitution(benchmark_network), ps); // happens with exp4.v @@ -127,22 +106,12 @@ int main() // NOLINT std::cout << "Node 9213: " << fc.fanin_nodes.size() << std::endl; std::cout << "Node 9213: " << _b.is_buf(8771) << std::endl;*/ - // std::cout << _b.num_gates() << std::endl; - - // fiction::debug::write_dot_network(_b); - - if (_b.size() > 10000) + if (b.size() > 10000) { - /*wiring_reduction_exp(entry.path().filename().string(), benchmark_network.num_pis(), 0, - benchmark_network.num_pos(), benchmark_network.num_gates(), _b.num_gates(), - _b.num_gates(), 0, 0, 0); - wiring_reduction_exp.save(); - wiring_reduction_exp.table(); - std::cout << ++x << "\n";*/ continue; } - const auto planarized_b = fiction::node_duplication_planarization(_b); + const auto planarized_b = fiction::node_duplication_planarization(b); const auto is_planar = fiction::check_planarity(planarized_b); if (planarized_b.size() > 20000) { @@ -152,80 +121,34 @@ int main() // NOLINT const auto cec_m = mockturtle::equivalence_checking( *fiction::virtual_miter(benchmark_network, planarized_b), {}, &st); assert(cec_m.has_value()); - std::cout << cec_m.value() << std::endl; - - using gate_lyt = fiction::gate_level_layout< - fiction::clocked_layout>>>; fiction::orthogonal_physical_design_stats stats{}; using gate_layout = fiction::gate_level_layout< fiction::clocked_layout>>>; auto layout = fiction::orthogonal(planarized_b, {}, &stats); - fiction::gate_level_drv_params ps_d{}; + const fiction::gate_level_drv_params ps_d{}; fiction::gate_level_drv_stats st_d{}; fiction::gate_level_drvs(layout, ps_d, &st_d); const auto miter = mockturtle::miter(planarized_b, layout); - bool eq; + bool eq = false; if (miter) { - mockturtle::equivalence_checking_stats st; + mockturtle::equivalence_checking_stats st_o; - const auto ce = mockturtle::equivalence_checking(*miter, {}, &st); + const auto ce = mockturtle::equivalence_checking(*miter, {}, &st_o); eq = ce.value(); } wiring_reduction_exp(entry.path().filename().string(), benchmark_network.num_pis(), planarized_b.num_virtual_pis(), benchmark_network.num_pos(), benchmark_network.num_gates(), - _b.num_gates(), planarized_b.num_gates(), is_planar, cec_m.value(), eq); + b.num_gates(), planarized_b.num_gates(), is_planar, cec_m.value(), eq); wiring_reduction_exp.save(); wiring_reduction_exp.table(); - std::cout << ++x << "\n"; } - /*fiction::technology_network tec; - const auto pi0 = tec.create_pi(); - const auto pi1 = tec.create_pi(); - const auto pi2 = tec.create_pi(); - const auto pi3 = tec.create_pi(); - const auto pi4 = tec.create_pi(); - - const auto a0 = tec.create_and(pi0, pi1); - const auto o0 = tec.create_or(pi0, pi1); - const auto a1 = tec.create_and(pi3, pi4); - const auto o1 = tec.create_or(pi3, pi4); - - const auto a2 = tec.create_and(o0, pi2); - const auto a3 = tec.create_and(o1, pi2); - const auto a4 = tec.create_and(a2, a3); - - tec.create_po(a0); - tec.create_po(a4); - tec.create_po(a1); - - fiction::network_balancing_params ps; - ps.unify_outputs = true; - - const auto _b = fiction::network_balancing( - fiction::fanout_substitution(tec), ps); - - - const auto _b_topo = mockturtle::topo_view(_b); - const auto _b_rank = mockturtle::rank_view(_b); - - fiction::node_duplication_planarization_params dps; - dps.random_output_order = false; - - const auto planarized_b = fiction::node_duplication_planarization(_b, dps); - - fiction::debug::write_dot_network(tec, "tec_test"); - fiction::debug::write_dot_network(_b, "t_b"); - fiction::debug::write_dot_network(planarized_b, "network_b");*/ - - static constexpr const uint64_t bench_select = (fiction_experiments::iscas85); // fiction_experiments::iscas85 & ~ - // fiction_experiments::trindade16 | fiction_experiments::fontes18 | fiction_experiments::epfl | - // fiction_experiments::iscas85 static constexpr const uint64_t bench_select = + static constexpr const std::uint64_t bench_select = (fiction_experiments::trindade16 | fiction_experiments::fontes18); for (const auto& benchmark : fiction_experiments::all_benchmarks(bench_select)) { const auto benchmark_network = read_ntk(benchmark); @@ -233,42 +156,18 @@ int main() // NOLINT fiction::network_balancing_params ps; ps.unify_outputs = true; - bool cont = false; - benchmark_network.foreach_pi( - [&benchmark_network, &cont](auto pi) - { - if (benchmark_network.is_po(pi)) - { - cont = true; - std::cout << "Pi is Po\n"; - } - }); - if (cont) - { - continue; - } - - const auto _b = fiction::network_balancing( + const auto b = fiction::network_balancing( fiction::fanout_substitution(benchmark_network), ps); - if (_b.size() > 10000) - { - /*wiring_reduction_exp(benchmark, benchmark_network.num_pis(), 0, benchmark_network.num_pos(), - benchmark_network.num_gates(), _b.num_gates(), _b.num_gates(), 0, 0, "TEST"); - wiring_reduction_exp.save(); - wiring_reduction_exp.table();*/ - continue; - } - - const auto planarized_b = fiction::node_duplication_planarization(_b); + const auto planarized_b = fiction::node_duplication_planarization(b); const auto is_planar = fiction::check_planarity(planarized_b); if (planarized_b.size() > 20000) { wiring_reduction_exp(benchmark, benchmark_network.num_pis(), planarized_b.num_virtual_pis(), - benchmark_network.num_pos(), benchmark_network.num_gates(), _b.num_gates(), - planarized_b.num_gates(), is_planar, 0, 0); + benchmark_network.num_pos(), benchmark_network.num_gates(), b.num_gates(), + planarized_b.num_gates(), is_planar, false, false); wiring_reduction_exp.save(); wiring_reduction_exp.table(); continue; @@ -280,62 +179,29 @@ int main() // NOLINT *fiction::virtual_miter(benchmark_network, planarized_b), {}, &st); assert(cec_m.has_value()); - auto name = mockturtle::names_view(planarized_b); - - fiction::restore_names(benchmark_network, name); - - using gate_lyt = fiction::gate_level_layout< - fiction::clocked_layout>>>; - fiction::orthogonal_physical_design_stats stats{}; using gate_layout = fiction::gate_level_layout< fiction::clocked_layout>>>; - auto start = std::chrono::high_resolution_clock::now(); auto layout = fiction::orthogonal(planarized_b, {}, &stats); - auto stop = std::chrono::high_resolution_clock::now(); - - std::chrono::duration elapsed = stop - start; - - std::cout << "Time elapsed: " << elapsed.count() << " s\n"; - - std::cout << "X size : " << stats.x_size << "\n"; - std::cout << "Y size : " << stats.y_size << "\n"; - - std::cout << "PO benchmark : " << benchmark_network.num_pos() << "\n"; - std::cout << "PO planarized : " << planarized_b.num_pos() << "\n"; - std::cout << "PO layout : " << layout.num_pos() << "\n"; fiction::gate_level_drv_params ps_d{}; fiction::gate_level_drv_stats st_d{}; fiction::gate_level_drvs(layout, ps_d, &st_d); - /*fiction::equivalence_checking_stats eq_s_ortho{}; - // check equivalence - const auto eq_stats_ortho = - fiction::equivalence_checking(planarized_b, layout, &eq_s_ortho); - std::cout << "eq_checking gone\n"; - const std::string eq_result_ortho = eq_stats_ortho == fiction::eq_type::STRONG ? "STRONG" : - eq_stats_ortho == fiction::eq_type::WEAK ? "WEAK" : - "NO";*/ - const auto miter = mockturtle::miter(planarized_b, layout); - bool eq; + bool eq = false; if (miter) { - mockturtle::equivalence_checking_stats st; + mockturtle::equivalence_checking_stats st_o; - const auto ce = mockturtle::equivalence_checking(*miter, {}, &st); + const auto ce = mockturtle::equivalence_checking(*miter, {}, &st_o); eq = ce.value(); } - // fiction::debug::write_dot_layout(layout); - /*fiction::debug::write_dot_network(_b, "ntk_b"); - fiction::debug::write_dot_network(planarized_b, "ntk_p");*/ - // log results wiring_reduction_exp(benchmark, benchmark_network.num_pis(), planarized_b.num_virtual_pis(), - benchmark_network.num_pos(), benchmark_network.num_gates(), _b.num_gates(), + benchmark_network.num_pos(), benchmark_network.num_gates(), b.num_gates(), planarized_b.num_gates(), is_planar, cec_m.value(), eq); wiring_reduction_exp.save(); diff --git a/include/fiction/algorithms/network_transformation/node_duplication_planarization.hpp b/include/fiction/algorithms/network_transformation/node_duplication_planarization.hpp index 513ac3150..1dc50ee07 100644 --- a/include/fiction/algorithms/network_transformation/node_duplication_planarization.hpp +++ b/include/fiction/algorithms/network_transformation/node_duplication_planarization.hpp @@ -5,18 +5,18 @@ #ifndef FICTION_NODE_DUPLICATION_PLANARIZATION_HPP #define FICTION_NODE_DUPLICATION_PLANARIZATION_HPP -#include "fiction/algorithms/properties/check_planarity_balanced.hpp" #include "fiction/networks/views/extended_rank_view.hpp" #include "fiction/networks/virtual_pi_network.hpp" #include +#include #include #include #include +#include #include #include -#include #include #include #include @@ -94,9 +94,9 @@ struct node_pair * @param node2 The second node of the fanin-edged node. * @param delayValue The delay value for the node. */ - node_pair(mockturtle::node node1, mockturtle::node node2, uint64_t delayValue) : + node_pair(mockturtle::node node1, mockturtle::node node2, uint64_t delay_value) : pair(node1, node2), - delay(delayValue), + delay(delay_value), fanin_pair(nullptr) {} }; diff --git a/libs/Catch2 b/libs/Catch2 index fa306fc85..bc63412e2 160000 --- a/libs/Catch2 +++ b/libs/Catch2 @@ -1 +1 @@ -Subproject commit fa306fc85eca7cc68a5362c503019fa823cbe411 +Subproject commit bc63412e2a3b3e39e178ea75953522f78b840aa7 diff --git a/libs/json b/libs/json index 960b763ec..b36f4c477 160000 --- a/libs/json +++ b/libs/json @@ -1 +1 @@ -Subproject commit 960b763ecd144f156d05ec61f577b04107290137 +Subproject commit b36f4c477c40356a0ae1204b567cca3c2a57d201 diff --git a/libs/mockturtle b/libs/mockturtle index 924c277bc..e55e2bbbe 160000 --- a/libs/mockturtle +++ b/libs/mockturtle @@ -1 +1 @@ -Subproject commit 924c277bc01900c9dc6d56fb6f2f4d100cab0806 +Subproject commit e55e2bbbef4648d311b97ae0907380190ebe8a29 diff --git a/libs/parallel-hashmap b/libs/parallel-hashmap index 8a889d369..63acc3336 160000 --- a/libs/parallel-hashmap +++ b/libs/parallel-hashmap @@ -1 +1 @@ -Subproject commit 8a889d3699b3c09ade435641fb034427f3fd12b6 +Subproject commit 63acc3336f941c6f324c88eb9ee4ce623a460cd5 diff --git a/libs/pybind11 b/libs/pybind11 index a1d00916b..ef5a9560b 160000 --- a/libs/pybind11 +++ b/libs/pybind11 @@ -1 +1 @@ -Subproject commit a1d00916b26b187e583f3bce39cd59c3b0652c32 +Subproject commit ef5a9560bb03efcac588888a825b7c7a0b8266cc diff --git a/libs/tinyxml2 b/libs/tinyxml2 index 8a519a556..374292e9b 160000 --- a/libs/tinyxml2 +++ b/libs/tinyxml2 @@ -1 +1 @@ -Subproject commit 8a519a556afecb3e717a4797615a8bfa49cae10a +Subproject commit 374292e9ba1549460f35d70411daba8b82bb2add