Skip to content

Commit

Permalink
add ortools soln
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Nov 18, 2023
1 parent fb665a8 commit e64b995
Show file tree
Hide file tree
Showing 4 changed files with 390 additions and 245 deletions.
5 changes: 5 additions & 0 deletions include/aie/Dialect/AIE/Transforms/AIEPathFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ typedef struct SwitchSetting {
os << to_string(s);
return os;
}

inline bool operator<(const SwitchSetting &rhs) const {
return src < rhs.src;
}

} SwitchSetting;

typedef std::map<Switchbox, SwitchSetting> SwitchSettings;
Expand Down
11 changes: 9 additions & 2 deletions python/PybindTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ void xilinx::AIE::bindTypes(py::module_ &m) {

return ss.str();
})
.def("__contains__", [](const std::set<Port> &self,
const Port &p) { return self.count(p); })
.def("__repr__", [](py::object &set) { return py::str(set); });

py::enum_<WireBundle>(m, "WireBundle", py::arithmetic())
Expand All @@ -60,9 +62,10 @@ void xilinx::AIE::bindTypes(py::module_ &m) {
.def(py::init<Port &>())
.def(py::init<WireBundle, int>())
.def_readonly("bundle", &Port::bundle)
.def_readonly("channel", &Port::channel)
.def_readwrite("channel", &Port::channel)
.def(py::hash(py::self))
.def(py::self == py::self)
.def(py::self < py::self)
.def("__str__", [](const Port &port) { return to_string(port); })
.def("__repr__", [](const Port &port) { return to_string(port); });

Expand All @@ -73,6 +76,7 @@ void xilinx::AIE::bindTypes(py::module_ &m) {
// Implements __hash__ (magic?)
.def(py::hash(py::self))
.def(py::self == py::self)
.def(py::self < py::self)
.def("__str__", [](const TileID &tile) { return to_string(tile); })
.def("__repr__", [](const TileID &tile) { return to_string(tile); });

Expand All @@ -82,6 +86,7 @@ void xilinx::AIE::bindTypes(py::module_ &m) {
// Implements __hash__ (magic?)
.def(py::hash(py::self))
.def(py::self == py::self)
.def(py::self < py::self)
.def("__str__", [](const Switchbox &sb) { return to_string(sb); })
.def("__repr__", [](const Switchbox &sb) { return to_string(sb); });

Expand All @@ -90,6 +95,7 @@ void xilinx::AIE::bindTypes(py::module_ &m) {
.def(py::init<Port &>())
.def_readonly("src", &SwitchSetting::src)
.def_readwrite("dsts", &SwitchSetting::dsts)
.def(py::self < py::self)
.def("__str__", [](const SwitchSetting &sb) { return to_string(sb); })
.def("__repr__", [](const SwitchSetting &sb) { return to_string(sb); });

Expand All @@ -114,6 +120,7 @@ void xilinx::AIE::bindTypes(py::module_ &m) {
.def_readonly("port", &PathEndPoint::port)
.def(py::hash(py::self))
.def(py::self == py::self)
.def(py::self < py::self)
.def("__str__", [](const PathEndPoint &pe) { return to_string(pe); })
.def("__repr__", [](const PathEndPoint &pe) { return to_string(pe); });

Expand All @@ -131,4 +138,4 @@ void xilinx::AIE::bindTypes(py::module_ &m) {
.def("get_num_dest_switchbox_connections",
&AIETargetModel::getNumDestSwitchboxConnections,
py::return_value_policy::reference);
}
}
7 changes: 4 additions & 3 deletions python/PythonPathFinderPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ class PythonPathFinder : public Pathfinder {

std::map<PathEndPoint, SwitchSettings>
findPaths(const int maxIterations) override {
return findPathsPythonFunc(maxCol, maxRow, targetModel, flows,
fixedConnections)
.cast<std::map<PathEndPoint, SwitchSettings>>();
auto routingSolution = findPathsPythonFunc(maxCol, maxRow, targetModel,
flows, fixedConnections)
.cast<std::map<PathEndPoint, SwitchSettings>>();
return routingSolution;
}

const AIETargetModel *targetModel;
Expand Down
Loading

0 comments on commit e64b995

Please sign in to comment.