Skip to content

Commit eeecb5b

Browse files
committed
equivalent: avoid using logical_block_type() func
Also solved draw.cpp issue Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 0062735 commit eeecb5b

File tree

9 files changed

+56
-32
lines changed

9 files changed

+56
-32
lines changed

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ static void SetupPinLocationsAndPinClasses(pugi::xml_node Locations,
642642
if (port.equivalent != PortEquivalence::NONE) {
643643
PhysicalTileType->class_inf[num_class].num_pins = port.num_pins;
644644
PhysicalTileType->class_inf[num_class].pinlist = (int*)vtr::malloc(sizeof(int) * port.num_pins);
645-
PhysicalTileType->class_inf[num_class].equivalence = PhysicalTileType->ports[i].equivalent;
645+
PhysicalTileType->class_inf[num_class].equivalence = port.equivalent;
646646
}
647647

648648
for (k = 0; k < port.num_pins; ++k) {

vpr/src/base/vpr_api.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,14 @@ void vpr_create_device_grid(const t_vpr_setup& vpr_setup, const t_arch& Arch) {
438438
continue;
439439
}
440440

441-
float util = 0.;
442441
if (device_ctx.grid.num_instances(&type) != 0) {
443-
util = float(num_type_instances[logical_block_type(&type)]) / device_ctx.grid.num_instances(&type);
442+
float util = 0.;
443+
VTR_LOG("\tPhysical Tile %s:\n", type.name);
444+
for (auto logical_block : type.equivalent_sites) {
445+
util = float(num_type_instances[logical_block]) / device_ctx.grid.num_instances(&type);
446+
VTR_LOG("\tBlock Utilization: %.2f Logical Block: %s\n", util, logical_block->name);
447+
}
444448
}
445-
VTR_LOG("\tBlock Utilization: %.2f Type: %s\n", util, type.name);
446449
}
447450
VTR_LOG("\n");
448451

vpr/src/draw/draw.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,9 +2730,13 @@ void deselect_all() {
27302730
}
27312731

27322732
static void draw_reset_blk_color(ClusterBlockId blk_id) {
2733+
auto& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
2734+
2735+
auto logical_block = clb_nlist.block_type(blk_id);
2736+
27332737
t_draw_state* draw_state = get_draw_state_vars();
27342738

2735-
draw_state->block_color[blk_id] = get_block_type_color(physical_tile_type(blk_id));
2739+
draw_state->block_color[blk_id] = get_block_type_color(pick_random_physical_type(logical_block));
27362740
}
27372741

27382742
/**
@@ -3690,7 +3694,7 @@ static void highlight_blocks(double x, double y) {
36903694
}
36913695
}
36923696

3693-
if (clb_index == EMPTY_BLOCK_ID) {
3697+
if (clb_index == EMPTY_BLOCK_ID || clb_index == ClusterBlockId::INVALID()) {
36943698
//Nothing found
36953699
return;
36963700
}

vpr/src/draw/draw_types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ezgl::rectangle t_draw_coords::get_absolute_clb_bbox(const ClusterBlockId clb_in
9595

9696
ezgl::rectangle t_draw_coords::get_absolute_clb_bbox(int grid_x, int grid_y, int sub_block_index) {
9797
auto& device_ctx = g_vpr_ctx.device();
98-
return get_pb_bbox(grid_x, grid_y, sub_block_index, *logical_block_type(device_ctx.grid[grid_x][grid_y].type)->pb_graph_head);
98+
return get_pb_bbox(grid_x, grid_y, sub_block_index, *pick_random_logical_type(device_ctx.grid[grid_x][grid_y].type)->pb_graph_head);
9999
}
100100

101101
#endif // NO_GRAPHICS

vpr/src/draw/intra_logic_block.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ void draw_internal_init_blk() {
9292
auto& device_ctx = g_vpr_ctx.device();
9393
for (const auto& type : device_ctx.physical_tile_types) {
9494
/* Empty block has no sub_blocks */
95-
if (&type == device_ctx.EMPTY_PHYSICAL_TILE_TYPE)
95+
if (is_empty_type(&type)) {
9696
continue;
97+
}
9798

98-
pb_graph_head_node = logical_block_type(&type)->pb_graph_head;
99+
auto logical_block = pick_random_logical_type(&type);
100+
pb_graph_head_node = logical_block->pb_graph_head;
99101
int type_descriptor_index = type.index;
100102

101103
int num_sub_tiles = type.capacity;
@@ -129,7 +131,7 @@ void draw_internal_init_blk() {
129131
clb_bbox.width(), clb_bbox.height());
130132

131133
/* Determine the max number of sub_block levels in the FPGA */
132-
draw_state->max_sub_blk_lvl = std::max(draw_internal_find_max_lvl(*logical_block_type(&type)->pb_type),
134+
draw_state->max_sub_blk_lvl = std::max(draw_internal_find_max_lvl(*logical_block->pb_type),
133135
draw_state->max_sub_blk_lvl);
134136
}
135137
}

vpr/src/power/power.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,26 +601,34 @@ static void power_usage_blocks(t_power_usage* power_usage) {
601601

602602
power_reset_tile_usage();
603603

604+
t_logical_block_type_ptr logical_block;
605+
604606
/* Loop through all grid locations */
605607
for (size_t x = 0; x < device_ctx.grid.width(); x++) {
606608
for (size_t y = 0; y < device_ctx.grid.height(); y++) {
609+
auto physical_tile = device_ctx.grid[x][y].type;
610+
607611
if ((device_ctx.grid[x][y].width_offset != 0)
608612
|| (device_ctx.grid[x][y].height_offset != 0)
609-
|| (device_ctx.grid[x][y].type == device_ctx.EMPTY_PHYSICAL_TILE_TYPE)) {
613+
|| is_empty_type(physical_tile)) {
610614
continue;
611615
}
612616

613-
for (int z = 0; z < device_ctx.grid[x][y].type->capacity; z++) {
617+
for (int z = 0; z < physical_tile->capacity; z++) {
614618
t_pb* pb = nullptr;
615619
t_power_usage pb_power;
616620

617621
ClusterBlockId iblk = place_ctx.grid_blocks[x][y].blocks[z];
618622

619-
if (iblk != EMPTY_BLOCK_ID && iblk != INVALID_BLOCK_ID)
623+
if (iblk != EMPTY_BLOCK_ID && iblk != INVALID_BLOCK_ID) {
620624
pb = cluster_ctx.clb_nlist.block_pb(iblk);
625+
logical_block = cluster_ctx.clb_nlist.block_type(iblk);
626+
} else {
627+
logical_block = pick_random_logical_type(physical_tile);
628+
}
621629

622630
/* Calculate power of this CLB */
623-
power_usage_pb(&pb_power, pb, logical_block_type(device_ctx.grid[x][y].type)->pb_graph_head, iblk);
631+
power_usage_pb(&pb_power, pb, logical_block->pb_graph_head, iblk);
624632
power_add_usage(power_usage, &pb_power);
625633
}
626634
}

vpr/src/route/clock_connection_builders.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,16 @@ void ClockToPinsConnection::create_switches(const ClockRRGraphBuilder& clock_gra
208208
auto width_offset = grid[x][y].width_offset;
209209
auto height_offset = grid[x][y].height_offset;
210210

211-
// Ignore gird locations that do not have blocks
212-
if (!logical_block_type(type)->pb_type) {
211+
// Ignore grid locations that do not have blocks
212+
bool has_pb_type = false;
213+
for (auto logical_block : type->equivalent_sites) {
214+
if (logical_block->pb_type) {
215+
has_pb_type = true;
216+
break;
217+
}
218+
}
219+
220+
if (!has_pb_type) {
213221
continue;
214222
}
215223

vpr/src/util/vpr_utils.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -637,20 +637,6 @@ t_physical_tile_type_ptr physical_tile_type(ClusterBlockId blk) {
637637
return device_ctx.grid[loc.x][loc.y].type;
638638
}
639639

640-
t_logical_block_type_ptr logical_block_type(t_physical_tile_type_ptr physical_tile_type) {
641-
auto& device_ctx = g_vpr_ctx.device();
642-
auto& logical_blocks = device_ctx.logical_block_types;
643-
644-
// Loop through the ordered map to get tiles in a decreasing priority order
645-
for (auto& logical_blocks_ids : physical_tile_type->logical_blocks_priority) {
646-
for (auto block_id : logical_blocks_ids.second) {
647-
return &logical_blocks[block_id];
648-
}
649-
}
650-
651-
VPR_THROW(VPR_ERROR_OTHER, "No corresponding logical block type found for physical tile type %s\n", physical_tile_type->name);
652-
}
653-
654640
/* Each node in the pb_graph for a top-level pb_type can be uniquely identified
655641
* by its pins. Since the pins in a cluster of a certain type are densely indexed,
656642
* this function will find the pin index (int pin_count_in_cluster) of the first
@@ -2178,6 +2164,19 @@ t_physical_tile_type_ptr pick_random_physical_type(t_logical_block_type_ptr logi
21782164
return equivalent_tiles[index];
21792165
}
21802166

2167+
t_logical_block_type_ptr pick_random_logical_type(t_physical_tile_type_ptr physical_tile) {
2168+
auto equivalent_sites = physical_tile->equivalent_sites;
2169+
2170+
size_t num_equivalent_sites = equivalent_sites.size();
2171+
int index = 0;
2172+
2173+
if (num_equivalent_sites > 1) {
2174+
index = vtr::irand((int)equivalent_sites.size() - 1);
2175+
}
2176+
2177+
return equivalent_sites[index];
2178+
}
2179+
21812180
int get_logical_pin(t_physical_tile_type_ptr physical_tile,
21822181
t_logical_block_type_ptr logical_block,
21832182
int pin) {

vpr/src/util/vpr_utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ bool is_io_type(t_physical_tile_type_ptr type);
2828
bool is_empty_type(t_physical_tile_type_ptr type);
2929
bool is_empty_type(t_logical_block_type_ptr type);
3030

31-
//Returns the corresponding physical/logical type given the logical/physical type as parameter
31+
//Returns the corresponding physical type given the logical type as parameter
3232
t_physical_tile_type_ptr physical_tile_type(ClusterBlockId blk);
33-
t_logical_block_type_ptr logical_block_type(t_physical_tile_type_ptr physical_tile_type);
3433

3534
int get_unique_pb_graph_node_id(const t_pb_graph_node* pb_graph_node);
3635

@@ -172,6 +171,7 @@ int get_max_num_pins(t_logical_block_type_ptr logical_block);
172171

173172
bool is_tile_compatible(t_physical_tile_type_ptr physical_tile, t_logical_block_type_ptr logical_block);
174173
t_physical_tile_type_ptr pick_random_physical_type(t_logical_block_type_ptr logical_block);
174+
t_logical_block_type_ptr pick_random_logical_type(t_physical_tile_type_ptr physical_tile);
175175

176176
int get_logical_pin(t_physical_tile_type_ptr physical_tile,
177177
t_logical_block_type_ptr logical_block,

0 commit comments

Comments
 (0)