Skip to content

Commit df0d366

Browse files
committed
[vpr][stats] add print_resource_usage
1 parent 648413c commit df0d366

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

vpr/src/base/stats.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,3 +448,27 @@ int count_netlist_clocks() {
448448
//Since std::set does not include duplicates, the number of clocks is the size of the set
449449
return static_cast<int>(clock_names.size());
450450
}
451+
452+
void print_resource_usage(const std::map<t_logical_block_type_ptr, size_t>& num_type_instances) {
453+
auto& device_ctx = g_vpr_ctx.device();
454+
455+
VTR_LOG("\n");
456+
VTR_LOG("Resource usage...\n");
457+
for (const auto& type : device_ctx.logical_block_types) {
458+
if (is_empty_type(&type)) continue;
459+
460+
VTR_LOG("\tNetlist\n\t\t%d\tblocks of type: %s\n",
461+
num_type_instances.at(&type), type.name.c_str());
462+
463+
VTR_LOG("\tArchitecture\n");
464+
for (const auto equivalent_tile : type.equivalent_tiles) {
465+
auto num_instances = 0;
466+
//get the number of equivalent tile across all layers
467+
num_instances = (int)device_ctx.grid.num_instances(equivalent_tile, -1);
468+
469+
VTR_LOG("\t\t%d\tblocks of type: %s\n",
470+
num_instances, equivalent_tile->name.c_str());
471+
}
472+
}
473+
VTR_LOG("\n");
474+
}

vpr/src/base/stats.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ void get_num_bends_and_length(ParentNetId inet, int* bends, int* length, int* se
2323

2424
int count_netlist_clocks();
2525

26+
/**
27+
* @brief Prints the number of resources in the netlist and the number of available resources in the architecture.
28+
* @param num_type_instances The number of instances of each logical block type
29+
*/
30+
void print_resource_usage(const std::map<t_logical_block_type_ptr, size_t>& num_type_instances);
31+
2632
/**
2733
* @brief template functions must be defined in header, or explicitely
2834
* instantiated in definition file (defeats the point of template)

0 commit comments

Comments
 (0)