From 0e69425794da7eccdedbd13bfd37898474fa5e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miodrag=20Milanovi=C4=87?= Date: Tue, 26 Nov 2024 10:13:41 +0100 Subject: [PATCH] Add expandBoundingBox method to API (#1395) * Add expandBoundingBox method to API * Update API documentation --- common/kernel/arch_api.h | 3 +++ common/kernel/base_arch.h | 8 ++++++++ common/route/router2.cc | 9 +-------- docs/archapi.md | 9 +++++++++ himbaechel/arch.h | 4 ++++ himbaechel/himbaechel_api.cc | 5 +++++ himbaechel/himbaechel_api.h | 2 ++ mistral/arch.h | 4 ++++ 8 files changed, 36 insertions(+), 8 deletions(-) diff --git a/common/kernel/arch_api.h b/common/kernel/arch_api.h index 88582add..4eb6f4dd 100644 --- a/common/kernel/arch_api.h +++ b/common/kernel/arch_api.h @@ -147,6 +147,9 @@ template struct ArchAPI : BaseCtx virtual bool isClusterStrict(const CellInfo *cell) const = 0; virtual bool getClusterPlacement(ClusterId cluster, BelId root_bel, std::vector> &placement) const = 0; + // Routing methods + virtual void expandBoundingBox(BoundingBox &bb) const = 0; + // Flow methods virtual bool pack() = 0; virtual bool place() = 0; diff --git a/common/kernel/base_arch.h b/common/kernel/base_arch.h index 708636a0..2929bcba 100644 --- a/common/kernel/base_arch.h +++ b/common/kernel/base_arch.h @@ -442,6 +442,14 @@ template struct BaseArch : ArchAPI }); } + // 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 {}; diff --git a/common/route/router2.cc b/common/route/router2.cc index 5ae091ee..148c4051 100644 --- a/common/route/router2.cc +++ b/common/route/router2.cc @@ -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); } } } diff --git a/docs/archapi.md b/docs/archapi.md index 043f937b..9918a895 100644 --- a/docs/archapi.md +++ b/docs/archapi.md @@ -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. diff --git a/himbaechel/arch.h b/himbaechel/arch.h index c1076d5a..ca965c86 100644 --- a/himbaechel/arch.h +++ b/himbaechel/arch.h @@ -707,6 +707,10 @@ struct Arch : BaseArch 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; diff --git a/himbaechel/himbaechel_api.cc b/himbaechel/himbaechel_api.cc index 0efe5c6f..23b24769 100644 --- a/himbaechel/himbaechel_api.cc +++ b/himbaechel/himbaechel_api.cc @@ -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) { diff --git a/himbaechel/himbaechel_api.h b/himbaechel/himbaechel_api.h index f4329217..fa757401 100644 --- a/himbaechel/himbaechel_api.h +++ b/himbaechel/himbaechel_api.h @@ -114,6 +114,8 @@ struct HimbaechelAPI virtual void drawPip(std::vector &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 diff --git a/mistral/arch.h b/mistral/arch.h index f2de793d..10309bf0 100644 --- a/mistral/arch.h +++ b/mistral/arch.h @@ -450,6 +450,10 @@ struct Arch : BaseArch 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;