Skip to content

Commit ef74c24

Browse files
committed
add print_device_util to stats
1 parent 283343d commit ef74c24

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

vpr/src/base/stats.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,3 +525,39 @@ void print_resource_usage(const std::map<t_logical_block_type_ptr, size_t>& num_
525525
}
526526
VTR_LOG("\n");
527527
}
528+
529+
void print_device_utilization(const std::map<t_logical_block_type_ptr, size_t>& num_type_instances, const float target_device_utilization) {
530+
auto& device_ctx = g_vpr_ctx.device();
531+
float device_utilization = calculate_device_utilization(device_ctx.grid, num_type_instances);
532+
VTR_LOG("Device Utilization: %.2f (target %.2f)\n", device_utilization, target_device_utilization);
533+
for (const auto& type : device_ctx.physical_tile_types) {
534+
if (is_empty_type(&type)) {
535+
continue;
536+
}
537+
538+
if (device_ctx.grid.num_instances(&type, -1) != 0) {
539+
VTR_LOG("\tPhysical Tile %s:\n", type.name.c_str());
540+
541+
auto equivalent_sites = get_equivalent_sites_set(&type);
542+
543+
for (auto logical_block : equivalent_sites) {
544+
float util = 0.;
545+
size_t num_inst = device_ctx.grid.num_instances(&type, -1);
546+
if (num_inst != 0) {
547+
util = float(num_type_instances.at(logical_block)) / num_inst;
548+
}
549+
VTR_LOG("\tBlock Utilization: %.2f Logical Block: %s\n", util, logical_block->name.c_str());
550+
}
551+
}
552+
}
553+
VTR_LOG("\n");
554+
555+
if (!device_ctx.grid.limiting_resources().empty()) {
556+
std::vector<std::string> limiting_block_names;
557+
for (auto blk_type : device_ctx.grid.limiting_resources()) {
558+
limiting_block_names.emplace_back(blk_type->name);
559+
}
560+
VTR_LOG("FPGA size limited by block type(s): %s\n", vtr::join(limiting_block_names, " ").c_str());
561+
VTR_LOG("\n");
562+
}
563+
}

vpr/src/base/stats.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ float calculate_device_utilization(const DeviceGrid& grid, const std::map<t_logi
3434
/**
3535
* @brief Prints the number of resources in the netlist and the number of available resources in the architecture.
3636
* @param num_type_instances The number of instances of each logical block type
37+
* @param target_device_utilization The target device utilization set by the user
3738
*/
38-
void print_resource_usage(const std::map<t_logical_block_type_ptr, size_t>& num_type_instances);
39+
void print_resource_usage(const std::map<t_logical_block_type_ptr, size_t>& num_type_instances, const float target_device_utilization);
3940

4041
/**
4142
* @brief template functions must be defined in header, or explicitely

0 commit comments

Comments
 (0)