Skip to content

Commit

Permalink
Add expandBoundingBox method to API (#1395)
Browse files Browse the repository at this point in the history
* Add expandBoundingBox method to API

* Update API documentation
  • Loading branch information
mmicko authored Nov 26, 2024
1 parent 5503546 commit 0e69425
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 8 deletions.
3 changes: 3 additions & 0 deletions common/kernel/arch_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ template <typename R> struct ArchAPI : BaseCtx
virtual bool isClusterStrict(const CellInfo *cell) const = 0;
virtual bool getClusterPlacement(ClusterId cluster, BelId root_bel,
std::vector<std::pair<CellInfo *, BelId>> &placement) const = 0;
// Routing methods
virtual void expandBoundingBox(BoundingBox &bb) const = 0;

// Flow methods
virtual bool pack() = 0;
virtual bool place() = 0;
Expand Down
8 changes: 8 additions & 0 deletions common/kernel/base_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,14 @@ template <typename R> struct BaseArch : ArchAPI<R>
});
}

// Routing methods
virtual void expandBoundingBox(BoundingBox &bb) const override {
bb.x0 = std::max(bb.x0 - 1, 0);
bb.y0 = std::max(bb.y0 - 1, 0);
bb.x1 = std::min(bb.x1 + 1, this->getGridDimX());
bb.y1 = std::min(bb.y1 + 1, this->getGridDimY());
}

// Flow methods
virtual void assignArchInfo() override {};

Expand Down
9 changes: 1 addition & 8 deletions common/route/router2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1013,14 +1013,7 @@ struct Router2
++net_data.fail_count;
if ((net_data.fail_count % 3) == 0) {
// Every three times a net fails to route, expand the bounding box to increase the search space
#ifndef ARCH_MISTRAL
// This patch seems to make thing worse for CycloneV, as it slows down the resolution of TD congestion,
// disable it
net_data.bb.x0 = std::max(net_data.bb.x0 - 1, 0);
net_data.bb.y0 = std::max(net_data.bb.y0 - 1, 0);
net_data.bb.x1 = std::min(net_data.bb.x1 + 1, ctx->getGridDimX());
net_data.bb.y1 = std::min(net_data.bb.y1 + 1, ctx->getGridDimY());
#endif
ctx->expandBoundingBox(net_data.bb);
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions docs/archapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -765,3 +765,12 @@ Returns `true` if the cell **must** be placed according to the cluster; for exam
Gets an exact placement of the cluster, with the root cell placed on or near `root_bel` (and always within the same tile). Returns false if no placement is viable, otherwise returns `true` and populates `placement` with a list of cells inside the cluster and bels they should be placed at.

This approach of allowing architectures to define cluster placements enables easier handling of irregular fabrics than requiring strict and constant x, y and z offsets.

Router Methods
---------------

### void expandBoundingBox(BoundingBox &bb) const

As part of `router2` implementation, during congestion update, every third time a net fails to route, this method is executed to expand the bounding box to increase the search space.

Default implementation expands by one tile in each direction.
4 changes: 4 additions & 0 deletions himbaechel/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,10 @@ struct Arch : BaseArch<ArchRanges>
DecalXY getPipDecal(PipId pip) const override;
DecalXY getGroupDecal(GroupId group) const override;

// ------------------------------------------------
// Routing methods
void expandBoundingBox(BoundingBox &bb) const override { uarch->expandBoundingBox(bb); };

// ------------------------------------------------

bool pack() override;
Expand Down
5 changes: 5 additions & 0 deletions himbaechel/himbaechel_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ bool HimbaechelAPI::getClusterPlacement(ClusterId cluster, BelId root_bel,
return ctx->BaseArch::getClusterPlacement(cluster, root_bel, placement);
}

void HimbaechelAPI::expandBoundingBox(BoundingBox &bb) const
{
ctx->BaseArch::expandBoundingBox(bb);
}

HimbaechelArch *HimbaechelArch::list_head;
HimbaechelArch::HimbaechelArch(const std::string &name) : name(name)
{
Expand Down
2 changes: 2 additions & 0 deletions himbaechel/himbaechel_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ struct HimbaechelAPI
virtual void drawPip(std::vector<GraphicElement> &g,GraphicElement::style_t style, Loc loc,
WireId src, IdString src_type, int32_t src_id, WireId dst, IdString dst_type, int32_t dst_id) {};

// Routing methods
virtual void expandBoundingBox(BoundingBox &bb) const;
// --- Flow hooks ---
virtual void pack() {}; // replaces the pack function
// Called before and after main placement and routing
Expand Down
4 changes: 4 additions & 0 deletions mistral/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ struct Arch : BaseArch<ArchRanges>
BelBucketId getBelBucketForCellType(IdString cell_type) const override;
BelBucketId getBelBucketForBel(BelId bel) const override;

// -------------------------------------------------
// Expanding bounding box seems to make thing worse for CycloneV
// as it slows down the resolution of TD congestion, disabling it
void expandBoundingBox(BoundingBox &bb) const override {};
// -------------------------------------------------

void assignArchInfo() override;
Expand Down

0 comments on commit 0e69425

Please sign in to comment.