Skip to content

Commit 7a860a2

Browse files
committed
[vpr][base] print resource usage and device util only if clb netlist is valid
1 parent ef74c24 commit 7a860a2

File tree

4 files changed

+34
-57
lines changed

4 files changed

+34
-57
lines changed

vpr/src/analytical_place/analytical_placement_flow.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "user_place_constraints.h"
2222
#include "vpr_context.h"
2323
#include "vpr_types.h"
24+
#include "stats.h"
2425
#include "vtr_assert.h"
2526
#include "vtr_time.h"
2627

@@ -188,6 +189,12 @@ void run_analytical_placement_flow(t_vpr_setup& vpr_setup) {
188189
device_ctx.grid);
189190
full_legalizer->legalize(p_placement);
190191

192+
// Print the number of resources in netlist and number of resources available in architecture
193+
float target_device_utilization = vpr_setup.PackerOpts.target_device_utilization;
194+
print_resource_usage(target_device_utilization);
195+
// Print the device utilization
196+
print_device_utilization(target_device_utilization);
197+
191198
// Run the Detailed Placer.
192199
std::unique_ptr<DetailedPlacer> detailed_placer = make_detailed_placer(ap_opts.detailed_placer_type,
193200
g_vpr_ctx.placement().blk_loc_registry(),

vpr/src/base/stats.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,13 @@ float calculate_device_utilization(const DeviceGrid& grid, const std::map<t_logi
502502
return utilization;
503503
}
504504

505-
void print_resource_usage(const std::map<t_logical_block_type_ptr, size_t>& num_type_instances) {
505+
void print_resource_usage(const float target_device_utilization) {
506506
auto& device_ctx = g_vpr_ctx.device();
507+
const auto& clb_netlist = g_vpr_ctx.clustering().clb_nlist;
508+
std::map<t_logical_block_type_ptr, size_t> num_type_instances;
509+
for (auto blk_id : clb_netlist.blocks()) {
510+
num_type_instances[clb_netlist.block_type(blk_id)]++;
511+
}
507512

508513
VTR_LOG("\n");
509514
VTR_LOG("Resource usage...\n");
@@ -526,8 +531,14 @@ void print_resource_usage(const std::map<t_logical_block_type_ptr, size_t>& num_
526531
VTR_LOG("\n");
527532
}
528533

529-
void print_device_utilization(const std::map<t_logical_block_type_ptr, size_t>& num_type_instances, const float target_device_utilization) {
534+
void print_device_utilization(const float target_device_utilization) {
530535
auto& device_ctx = g_vpr_ctx.device();
536+
const auto& clb_netlist = g_vpr_ctx.clustering().clb_nlist;
537+
std::map<t_logical_block_type_ptr, size_t> num_type_instances;
538+
for (auto blk_id : clb_netlist.blocks()) {
539+
num_type_instances[clb_netlist.block_type(blk_id)]++;
540+
}
541+
531542
float device_utilization = calculate_device_utilization(device_ctx.grid, num_type_instances);
532543
VTR_LOG("Device Utilization: %.2f (target %.2f)\n", device_utilization, target_device_utilization);
533544
for (const auto& type : device_ctx.physical_tile_types) {

vpr/src/base/stats.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ float calculate_device_utilization(const DeviceGrid& grid, const std::map<t_logi
3333

3434
/**
3535
* @brief Prints the number of resources in the netlist and the number of available resources in the architecture.
36-
* @param num_type_instances The number of instances of each logical block type
3736
* @param target_device_utilization The target device utilization set by the user
3837
*/
39-
void print_resource_usage(const std::map<t_logical_block_type_ptr, size_t>& num_type_instances, const float target_device_utilization);
38+
void print_resource_usage(const float target_device_utilization);
39+
40+
/**
41+
* @brief Prints the device utilization
42+
* @param target_device_utilization The target device utilization set by the user
43+
*/
44+
void print_device_utilization(const float target_device_utilization);
4045

4146
/**
4247
* @brief template functions must be defined in header, or explicitely

vpr/src/base/vpr_api.cpp

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,13 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
385385
}
386386

387387
vpr_create_device(vpr_setup, arch);
388+
if (vpr_setup.PackerOpts.doPacking != STAGE_SKIP) {
389+
float target_device_utilization = vpr_setup.PackerOpts.target_device_utilization;
390+
// Print the number of resources in netlist and number of resources available in architecture
391+
print_resource_usage(target_device_utilization);
392+
// Print the device utilization
393+
print_device_utilization(target_device_utilization);
394+
}
388395

389396
// TODO: Placer still assumes that cluster net list is used - graphics can not work with flat routing yet
390397
vpr_init_graphics(vpr_setup, arch, false);
@@ -498,59 +505,6 @@ void vpr_create_device_grid(const t_vpr_setup& vpr_setup, const t_arch& Arch) {
498505
*/
499506
size_t num_grid_tiles = count_grid_tiles(device_ctx.grid);
500507
VTR_LOG("FPGA sized to %zu x %zu: %zu grid tiles (%s)\n", device_ctx.grid.width(), device_ctx.grid.height(), num_grid_tiles, device_ctx.grid.name().c_str());
501-
502-
VTR_LOG("\n");
503-
VTR_LOG("Resource usage...\n");
504-
for (const auto& type : device_ctx.logical_block_types) {
505-
if (is_empty_type(&type)) continue;
506-
507-
VTR_LOG("\tNetlist\n\t\t%d\tblocks of type: %s\n",
508-
num_type_instances[&type], type.name.c_str());
509-
510-
VTR_LOG("\tArchitecture\n");
511-
for (const auto equivalent_tile : type.equivalent_tiles) {
512-
auto num_instances = 0;
513-
//get the number of equivalent tile across all layers
514-
num_instances = (int)device_ctx.grid.num_instances(equivalent_tile, -1);
515-
516-
VTR_LOG("\t\t%d\tblocks of type: %s\n",
517-
num_instances, equivalent_tile->name.c_str());
518-
}
519-
}
520-
VTR_LOG("\n");
521-
522-
float device_utilization = calculate_device_utilization(device_ctx.grid, num_type_instances);
523-
VTR_LOG("Device Utilization: %.2f (target %.2f)\n", device_utilization, target_device_utilization);
524-
for (const auto& type : device_ctx.physical_tile_types) {
525-
if (is_empty_type(&type)) {
526-
continue;
527-
}
528-
529-
if (device_ctx.grid.num_instances(&type, -1) != 0) {
530-
VTR_LOG("\tPhysical Tile %s:\n", type.name.c_str());
531-
532-
auto equivalent_sites = get_equivalent_sites_set(&type);
533-
534-
for (auto logical_block : equivalent_sites) {
535-
float util = 0.;
536-
size_t num_inst = device_ctx.grid.num_instances(&type, -1);
537-
if (num_inst != 0) {
538-
util = float(num_type_instances[logical_block]) / num_inst;
539-
}
540-
VTR_LOG("\tBlock Utilization: %.2f Logical Block: %s\n", util, logical_block->name.c_str());
541-
}
542-
}
543-
}
544-
VTR_LOG("\n");
545-
546-
if (!device_ctx.grid.limiting_resources().empty()) {
547-
std::vector<std::string> limiting_block_names;
548-
for (auto blk_type : device_ctx.grid.limiting_resources()) {
549-
limiting_block_names.emplace_back(blk_type->name);
550-
}
551-
VTR_LOG("FPGA size limited by block type(s): %s\n", vtr::join(limiting_block_names, " ").c_str());
552-
VTR_LOG("\n");
553-
}
554508
}
555509

556510
void vpr_setup_clock_networks(t_vpr_setup& vpr_setup, const t_arch& Arch) {

0 commit comments

Comments
 (0)