Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨 Fixed compiler and linter warnings #559

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "pyfiction/types.hpp"

#include <fiction/algorithms/iter/bdl_input_iterator.hpp>
#include <fiction/algorithms/simulation/sidb/detect_bdl_pairs.hpp>

#include <fmt/format.h>
#include <pybind11/pybind11.h>
Expand All @@ -36,7 +35,7 @@ void bdl_input_iterator(pybind11::module& m, const std::string& lattice)
"params"_a = fiction::bdl_input_iterator_params{}, DOC(fiction_bdl_input_iterator_bdl_input_iterator))
.def(
"__next__",
[](fiction::bdl_input_iterator<Lyt>& self) -> Lyt&
[](fiction::bdl_input_iterator<Lyt>& self) -> Lyt
{
if (self >= ((1ull << self.num_input_pairs()) - 1))
{
Expand All @@ -49,48 +48,48 @@ void bdl_input_iterator(pybind11::module& m, const std::string& lattice)
},
DOC(fiction_bdl_input_iterator_operator_mul))
.def(
"__eq__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t m) -> bool { return self == m; },
"__eq__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t n) -> bool { return self == n; },
"m"_a, DOC(fiction_bdl_input_iterator_operator_eq))
.def(
"__ne__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t m) -> bool { return self != m; },
"__ne__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t n) -> bool { return self != n; },
"m"_a, DOC(fiction_bdl_input_iterator_operator_ne))
.def(
"__lt__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t m) -> bool { return self < m; },
"__lt__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t n) -> bool { return self < n; },
"m"_a, DOC(fiction_bdl_input_iterator_operator_lt))
.def(
"__le__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t m) -> bool { return self <= m; },
"__le__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t n) -> bool { return self <= n; },
"m"_a, DOC(fiction_bdl_input_iterator_operator_le))
.def(
"__gt__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t m) -> bool { return self > m; },
"__gt__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t n) -> bool { return self > n; },
"m"_a, DOC(fiction_bdl_input_iterator_operator_gt))
.def(
"__ge__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t m) -> bool { return self >= m; },
"__ge__", [](const fiction::bdl_input_iterator<Lyt>& self, const uint64_t n) -> bool { return self >= n; },
"m"_a, DOC(fiction_bdl_input_iterator_operator_ge))
.def(
"__add__", [](const fiction::bdl_input_iterator<Lyt>& self, const int m) -> fiction::bdl_input_iterator<Lyt>
{ return self + m; }, "m"_a, DOC(fiction_bdl_input_iterator_operator_add))
"__add__", [](const fiction::bdl_input_iterator<Lyt>& self, const int n) -> fiction::bdl_input_iterator<Lyt>
{ return self + n; }, "m"_a, DOC(fiction_bdl_input_iterator_operator_add))
.def(
"__iadd__",
[](fiction::bdl_input_iterator<Lyt>& self, const int m) -> fiction::bdl_input_iterator<Lyt>&
[](fiction::bdl_input_iterator<Lyt>& self, const int n) -> fiction::bdl_input_iterator<Lyt>&
{
self += m;
self += n;
return self;
},
"m"_a, DOC(fiction_bdl_input_iterator_operator_iadd))
.def(
"__sub__", [](const fiction::bdl_input_iterator<Lyt>& self, const int m) { return self - m; }, "m"_a,
"__sub__", [](const fiction::bdl_input_iterator<Lyt>& self, const int n) { return self - n; }, "m"_a,
DOC(fiction_bdl_input_iterator_operator_sub))
.def(
"__isub__",
[](fiction::bdl_input_iterator<Lyt>& self, const int m) -> fiction::bdl_input_iterator<Lyt>&
[](fiction::bdl_input_iterator<Lyt>& self, const int n) -> fiction::bdl_input_iterator<Lyt>&
{
self -= m;
self -= n;
return self;
},
"m"_a, DOC(fiction_bdl_input_iterator_operator_isub))
.def(
"__getitem__", [](const fiction::bdl_input_iterator<Lyt>& self, int m) -> fiction::bdl_input_iterator<Lyt>
{ return self[m]; }, "m"_a, DOC(fiction_bdl_input_iterator_operator_array))
"__getitem__", [](const fiction::bdl_input_iterator<Lyt>& self, int n) -> fiction::bdl_input_iterator<Lyt>
{ return self[n]; }, "m"_a, DOC(fiction_bdl_input_iterator_operator_array))

.def("num_input_pairs", &fiction::bdl_input_iterator<Lyt>::num_input_pairs)
.def("get_layout", [](const fiction::bdl_input_iterator<Lyt>& self) -> const Lyt& { return *self; })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,23 @@ void logic_simulation(pybind11::module& m, const std::string& type_name)
std::vector<std::string> po_names;
po_names.reserve(ntk_or_lyt.num_pos());

const auto store_po_names = [&po_names](const NtkOrLyt& ntk_or_lyt)
const auto store_po_names = [&po_names](const NtkOrLyt& network_or_layout)
{
ntk_or_lyt.foreach_po(
[&ntk_or_lyt, &po_names]([[maybe_unused]] const auto& po, auto i)
network_or_layout.foreach_po(
[&network_or_layout, &po_names]([[maybe_unused]] const auto& po, auto i)
{
po_names.emplace_back(ntk_or_lyt.has_output_name(i) ? ntk_or_lyt.get_output_name(i) :
fmt::format("po{}", i));
po_names.emplace_back(network_or_layout.has_output_name(i) ?
network_or_layout.get_output_name(i) :
fmt::format("po{}", i));
});
};

const auto simulate = [&tables](const NtkOrLyt& ntk_or_lyt)
const auto simulate = [&tables](const NtkOrLyt& network_or_layout)
{
tables = mockturtle::simulate<py_tt>(
ntk_or_lyt,
network_or_layout,
// NOLINTNEXTLINE
mockturtle::default_simulator<py_tt>{static_cast<unsigned>(ntk_or_lyt.num_pis())});
mockturtle::default_simulator<py_tt>{static_cast<unsigned>(network_or_layout.num_pis())});
};

store_po_names(ntk_or_lyt);
Expand Down
11 changes: 10 additions & 1 deletion bindings/pyfiction/include/pyfiction/layouts/coordinates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
#include <pybind11/pybind11.h>

#include <cstdint>
#include <exception>
#include <stdexcept>

marcelwa marked this conversation as resolved.
Show resolved Hide resolved
// data types cannot properly be converted to bit field types
#pragma GCC diagnostic push
#ifndef __clang__
#pragma GCC diagnostic ignored "-Wuseless-cast"
#endif
#pragma GCC diagnostic ignored "-Wconversion"

namespace pyfiction
{
Expand Down Expand Up @@ -222,4 +229,6 @@ inline void coordinate_utility(pybind11::module& m)

} // namespace pyfiction

#pragma GCC diagnostic pop

#endif // PYFICTION_COORDINATES_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ void gate_level_layout(pybind11::module& m, const std::string& topology)

.def(
"fanin_size", [](const GateLyt& layout, const uint64_t node)
{ return layout.template fanin_size<true>(node); }, "n"_a, DOC(fiction_gate_level_layout_fanin_size))
{ return layout.template fanin_size<true>(static_cast<typename GateLyt::node>(node)); }, "n"_a,
DOC(fiction_gate_level_layout_fanin_size))

.def(
"fanout_size", [](const GateLyt& layout, const uint64_t node)
{ return layout.template fanout_size<true>(node); }, "n"_a, DOC(fiction_gate_level_layout_fanout_size))
{ return layout.template fanout_size<true>(static_cast<typename GateLyt::node>(node)); }, "n"_a,
DOC(fiction_gate_level_layout_fanout_size))

.def(
"get_node", [](const GateLyt& layout, const py_offset_coordinate& coordinate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ state, which assigns binary `0` to all input BDL pairs.
Parameter ``lyt``:
The SiDB BDL layout to iterate over.

Parameter ``params``:
Parameter ``ps``:
Parameters for the BDL input iterator.)doc";

static const char *__doc_fiction_bdl_input_iterator_bdl_input_iterator_2 =
Expand All @@ -556,7 +556,7 @@ all input BDL pairs.
Parameter ``lyt``:
The SiDB BDL layout to iterate over.

Parameter ``params``:
Parameter ``ps``:
Parameters for the BDL input iterator.

Parameter ``input_wires``:
Expand Down Expand Up @@ -4133,8 +4133,8 @@ based on their corresponding positions and types. Optionally, it
performs post-layout optimization and sets the layout name if certain
conditions are met.

Template parameter ``Type``:
of the Parameters used for the SiDB on-the-fly gate library.
Template parameter ``Params``:
Type of the Parameters used for the SiDB on-the-fly gate library.

Parameter ``params``:
Parameters used for the SiDB on-the-fly gate library.
Expand Down Expand Up @@ -4944,7 +4944,7 @@ Parameter ``inter_bdl_distance``:
A `std::optional` containing the first BDL pair that meets the
criteria, or `std::nullopt` if no such pair is found.)doc";

static const char *__doc_fiction_detail_detect_bdl_wires_impl_lyt = R"doc(SiDB cell-level layout.)doc";
static const char *__doc_fiction_detail_detect_bdl_wires_impl_layout = R"doc(SiDB cell-level layout.)doc";

static const char *__doc_fiction_detail_detect_bdl_wires_impl_params = R"doc(Parameters for detecting BDL wires.)doc";

Expand Down Expand Up @@ -9133,7 +9133,7 @@ Template parameter ``Lyt``:
Template parameter ``TT``:
Truth table type.

Parameter ``truth_table_spec``:
Parameter ``spec``:
Vector of truth table specifications.

Parameter ``params``:
Expand Down Expand Up @@ -14025,9 +14025,9 @@ Parameter ``c``:

static const char *__doc_fiction_num_clks = R"doc()doc";

static const char *__doc_fiction_num_clks_FOUR = R"doc()doc";
static const char *__doc_fiction_num_clks_FOUR = R"doc(Four clocks.)doc";

static const char *__doc_fiction_num_clks_THREE = R"doc()doc";
static const char *__doc_fiction_num_clks_THREE = R"doc(Three clocks.)doc";

static const char *__doc_fiction_num_constant_fanins =
R"doc(Computes the number of constant fanin nodes of some network node `n`.
Expand Down
45 changes: 23 additions & 22 deletions include/fiction/algorithms/graph/graph_coloring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <numeric>
#include <optional>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -296,19 +297,19 @@ class sat_coloring_handler
std::iota(potential_chromatic_numbers.begin(), potential_chromatic_numbers.end(), h / 2);

// binary search for the chromatic number, i.e., the lower bound of potential ones
std::lower_bound(potential_chromatic_numbers.cbegin(), potential_chromatic_numbers.cend(), h,
[this, &most_recent_sat_instance](const auto& k1, [[maybe_unused]] const auto& k2)
{
if (const auto [sat, instance] = check_k_coloring(k1);
sat == bill::result::states::satisfiable)
{
most_recent_sat_instance = {k1, instance};
std::ignore = std::lower_bound(
potential_chromatic_numbers.cbegin(), potential_chromatic_numbers.cend(), h,
[this, &most_recent_sat_instance](const auto& k1, [[maybe_unused]] const auto& k2)
{
if (const auto [sat, instance] = check_k_coloring(k1); sat == bill::result::states::satisfiable)
{
most_recent_sat_instance = {k1, instance};

return false;
}
return false;
}

return true;
});
return true;
});

return most_recent_sat_instance;
}
Expand Down Expand Up @@ -532,7 +533,7 @@ class sat_coloring_handler
}
else // without clique information, at least the first vertex can be painted
{
std::find_if(
std::ignore = std::find_if(
graph.begin_vertices(), graph.end_vertices(),
[this, &instance, &clique_first_ordering](const auto& vp)
{
Expand All @@ -543,18 +544,18 @@ class sat_coloring_handler
// create a clique first vertex ordering
clique_first_ordering.push_back(v);

std::find_if(graph.begin_adjacent(v), graph.end_adjacent(v),
[&instance, &clique_first_ordering](const auto& av)
{
// assign color 1 to an adjacent vertex
instance->solver.add_clause(
bill::lit_type{instance->variables[{av, 1}], bill::positive_polarity});
std::ignore = std::find_if(graph.begin_adjacent(v), graph.end_adjacent(v),
[&instance, &clique_first_ordering](const auto& av)
{
// assign color 1 to an adjacent vertex
instance->solver.add_clause(bill::lit_type{
instance->variables[{av, 1}], bill::positive_polarity});

// create a clique first vertex ordering
clique_first_ordering.push_back(av);
// create a clique first vertex ordering
clique_first_ordering.push_back(av);

return true; // abort loop after first iteration
});
return true; // abort loop after first iteration
});

return true; // abort loop after first iteration
});
Expand Down
18 changes: 9 additions & 9 deletions include/fiction/algorithms/iter/bdl_input_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ class bdl_input_iterator
* BDL pairs.
*
* @param lyt The SiDB BDL layout to iterate over.
* @param params Parameters for the BDL input iterator.
* @param ps Parameters for the BDL input iterator.
*/
explicit bdl_input_iterator(const Lyt& lyt,
const bdl_input_iterator_params& params = bdl_input_iterator_params{}) noexcept :
const bdl_input_iterator_params& ps = bdl_input_iterator_params{}) noexcept :
layout{lyt.clone()},
input_pairs{
detect_bdl_pairs<Lyt>(lyt, sidb_technology::cell_type::INPUT, params.bdl_wire_params.bdl_pairs_params)},
detect_bdl_pairs<Lyt>(lyt, sidb_technology::cell_type::INPUT, ps.bdl_wire_params.bdl_pairs_params)},
num_inputs{static_cast<uint8_t>(input_pairs.size())},
input_bdl_wires{detect_bdl_wires<Lyt>(lyt, params.bdl_wire_params, bdl_wire_selection::INPUT)},
input_bdl_wires{detect_bdl_wires<Lyt>(lyt, ps.bdl_wire_params, bdl_wire_selection::INPUT)},
last_bdl_for_each_wire{determine_last_bdl_for_each_wire()},
params{params}
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 is not an SiDB layout");
Expand All @@ -98,18 +98,18 @@ class bdl_input_iterator
* which assigns binary `0` to all input BDL pairs.
*
* @param lyt The SiDB BDL layout to iterate over.
* @param params Parameters for the BDL input iterator.
* @param ps Parameters for the BDL input iterator.
* @param input_wires Pre-detected input BDL wires.
*/
explicit bdl_input_iterator(const Lyt& lyt, const bdl_input_iterator_params& params,
explicit bdl_input_iterator(const Lyt& lyt, const bdl_input_iterator_params& ps,
const std::vector<bdl_wire<Lyt>>& input_wires) noexcept :
layout{lyt.clone()},
input_pairs{
detect_bdl_pairs<Lyt>(lyt, sidb_technology::cell_type::INPUT, params.bdl_wire_params.bdl_pairs_params)},
detect_bdl_pairs<Lyt>(lyt, sidb_technology::cell_type::INPUT, ps.bdl_wire_params.bdl_pairs_params)},
num_inputs{static_cast<uint8_t>(input_pairs.size())},
input_bdl_wires{input_wires},
last_bdl_for_each_wire{determine_last_bdl_for_each_wire()},
params{params}
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 is not an SiDB layout");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
#ifndef FICTION_APPLY_GATE_LIBRARY_HPP
#define FICTION_APPLY_GATE_LIBRARY_HPP

#include "fiction/technology/fcn_gate_library.hpp"
#include "fiction/technology/inml_topolinano_library.hpp"
#include "fiction/technology/qca_one_library.hpp"
#include "fiction/technology/sidb_bestagon_library.hpp"
#include "fiction/technology/sidb_on_the_fly_gate_library.hpp"
#include "fiction/traits.hpp"
#include "fiction/utils/layout_utils.hpp"
#include "fiction/utils/name_utils.hpp"

#include <cstdint>

#if (PROGRESS_BARS)
#include <mockturtle/utils/progress_bar.hpp>

#include <cstdint>
#endif
#include <mockturtle/traits.hpp>

Expand All @@ -29,6 +25,7 @@
#pragma GCC diagnostic ignored "-Wuseless-cast"
#endif
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"

namespace fiction
{
Expand Down Expand Up @@ -121,7 +118,7 @@ class apply_gate_library_impl
* gate-level layout and maps gates to cell implementations based on their corresponding positions and types.
* Optionally, it performs post-layout optimization and sets the layout name if certain conditions are met.
*
* @tparam Type of the Parameters used for the SiDB on-the-fly gate library.
* @tparam Params Type of the Parameters used for the SiDB on-the-fly gate library.
* @param params Parameters used for the SiDB on-the-fly gate library.
* @return A `CellLyt` object representing the generated cell layout.
*/
Expand Down
Loading