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

Add expandBoundingBox method to API #1395

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
7 changes: 7 additions & 0 deletions docs/archapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -765,3 +765,10 @@ 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

Updates bounding box to expand search space when routing is failing to find possible route.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a little bit more explanation here would be good?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Updated.

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