Skip to content

Commit

Permalink
🔀 Resolve merge conflicts with main
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelwa committed Oct 9, 2023
1 parent 5f625d9 commit 3e701b1
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 78 deletions.
1 change: 1 addition & 0 deletions bindings/pyfiction/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pybind11_add_module(pyfiction pyfiction.cpp)
target_link_libraries(pyfiction PRIVATE libfiction)
target_include_directories(pyfiction PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
set_property(TARGET pyfiction PROPERTY POSITION_INDEPENDENT_CODE ON)
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ void hexagonalization(pybind11::module& m)

m.def(
"hexagonalization",
[](const Lyt& lyt) -> py_hexagonal_gate_layout { return fiction::hexagonalization<Lyt>(lyt); }, "layout"_a,
DOC(fiction_hexagonalization));
[](const Lyt& lyt) -> py_hexagonal_gate_layout
{ return fiction::hexagonalization<py_hexagonal_gate_layout, Lyt>(lyt); },
"layout"_a, DOC(fiction_hexagonalization));
}

} // namespace detail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ void post_layout_optimization(pybind11::module& m)
{
using namespace pybind11::literals;

m.def("post_layout_optimization", &fiction::post_layout_optimization<Lyt>, "lyt"_a, "pst"_a = nullptr,
DOC(fiction_post_layout_optimization));
}

} // namespace detail

inline void post_layout_optimization(pybind11::module& m)
{
pybind11::class_<fiction::post_layout_optimization_stats>(m, "post_layout_optimization_stats",
DOC(fiction_post_layout_optimization_stats))
.def(pybind11::init<>())
Expand All @@ -37,14 +45,6 @@ void post_layout_optimization(pybind11::module& m)

;

m.def("post_layout_optimization", &fiction::post_layout_optimization<Lyt>, "layout"_a, "statistics"_a = nullptr,
DOC(fiction_post_layout_optimization));
}

} // namespace detail

inline void post_layout_optimization(pybind11::module& m)
{
detail::post_layout_optimization<py_cartesian_gate_layout>(m);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ void calculate_energy_and_state_type(pybind11::module& m)
{
using namespace pybind11::literals;

m.def("calculate_energy_and_state_type", &fiction::calculate_energy_and_state_type<Lyt>, "energy_distribution"_a,
"valid_lyts"_a, "output_cells"_a, "output_bits"_a, DOC(fiction_calculate_energy_and_state_type));
m.def("calculate_energy_and_state_type", &fiction::calculate_energy_and_state_type<Lyt, py_tt>,
"energy_distribution"_a, "valid_charge_distributions"_a, "output_bdl_pairs"_a, "spec"_a, "input_index"_a,
DOC(fiction_calculate_energy_and_state_type));
}

} // namespace detail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void critical_temperature(pybind11::module& m)

;

m.def("critical_temperature", &fiction::critical_temperature<Lyt>, "layout"_a,
m.def("critical_temperature_gate_based", &fiction::critical_temperature_gate_based<Lyt, py_tt>, "lyt"_a, "spec"_a,
"params"_a = fiction::critical_temperature_params{}, "stats"_a = nullptr, DOC(fiction_critical_temperature));
}

Expand All @@ -58,26 +58,26 @@ inline void critical_temperature(pybind11::module& m)
/**
* Critical temperature mode.
*/
py::enum_<fiction::critical_temperature_params::critical_temperature_mode>(m, "critical_temperature_mode",
DOC(fiction_critical_temperature_mode))
py::enum_<fiction::critical_temperature_params::critical_temperature_mode>(
m, "critical_temperature_mode", DOC(fiction_critical_temperature_params_critical_temperature_mode))
.value("GATE_BASED_SIMULATION",
fiction::critical_temperature_params::critical_temperature_mode::GATE_BASED_SIMULATION,
DOC(fiction_critical_temperature_mode_GATE_BASED_SIMULATION))
DOC(fiction_critical_temperature_params_critical_temperature_mode_GATE_BASED_SIMULATION))
.value("NON_GATE_BASED_SIMULATION",
fiction::critical_temperature_params::critical_temperature_mode::NON_GATE_BASED_SIMULATION,
DOC(fiction_critical_temperature_mode_NON_GATE_BASED_SIMULATION))
DOC(fiction_critical_temperature_params_critical_temperature_mode_NON_GATE_BASED_SIMULATION))

;

/**
* Simulation engine.
*/
py::enum_<fiction::critical_temperature_params::simulation_engine>(m, "simulation_engine",
DOC(fiction_simulation_engine))
py::enum_<fiction::critical_temperature_params::simulation_engine>(
m, "simulation_engine", DOC(fiction_critical_temperature_params_simulation_engine))
.value("EXACT", fiction::critical_temperature_params::simulation_engine::EXACT,
DOC(fiction_simulation_engine_EXACT))
DOC(fiction_critical_temperature_params_simulation_engine_EXACT))
.value("APPROXIMATE", fiction::critical_temperature_params::simulation_engine::APPROXIMATE,
DOC(fiction_simulation_engine_APPROXIMATE))
DOC(fiction_critical_temperature_params_simulation_engine_APPROXIMATE))

;

Expand All @@ -87,20 +87,16 @@ inline void critical_temperature(pybind11::module& m)
py::class_<fiction::critical_temperature_params>(m, "critical_temperature_params",
DOC(fiction_critical_temperature_params))
.def(py::init<>())
.def_readwrite("engine", &fiction::critical_temperature_params::engine,
DOC(fiction_critical_temperature_params_engine))
.def_readwrite("temperature_mode", &fiction::critical_temperature_params::temperature_mode,
DOC(fiction_critical_temperature_params_temperature_mode))
.def_readwrite("simulation_params", &fiction::critical_temperature_params::simulation_params,
DOC(fiction_critical_temperature_params_simulation_params))
.def_readwrite("engine", &fiction::critical_temperature_params::engine,
DOC(fiction_critical_temperature_params_engine))
.def_readwrite("confidence_level", &fiction::critical_temperature_params::confidence_level,
DOC(fiction_critical_temperature_params_confidence_level))
.def_readwrite("max_temperature", &fiction::critical_temperature_params::max_temperature,
DOC(fiction_critical_temperature_params_max_temperature))
.def_readwrite("truth_table", &fiction::critical_temperature_params::truth_table,
DOC(fiction_critical_temperature_params_truth_table))
.def_readwrite("input_bit", &fiction::critical_temperature_params::input_bit,
DOC(fiction_critical_temperature_params_input_bit))
.def_readwrite("bdl_params", &fiction::critical_temperature_params::bdl_params,
DOC(fiction_critical_temperature_params_bdl_params))

;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,32 @@ inline void charge_distribution_surface(pybind11::module& m)
/**
* Dependent cell mode.
*/
py::enum_<fiction::dependent_cell_mode>(m, "dependent_cell_mode")
//, DOC(fiction_dependent_cell_mode))
.value("FIXED", fiction::dependent_cell_mode::FIXED)
//, DOC(fiction_dependent_cell_mode_FIXED))
.value("VARIABLE", fiction::dependent_cell_mode::VARIABLE)
//, DOC(fiction_dependent_cell_mode_VARIABLE))
py::enum_<fiction::dependent_cell_mode>(m, "dependent_cell_mode", DOC(fiction_dependent_cell_mode))
.value("FIXED", fiction::dependent_cell_mode::FIXED, DOC(fiction_dependent_cell_mode_FIXED))
.value("VARIABLE", fiction::dependent_cell_mode::VARIABLE, DOC(fiction_dependent_cell_mode_VARIABLE))

;

/**
* Energy calculation.
*/
py::enum_<fiction::energy_calculation>(m, "energy_calculation")
//, DOC(fiction_energy_calculation))
.value("KEEP_OLD_ENERGY_VALUE", fiction::energy_calculation::KEEP_OLD_ENERGY_VALUE)
//, DOC(fiction_energy_calculation_KEEP_OLD_ENERGY_VALUE))
.value("UPDATE_ENERGY", fiction::energy_calculation::UPDATE_ENERGY)
//, DOC(fiction_energy_calculation_UPDATE_ENERGY))
py::enum_<fiction::energy_calculation>(m, "energy_calculation", DOC(fiction_energy_calculation))
.value("KEEP_OLD_ENERGY_VALUE", fiction::energy_calculation::KEEP_OLD_ENERGY_VALUE,
DOC(fiction_energy_calculation_KEEP_OLD_ENERGY_VALUE))
.value("UPDATE_ENERGY", fiction::energy_calculation::UPDATE_ENERGY,
DOC(fiction_energy_calculation_UPDATE_ENERGY))

;

/**
* Charge distribution history.
*/
py::enum_<fiction::charge_distribution_history>(m, "charge_distribution_history")
//, DOC(fiction_charge_distribution_history))
.value("CONSIDER", fiction::charge_distribution_history::CONSIDER)
//, DOC(fiction_charge_distribution_history_CONSIDER))
.value("NEGLECT", fiction::charge_distribution_history::NEGLECT)
//, DOC(fiction_charge_distribution_history_NEGLECT))
py::enum_<fiction::charge_distribution_history>(m, "charge_distribution_history",
DOC(fiction_charge_distribution_history))
.value("CONSIDER", fiction::charge_distribution_history::CONSIDER,
DOC(fiction_charge_distribution_history_CONSIDER))
.value("NEGLECT", fiction::charge_distribution_history::NEGLECT,
DOC(fiction_charge_distribution_history_NEGLECT))

;

Expand Down Expand Up @@ -179,7 +175,7 @@ inline void charge_distribution_surface(pybind11::module& m)
.def("get_charge_state_by_index", &py_charge_distribution_surface::get_charge_state_by_index, "index"_a)
.def("get_all_sidb_charges", &py_charge_distribution_surface::get_all_sidb_charges)
.def("negative_sidb_detection", &py_charge_distribution_surface::negative_sidb_detection)
.def("get_nm_distance_between_cells", &py_charge_distribution_surface::get_nm_distance_between_cells, "c1"_a,
.def("get_nm_distance_between_sidbs", &py_charge_distribution_surface::get_nm_distance_between_sidbs, "c1"_a,
"c2"_a)
.def("get_nm_distance_by_indices", &py_charge_distribution_surface::get_nm_distance_by_indices, "index1"_a,
"index2"_a)
Expand All @@ -194,15 +190,8 @@ inline void charge_distribution_surface(pybind11::module& m)
"index1"_a, "index2"_a)
.def("get_potential_between_sidbs", &py_charge_distribution_surface::get_potential_between_sidbs, "c1"_a,
"c2"_a)
.def("get_electrostatic_potential_by_indices",
&py_charge_distribution_surface::get_electrostatic_potential_by_indices, "index1"_a, "index2"_a)
// .def("potential_between_sidbs_by_index",
// &py_charge_distribution_surface::potential_between_sidbs_by_index,
// "index1"_a, "index2"_a)
// .def("potential_between_sidbs", &py_charge_distribution_surface::potential_between_sidbs, "c1"_a,
// "c2"_a) .def("potential_between_sidbs_by_indices",
// &py_charge_distribution_surface::potential_between_sidbs_by_indices,
// "index1"_a, "index2"_a)
.def("get_potential_by_indices", &py_charge_distribution_surface::get_potential_by_indices, "index1"_a,
"index2"_a)
.def("update_local_potential", &py_charge_distribution_surface::update_local_potential)
.def("get_local_potential", &py_charge_distribution_surface::get_local_potential, "c"_a)
.def("get_local_potential_by_index", &py_charge_distribution_surface::get_local_potential_by_index, "index"_a)
Expand Down Expand Up @@ -232,25 +221,23 @@ inline void charge_distribution_surface(pybind11::module& m)
"potential_value"_a, "dependent_cell"_a = fiction::dependent_cell_mode::FIXED)
.def("is_three_state_simulation_required", &py_charge_distribution_surface::is_three_state_simulation_required)
.def("get_positive_candidates", &py_charge_distribution_surface::get_positive_candidates)
.def("positive_cell_to_index", &py_charge_distribution_surface::positive_cell_to_index, "c"_a)
.def("three_state_cell_to_index", &py_charge_distribution_surface::three_state_cell_to_index, "c"_a)
.def("two_state_cell_to_index", &py_charge_distribution_surface::two_state_cell_to_index, "c"_a)
.def("index_to_cell", &py_charge_distribution_surface::index_to_cell, "index"_a)
.def("index_to_three_state_cell", &py_charge_distribution_surface::index_to_three_state_cell, "index"_a)
.def("index_to_two_state_cell", &py_charge_distribution_surface::index_to_two_state_cell, "index"_a)

.def("chargeless_potential_at_given_distance",
&py_charge_distribution_surface::chargeless_potential_at_given_distance, "distance"_a)

.def("chargeless_potential_generated_by_defect_at_given_distance",
&py_charge_distribution_surface::chargeless_potential_generated_by_defect_at_given_distance, "distance"_a,
"defect"_a = fiction::sidb_defect{})

.def("assign_local_external_potential", &py_charge_distribution_surface::assign_local_external_potential,
"external_potential"_a)
.def("get_external_potentials", &py_charge_distribution_surface::get_external_potentials)
.def("get_defect_potentials", &py_charge_distribution_surface::get_defect_potentials)

.def("get_local_external_potentials", &py_charge_distribution_surface::get_local_external_potentials)
.def("get_local_defect_potentials", &py_charge_distribution_surface::get_local_defect_potentials)
.def("get_defects", &py_charge_distribution_surface::get_defects)

.def("update_charge_state_of_dependent_cell",
&py_charge_distribution_surface::update_charge_state_of_dependent_cell)
.def("get_charge_index_of_sub_layout", &py_charge_distribution_surface::get_charge_index_of_sub_layout)
Expand Down
2 changes: 0 additions & 2 deletions bindings/pyfiction/pyfiction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ PYBIND11_MODULE(pyfiction, m)
*/
pyfiction::exact(m);
pyfiction::orthogonal(m);
pyfiction::post_layout_optimization(m);
pyfiction::hexagonalization(m);
pyfiction::apply_gate_library(m);
pyfiction::color_routing(m);
pyfiction::hexagonalization(m);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@

class TestPostLayoutOptimiztaion(unittest.TestCase):

def test_post_layout_optimization_without_stats(self):
network = read_logic_network(dir_path + "/../../resources/mux21.v")

layout = orthogonal(network)

self.assertEqual(equivalence_checking(network, layout), eq_type.STRONG)

post_layout_optimization(layout)

self.assertEqual(equivalence_checking(network, layout), eq_type.STRONG)

def test_post_layout_optimization_with_stats(self):
network = read_logic_network(dir_path + "/../../resources/mux21.v")

Expand All @@ -15,9 +26,10 @@ def test_post_layout_optimization_with_stats(self):
self.assertEqual(equivalence_checking(network, layout), eq_type.STRONG)

stats = post_layout_optimization_stats()
post_layout_optimization(layout, statistics=stats)
post_layout_optimization(layout, stats)

self.assertEqual(equivalence_checking(network, layout), eq_type.STRONG)
self.assertGreater(stats.time_total.total_seconds(), 0)


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ def test_calculate_energy_and_state_type(self):
charge_lyt_two.assign_charge_state((5, 2), sidb_charge_state.NEGATIVE)
charge_lyt_two.update_after_charge_change()

energy_distribution = {0.45752725052: 1, 0.12311716: 0}
energy_distr = {0.45752725052: 1, 0.12311716: 0}
valid_lyts = [charge_distribution_surface(), charge_distribution_surface()]
valid_lyts = [charge_lyt_one, charge_lyt_two]
output_cells = [(1, 1, 0)]
output_bits = [False]

# TODO Tests has to be added


if __name__ == '__main__':
unittest.main()
22 changes: 16 additions & 6 deletions include/fiction/algorithms/physical_design/exact.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3150,7 +3150,9 @@ std::optional<Lyt> exact(const Ntk& ntk, const exact_physical_design_params& ps
"Ntk is not a network type"); // Ntk is being converted to a topology_network anyway, therefore,
// this is the only relevant check here

if (const auto clocking_scheme = get_clocking_scheme<Lyt>(ps.scheme); !clocking_scheme.has_value())
const auto clocking_scheme = get_clocking_scheme<Lyt>(ps.scheme);

if (!clocking_scheme.has_value())
{
throw unsupported_clocking_scheme_exception();
}
Expand Down Expand Up @@ -3179,10 +3181,11 @@ std::optional<Lyt> exact(const Ntk& ntk, const exact_physical_design_params& ps

mockturtle::names_view<technology_network> intermediate_ntk{
fanout_substitution<mockturtle::names_view<technology_network>>(
ntk, {fanout_substitution_params::substitution_strategy::BREADTH, ps.scheme->max_out_degree, 1ul})};
ntk, {fanout_substitution_params::substitution_strategy::BREADTH, clocking_scheme->max_out_degree, 1ul})};

exact_physical_design_stats st{};
detail::exact_impl<Lyt> p{intermediate_ntk, ps, st};

detail::exact_impl<Lyt> p{intermediate_ntk, ps, st};

auto result = p.run();

Expand Down Expand Up @@ -3219,7 +3222,9 @@ std::optional<Lyt> exact_with_blacklist(const Ntk& ntk, const surface_black_list
"Ntk is not a network type"); // Ntk is being converted to a topology_network anyway, therefore,
// this is the only relevant check here

if (const auto clocking_scheme = get_clocking_scheme<Lyt>(ps.scheme); !clocking_scheme.has_value())
const auto clocking_scheme = get_clocking_scheme<Lyt>(ps.scheme);

if (!clocking_scheme.has_value())
{
throw unsupported_clocking_scheme_exception();
}
Expand All @@ -3246,8 +3251,13 @@ std::optional<Lyt> exact_with_blacklist(const Ntk& ntk, const surface_black_list
}
}

exact_physical_design_stats st{};
detail::exact_impl<Lyt, Ntk> p{ntk, ps, st, black_list};
mockturtle::names_view<technology_network> intermediate_ntk{
fanout_substitution<mockturtle::names_view<technology_network>>(
ntk, {fanout_substitution_params::substitution_strategy::BREADTH, clocking_scheme->max_out_degree, 1ul})};

exact_physical_design_stats st{};

detail::exact_impl<Lyt> p{intermediate_ntk, ps, st, black_list};

auto result = p.run();

Expand Down
2 changes: 1 addition & 1 deletion include/fiction/algorithms/simulation/sidb/quicksim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sidb_simulation_result<Lyt> quicksim(const Lyt& lyt, const quicksim_params& ps =
static_assert(is_cell_level_layout_v<Lyt>, "Lyt is not a cell-level layout");
static_assert(has_sidb_technology_v<Lyt>, "Lyt must be an SiDB layout");

if (ps.interation_steps == 0)
if (ps.iteration_steps == 0)
{
return sidb_simulation_result<Lyt>{};
}
Expand Down
6 changes: 2 additions & 4 deletions include/fiction/technology/charge_distribution_surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,8 @@ class charge_distribution_surface<Lyt, false> : public Lyt
* @param external_potential Externally applied local electrostatic potential.
*/
explicit charge_distribution_surface(
const Lyt& lyt,
const sidb_simulation_parameters& params = sidb_simulation_parameters{},
const sidb_charge_state cs = sidb_charge_state::NEGATIVE,
const typename Lyt::cell& variable_cells = {},
const Lyt& lyt, const sidb_simulation_parameters& params = sidb_simulation_parameters{},
const sidb_charge_state cs = sidb_charge_state::NEGATIVE, const typename Lyt::cell& variable_cells = {},
const std::unordered_map<typename Lyt::cell, double>& external_potential = {}) :
Lyt(lyt),
strg{std::make_shared<charge_distribution_storage>(params, external_potential, variable_cells)}
Expand Down

0 comments on commit 3e701b1

Please sign in to comment.