Skip to content

add show-resource-usage mode #3061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions doc/src/vpr/command_line_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,16 @@ The following options are used to enable server mode in VPR.

.. seealso:: :ref:`interactive_path_analysis_client`


Show Architecture Resources
^^^^^^^^^^^^^^^^^^^^^^^^
.. option:: --show_arch_resources

Print the architecture resource report for each device layout and exit normally.

**Default:** ``off``


Command-line Auto Completion
----------------------------

Expand Down
5 changes: 5 additions & 0 deletions vpr/src/base/read_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,11 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
.help("Show version information then exit")
.action(argparse::Action::VERSION);

gen_grp.add_argument<bool, ParseOnOff>(args.show_arch_resources, "--show_arch_resources")
.help("Show architecture resources then exit")
.action(argparse::Action::STORE_TRUE)
.default_value("off");

gen_grp.add_argument<std::string>(args.device_layout, "--device")
.help(
"Controls which device layout/floorplan is used from the architecture file."
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/read_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct t_options {
/* General options */
argparse::ArgValue<bool> show_help;
argparse::ArgValue<bool> show_version;
argparse::ArgValue<bool> show_arch_resources;
argparse::ArgValue<size_t> num_workers;
argparse::ArgValue<bool> timing_analysis;
argparse::ArgValue<e_timing_update_type> timing_update_type;
Expand Down
42 changes: 42 additions & 0 deletions vpr/src/base/vpr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,48 @@ static void unset_port_equivalences(DeviceContext& device_ctx) {
}
}

void vpr_print_arch_resources(const t_vpr_setup& vpr_setup, const t_arch& Arch) {
vtr::ScopedStartFinishTimer timer("Build Device Grid");
/* Read in netlist file for placement and routing */
auto& device_ctx = g_vpr_ctx.mutable_device();

device_ctx.arch = &Arch;

/*
*Load the device grid
*/

//Record the resource requirement
std::map<t_logical_block_type_ptr, size_t> num_type_instances;

//Build the device
for (const t_grid_def& l : Arch.grid_layouts) {
float target_device_utilization = vpr_setup.PackerOpts.target_device_utilization;
device_ctx.grid = create_device_grid(l.name, Arch.grid_layouts, num_type_instances, target_device_utilization);

/*
*Report on the device
*/
size_t num_grid_tiles = count_grid_tiles(device_ctx.grid);
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());

std::string title("\nResource usage for device layout " + l.name + "...\n");
VTR_LOG(title.c_str());
for (const t_logical_block_type& type : device_ctx.logical_block_types) {
if (is_empty_type(&type)) continue;

VTR_LOG("\tArchitecture\n");
for (const t_physical_tile_type_ptr equivalent_tile : type.equivalent_tiles) {
//get the number of equivalent tile across all layers
int num_instances = (int)device_ctx.grid.num_instances(equivalent_tile, -1);

VTR_LOG("\t\t%d\tblocks of type: %s\n",
num_instances, equivalent_tile->name.c_str());
}
}
}
}

bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
if (vpr_setup.exit_before_pack) {
VTR_LOG_WARN("Exiting before packing as requested.\n");
Expand Down
3 changes: 3 additions & 0 deletions vpr/src/base/vpr_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ void vpr_analysis(const Netlist<>& net_list,
///@brief Create the device (grid + rr graph)
void vpr_create_device(t_vpr_setup& vpr_setup, const t_arch& Arch);

/// @brief Print architecture resources
void vpr_print_arch_resources(const t_vpr_setup& vpr_setup, const t_arch& Arch);

///@brief Create the device grid
void vpr_create_device_grid(const t_vpr_setup& vpr_setup, const t_arch& Arch);

Expand Down
6 changes: 6 additions & 0 deletions vpr/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ int main(int argc, const char** argv) {
return SUCCESS_EXIT_CODE;
}

if (Options.show_arch_resources) {
vpr_print_arch_resources(vpr_setup, Arch);
vpr_free_all(Arch, vpr_setup);
return SUCCESS_EXIT_CODE;
}

bool flow_succeeded = vpr_flow(vpr_setup, Arch);
if (!flow_succeeded) {
VTR_LOG("VPR failed to implement circuit\n");
Expand Down