diff --git a/doc/src/vpr/command_line_usage.rst b/doc/src/vpr/command_line_usage.rst index c420ef40f8..78338d75c5 100644 --- a/doc/src/vpr/command_line_usage.rst +++ b/doc/src/vpr/command_line_usage.rst @@ -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 ---------------------------- diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index 553a964d30..75d6340973 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -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(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(args.device_layout, "--device") .help( "Controls which device layout/floorplan is used from the architecture file." diff --git a/vpr/src/base/read_options.h b/vpr/src/base/read_options.h index 5e26d36725..bf320e8708 100644 --- a/vpr/src/base/read_options.h +++ b/vpr/src/base/read_options.h @@ -68,6 +68,7 @@ struct t_options { /* General options */ argparse::ArgValue show_help; argparse::ArgValue show_version; + argparse::ArgValue show_arch_resources; argparse::ArgValue num_workers; argparse::ArgValue timing_analysis; argparse::ArgValue timing_update_type; diff --git a/vpr/src/base/vpr_api.cpp b/vpr/src/base/vpr_api.cpp index 4dc4732c90..3d992d9138 100644 --- a/vpr/src/base/vpr_api.cpp +++ b/vpr/src/base/vpr_api.cpp @@ -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 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"); diff --git a/vpr/src/base/vpr_api.h b/vpr/src/base/vpr_api.h index 02fb56a46b..68652afcd8 100644 --- a/vpr/src/base/vpr_api.h +++ b/vpr/src/base/vpr_api.h @@ -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); diff --git a/vpr/src/main.cpp b/vpr/src/main.cpp index 6643de9484..3d4607473a 100644 --- a/vpr/src/main.cpp +++ b/vpr/src/main.cpp @@ -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");