Skip to content

Commit b59daed

Browse files
committed
Added comments and add unit test to check macro routine that updates member PartitionRegions
1 parent be89488 commit b59daed

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

vpr/src/place/initial_placement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ void initial_placement(enum e_pad_loc_type pad_loc_type, const char* constraints
419419
vtr::vector<ClusterBlockId, t_block_score> block_scores = assign_block_scores();
420420
std::vector<ClusterBlockId> sorted_blocks = sort_blocks(block_scores);
421421

422-
//Perform constraints_propagation
423-
constraints_propagation();
422+
//Go through blocks with floorplan constraints to ensure we have the tightest constraint on each one.
423+
propagate_place_constraints();
424424

425425
// Loading legal placement locations
426426
zero_initialize_grid_blocks();

vpr/src/place/place_constraints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ PartitionRegion update_macro_member_pr(PartitionRegion& head_pr, const t_pl_offs
142142
return macro_pr;
143143
}
144144

145-
void constraints_propagation() {
145+
void propagate_place_constraints() {
146146
auto& place_ctx = g_vpr_ctx.placement();
147147
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
148148

vpr/src/place/place_constraints.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ bool is_macro_constrained(const t_pl_macro& pl_macro);
4040
PartitionRegion update_macro_head_pr(const t_pl_macro& pl_macro);
4141

4242
/*
43-
* Update macro member PR
43+
* Update the PartitionRegions of non-head members of a macro,
44+
* based on the constraint that was calculated for the head region.
45+
* The constraint that was calculated for the head region considered all
46+
* constrained blocks in the macro, so to calculate the constraint for the rest
47+
* of the blocks, it is just the head constraint with the offset of the member
48+
* applied.
4449
*/
4550
PartitionRegion update_macro_member_pr(PartitionRegion& head_pr, const t_pl_offset& offset);
4651

@@ -51,7 +56,7 @@ PartitionRegion update_macro_member_pr(PartitionRegion& head_pr, const t_pl_offs
5156
* This is done at the start of initial placement to ease floorplan legality checking
5257
* while placing macros during initial placement.
5358
*/
54-
void constraints_propagation();
59+
void propagate_place_constraints();
5560

5661
inline bool floorplan_legal(const t_pl_blocks_to_be_moved& blocks_affected) {
5762
bool floorplan_legal;

vpr/test/test_vpr_constraints.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "vpr_constraints.h"
77
#include "partition.h"
88
#include "region.h"
9+
#include "place_constraints.h"
910

1011
/**
1112
* This file contains unit tests that check the functionality of all classes related to vpr constraints. These classes include
@@ -425,6 +426,28 @@ TEST_CASE("RegionLocked", "[vpr]") {
425426
REQUIRE(is_r2_locked == false);
426427
}
427428

429+
//Test calculation of macro constraints
430+
TEST_CASE("MacroConstraints", "[vpr]") {
431+
PartitionRegion head_pr;
432+
t_pl_offset offset(2, 1, 0);
433+
434+
Region reg;
435+
reg.set_region_rect(5, 2, 9, 6);
436+
437+
head_pr.add_to_part_region(reg);
438+
439+
PartitionRegion macro_pr = update_macro_member_pr(head_pr, offset);
440+
441+
std::vector<Region> mac_regions = macro_pr.get_partition_region();
442+
443+
vtr::Rect<int> mac_rect = mac_regions[0].get_region_rect();
444+
445+
REQUIRE(mac_rect.xmin() == 7);
446+
REQUIRE(mac_rect.ymin() == 3);
447+
REQUIRE(mac_rect.xmax() == 11);
448+
REQUIRE(mac_rect.ymax() == 7);
449+
}
450+
428451
static constexpr const char kArchFile[] = "test_read_arch_metadata.xml";
429452

430453
// Test that place constraints are not changed during placement

0 commit comments

Comments
 (0)