Skip to content

Commit

Permalink
restart python_passes.py tests
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Dec 5, 2023
1 parent 294ef2d commit e2e3b4f
Show file tree
Hide file tree
Showing 3 changed files with 430 additions and 436 deletions.
16 changes: 10 additions & 6 deletions lib/Dialect/AIE/IR/AIEDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ void AIEDialect::initialize() {

// Check that the operation only contains terminators in
// TerminatorOpTypes.
template <typename... TerminatorOpTypes> struct HasSomeTerminator {
template <typename... TerminatorOpTypes>
struct HasSomeTerminator {
static LogicalResult verifyTrait(Operation *op) {
for (auto &region : op->getRegions()) {
for (auto &block : region) {
Expand Down Expand Up @@ -835,7 +836,7 @@ LogicalResult TileOp::verify() {

auto users = getResult().getUsers();
bool found = false;
for (auto user : users) {
for (auto *user : users) {
if (llvm::isa<SwitchboxOp>(*user)) {
if (found)
return emitOpError("can only have one switchbox");
Expand Down Expand Up @@ -896,10 +897,12 @@ LogicalResult SwitchboxOp::verify() {
sourceset.insert(source);

Port dest = {connectOp.getDestBundle(), connectOp.destIndex()};
if (destset.count(dest))
if (destset.count(dest)) {
return connectOp.emitOpError("targets same destination ")
<< stringifyWireBundle(dest.bundle) << ": " << dest.channel
<< " as another connect operation";
<< to_string(dest) << " as another connect operation (from "
<< to_string(source)
<< ", tile: " << to_string(this->getTileOp().getTileID()) << ")";
}
destset.insert(dest);

if (connectOp.sourceIndex() < 0)
Expand Down Expand Up @@ -1386,7 +1389,8 @@ int SwitchboxOp::colIndex() { return getTileOp().colIndex(); }

int SwitchboxOp::rowIndex() { return getTileOp().rowIndex(); }

template <typename... ParentOpTypes> struct HasSomeParent {
template <typename... ParentOpTypes>
struct HasSomeParent {
static LogicalResult verifyTrait(Operation *op) {
Operation *operation = op->getParentOp();
while (operation) {
Expand Down
14 changes: 9 additions & 5 deletions python/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def route_using_cp(
min_edges=False,
seed=10,
num_workers=multiprocessing.cpu_count() // 2,
max_time_in_seconds=600,
timeout=600,
):
from ortools.sat.python import cp_model

Expand All @@ -202,7 +202,7 @@ def route_using_cp(
# For determinism
solver.parameters.random_seed = seed
solver.parameters.num_workers = num_workers
solver.parameters.max_time_in_seconds = max_time_in_seconds
solver.parameters.max_time_in_seconds = timeout

# Create variable for each edge, for each path
flow_vars = {}
Expand Down Expand Up @@ -287,7 +287,7 @@ def route_using_cp(

return flow_paths

warnings.warn("Couldn't route.")
raise RuntimeError("Couldn't route.")


def route_using_ilp(DG, flows):
Expand Down Expand Up @@ -467,6 +467,7 @@ def pythonize_bool(value):
class Router:
max_col: int
max_row: int
timeout: int
use_gurobi: bool = False
# Don't use actual binding here to prevent a blow up since class bodies are executed
# at module load time.
Expand All @@ -475,13 +476,14 @@ class Router:
fixed_connections: List[Tuple["TileID", "Port"]]
routing_solution: Dict["PathEndPoint", "SwitchSettings"]

def __init__(self, use_gurobi=False):
def __init__(self, use_gurobi=False, timeout=600):
self.flows = []
self.fixed_connections = []
self.routing_solution = None
self.use_gurobi = use_gurobi or pythonize_bool(
os.getenv("ROUTER_USE_GUROBI", "False")
)
self.timeout = timeout

def initialize(self, max_col, max_row, target_model):
self.max_col = max_col
Expand All @@ -500,7 +502,9 @@ def find_paths(self):
if self.use_gurobi:
flow_paths = route_using_ilp(DG, self.flows)
else:
flow_paths = route_using_cp(DG, self.flows, num_workers=10)
flow_paths = route_using_cp(
DG, self.flows, num_workers=10, timeout=self.timeout
)

self.routing_solution = get_routing_solution(DG, flow_paths)
return self.routing_solution
Expand Down
Loading

0 comments on commit e2e3b4f

Please sign in to comment.