Skip to content

Stage reporting update #3188

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

Merged
merged 5 commits into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions utils/fasm/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ int main(int argc, const char **argv) {
/* Read options, architecture, and circuit netlist */
vpr_init(argc, argv, &Options, &vpr_setup, &Arch);

vpr_setup.PackerOpts.doPacking = STAGE_LOAD;
vpr_setup.PlacerOpts.doPlacement = STAGE_LOAD;
vpr_setup.APOpts.doAP = STAGE_SKIP;
vpr_setup.RouterOpts.doRouting = STAGE_LOAD;
vpr_setup.PackerOpts.doPacking = e_stage_action::LOAD;
vpr_setup.PlacerOpts.doPlacement = e_stage_action::LOAD;
vpr_setup.APOpts.doAP = e_stage_action::SKIP;
vpr_setup.RouterOpts.doRouting = e_stage_action::LOAD;
vpr_setup.RouterOpts.read_rr_edge_metadata = true;
vpr_setup.AnalysisOpts.doAnalysis = STAGE_SKIP;
vpr_setup.AnalysisOpts.doAnalysis = e_stage_action::SKIP;

bool flow_succeeded = false;
flow_succeeded = vpr_flow(vpr_setup, Arch);
Expand Down
10 changes: 5 additions & 5 deletions utils/fasm/test/test_fasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,12 @@ TEST_CASE("fasm_integration_test", "[fasm]") {
vpr_init(sizeof(argv)/sizeof(argv[0]), argv,
&options, &vpr_setup, &arch);

vpr_setup.PackerOpts.doPacking = STAGE_LOAD;
vpr_setup.PlacerOpts.doPlacement = STAGE_LOAD;
vpr_setup.APOpts.doAP = STAGE_SKIP;
vpr_setup.RouterOpts.doRouting = STAGE_LOAD;
vpr_setup.PackerOpts.doPacking = e_stage_action::LOAD;
vpr_setup.PlacerOpts.doPlacement = e_stage_action::LOAD;
vpr_setup.APOpts.doAP = e_stage_action::SKIP;
vpr_setup.RouterOpts.doRouting = e_stage_action::LOAD;
vpr_setup.RouterOpts.read_rr_edge_metadata = true;
vpr_setup.AnalysisOpts.doAnalysis = STAGE_SKIP;
vpr_setup.AnalysisOpts.doAnalysis = e_stage_action::SKIP;

bool flow_succeeded = vpr_flow(vpr_setup, arch);
REQUIRE(flow_succeeded == true);
Expand Down
10 changes: 5 additions & 5 deletions vpr/src/base/CheckSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void CheckSetup(const t_packer_opts& packer_opts,
"Timing analysis must be enabled for timing-driven placement.\n");
}

if (!placer_opts.doPlacement && (!placer_opts.constraints_file.empty())) {
if (placer_opts.doPlacement == e_stage_action::SKIP && (!placer_opts.constraints_file.empty())) {
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
"A block location file requires that placement is enabled.\n");
}
Expand All @@ -75,14 +75,14 @@ void CheckSetup(const t_packer_opts& packer_opts,
}

// Rules for doing Analytical Placement
if (ap_opts.doAP) {
if (ap_opts.doAP != e_stage_action::SKIP) {
// Make sure that the --place option was not set.
if (placer_opts.doPlacement) {
if (placer_opts.doPlacement != e_stage_action::SKIP) {
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
"Cannot perform both analytical and non-analytical placement.\n");
}
// Make sure that the --pack option was not set.
if (packer_opts.doPacking) {
if (packer_opts.doPacking != e_stage_action::SKIP) {
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
"Analytical placement should skip packing.\n");
}
Expand All @@ -103,7 +103,7 @@ void CheckSetup(const t_packer_opts& packer_opts,
// goes with ensuring that some blocks are fixed.
}

if (router_opts.doRouting) {
if (router_opts.doRouting != e_stage_action::SKIP) {
if (!timing.timing_analysis_enabled
&& (DEMAND_ONLY != router_opts.base_cost_type && DEMAND_ONLY_NORMALIZED_LENGTH != router_opts.base_cost_type)) {
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
Expand Down
48 changes: 24 additions & 24 deletions vpr/src/base/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,50 +250,50 @@ void SetupVPR(const t_options* options,
&& !options->do_routing
&& !options->do_analysis) {
//run all stages if none specified
packerOpts->doPacking = STAGE_DO;
placerOpts->doPlacement = STAGE_DO;
apOpts->doAP = STAGE_SKIP; // AP not default.
routerOpts->doRouting = STAGE_DO;
analysisOpts->doAnalysis = STAGE_AUTO; //Deferred until implementation status known
packerOpts->doPacking = e_stage_action::DO;
placerOpts->doPlacement = e_stage_action::DO;
apOpts->doAP = e_stage_action::SKIP; // AP not default.
routerOpts->doRouting = e_stage_action::DO;
analysisOpts->doAnalysis = e_stage_action::SKIP_IF_PRIOR_FAIL; //Deferred until implementation status known
} else {
//We run all stages up to the specified stage
//Note that by checking in reverse order (i.e. analysis to packing)
//we ensure that earlier stages override the default 'LOAD' action
//set by later stages

if (options->do_analysis) {
packerOpts->doPacking = STAGE_LOAD;
placerOpts->doPlacement = STAGE_LOAD;
routerOpts->doRouting = STAGE_LOAD;
analysisOpts->doAnalysis = STAGE_DO;
packerOpts->doPacking = e_stage_action::LOAD;
placerOpts->doPlacement = e_stage_action::LOAD;
routerOpts->doRouting = e_stage_action::LOAD;
analysisOpts->doAnalysis = e_stage_action::DO;
}

if (options->do_routing) {
packerOpts->doPacking = STAGE_LOAD;
placerOpts->doPlacement = STAGE_LOAD;
routerOpts->doRouting = STAGE_DO;
analysisOpts->doAnalysis = ((options->do_analysis) ? STAGE_DO : STAGE_AUTO); //Always run analysis after routing
packerOpts->doPacking = e_stage_action::LOAD;
placerOpts->doPlacement = e_stage_action::LOAD;
routerOpts->doRouting = e_stage_action::DO;
analysisOpts->doAnalysis = ((options->do_analysis) ? e_stage_action::DO : e_stage_action::SKIP_IF_PRIOR_FAIL); //Always run analysis after routing
}

if (options->do_placement) {
packerOpts->doPacking = STAGE_LOAD;
placerOpts->doPlacement = STAGE_DO;
packerOpts->doPacking = e_stage_action::LOAD;
placerOpts->doPlacement = e_stage_action::DO;
}

if (options->do_analytical_placement) {
// In the Analytical Placement flow, packing and placement are
// integrated. Thus, these stages are skipped.
packerOpts->doPacking = STAGE_SKIP;
placerOpts->doPlacement = STAGE_SKIP;
apOpts->doAP = STAGE_DO;
packerOpts->doPacking = e_stage_action::SKIP;
placerOpts->doPlacement = e_stage_action::SKIP;
apOpts->doAP = e_stage_action::DO;
}

if (options->do_packing) {
packerOpts->doPacking = STAGE_DO;
packerOpts->doPacking = e_stage_action::DO;
}

if (options->do_legalize) {
packerOpts->doPacking = STAGE_LOAD;
packerOpts->doPacking = e_stage_action::LOAD;
packerOpts->load_flat_placement = true;
}
}
Expand Down Expand Up @@ -473,7 +473,7 @@ static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts)
RouterOpts->acc_fac = Options.acc_fac;
RouterOpts->bend_cost = Options.bend_cost;
if (Options.do_routing) {
RouterOpts->doRouting = STAGE_DO;
RouterOpts->doRouting = e_stage_action::DO;
}
RouterOpts->routing_failure_predictor = Options.routing_failure_predictor;
RouterOpts->routing_budgets_algorithm = Options.routing_budgets_algorithm;
Expand Down Expand Up @@ -587,7 +587,7 @@ void SetupPackerOpts(const t_options& Options,
PackerOpts->circuit_file_name = Options.CircuitFile;

if (Options.do_packing) {
PackerOpts->doPacking = STAGE_DO;
PackerOpts->doPacking = e_stage_action::DO;
}

PackerOpts->allow_unrelated_clustering = Options.allow_unrelated_clustering;
Expand Down Expand Up @@ -629,7 +629,7 @@ static void SetupNetlistOpts(const t_options& Options, t_netlist_opts& NetlistOp
*/
static void SetupPlacerOpts(const t_options& Options, t_placer_opts* PlacerOpts) {
if (Options.do_placement) {
PlacerOpts->doPlacement = STAGE_DO;
PlacerOpts->doPlacement = e_stage_action::DO;
}

PlacerOpts->inner_loop_recompute_divider = Options.inner_loop_recompute_divider;
Expand Down Expand Up @@ -713,7 +713,7 @@ static void SetupPlacerOpts(const t_options& Options, t_placer_opts* PlacerOpts)

static void SetupAnalysisOpts(const t_options& Options, t_analysis_opts& analysis_opts) {
if (Options.do_analysis) {
analysis_opts.doAnalysis = STAGE_DO;
analysis_opts.doAnalysis = e_stage_action::DO;
}

analysis_opts.gen_post_synthesis_netlist = Options.Generate_Post_Synthesis_Netlist;
Expand Down
20 changes: 10 additions & 10 deletions vpr/src/base/ShowSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@ void ShowSetup(const t_vpr_setup& vpr_setup) {
}
VTR_LOG("\n");

VTR_LOG("Packer: %s\n", (vpr_setup.PackerOpts.doPacking ? "ENABLED" : "DISABLED"));
VTR_LOG("Placer: %s\n", (vpr_setup.PlacerOpts.doPlacement ? "ENABLED" : "DISABLED"));
VTR_LOG("Analytical Placer: %s\n", (vpr_setup.APOpts.doAP ? "ENABLED" : "DISABLED"));
VTR_LOG("Router: %s\n", (vpr_setup.RouterOpts.doRouting ? "ENABLED" : "DISABLED"));
VTR_LOG("Analysis: %s\n", (vpr_setup.AnalysisOpts.doAnalysis ? "ENABLED" : "DISABLED"));
VTR_LOG("Packer: %s\n", stage_action_strings[vpr_setup.PackerOpts.doPacking]);
VTR_LOG("Placer: %s\n", stage_action_strings[vpr_setup.PlacerOpts.doPlacement]);
VTR_LOG("Analytical Placer: %s\n", stage_action_strings[vpr_setup.APOpts.doAP]);
VTR_LOG("Router: %s\n", stage_action_strings[vpr_setup.RouterOpts.doRouting]);
VTR_LOG("Analysis: %s\n", stage_action_strings[vpr_setup.AnalysisOpts.doAnalysis]);
VTR_LOG("\n");

VTR_LOG("VPR was run with the following options:\n\n");

ShowNetlistOpts(vpr_setup.NetlistOpts);

if (vpr_setup.PackerOpts.doPacking) {
if (vpr_setup.PackerOpts.doPacking != e_stage_action::SKIP) {
ShowPackerOpts(vpr_setup.PackerOpts);
}
if (vpr_setup.PlacerOpts.doPlacement) {
if (vpr_setup.PlacerOpts.doPlacement != e_stage_action::SKIP) {
ShowPlacerOpts(vpr_setup.PlacerOpts);
}
if (vpr_setup.APOpts.doAP) {
if (vpr_setup.APOpts.doAP != e_stage_action::SKIP) {
ShowAnalyticalPlacerOpts(vpr_setup.APOpts);
}
if (vpr_setup.RouterOpts.doRouting) {
if (vpr_setup.RouterOpts.doRouting != e_stage_action::SKIP) {
ShowRouterOpts(vpr_setup.RouterOpts);
}
if (vpr_setup.AnalysisOpts.doAnalysis) {
if (vpr_setup.AnalysisOpts.doAnalysis != e_stage_action::SKIP) {
ShowAnalysisOpts(vpr_setup.AnalysisOpts);
}
if (vpr_setup.NocOpts.noc) {
Expand Down
2 changes: 2 additions & 0 deletions vpr/src/base/ShowSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <ostream>
#include <string>
#include <vector>
#include "vpr_types.h"

struct t_logical_block_type;
struct t_vpr_setup;
Expand Down Expand Up @@ -33,4 +34,5 @@ struct ClusteredNetlistStats {
};

void ShowSetup(const t_vpr_setup& vpr_setup);

void writeClusteredNetlistStats(const std::string& block_usage_filename);
34 changes: 17 additions & 17 deletions vpr/src/base/vpr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
vpr_create_device(vpr_setup, arch);
// If packing is not skipped, cluster netlist contain valid information, so
// we can print the resource usage and device utilization
if (vpr_setup.PackerOpts.doPacking != STAGE_SKIP) {
if (vpr_setup.PackerOpts.doPacking != e_stage_action::SKIP) {
float target_device_utilization = vpr_setup.PackerOpts.target_device_utilization;
// Print the number of resources in netlist and number of resources available in architecture
print_resource_usage();
Expand All @@ -482,7 +482,7 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
}

{ // Analytical Place
if (vpr_setup.APOpts.doAP == STAGE_DO) {
if (vpr_setup.APOpts.doAP == e_stage_action::DO) {
// Passing flat placement input if provided and not loaded yet.
if (!vpr_setup.FileNameOpts.read_flat_place_file.empty() && !g_vpr_ctx.atom().flat_placement_info().valid) {
g_vpr_ctx.mutable_atom().mutable_flat_placement_info() = read_flat_placement(vpr_setup.FileNameOpts.read_flat_place_file,
Expand Down Expand Up @@ -641,10 +641,10 @@ bool vpr_pack_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {

bool status = true;

if (packer_opts.doPacking == STAGE_SKIP) {
if (packer_opts.doPacking == e_stage_action::SKIP) {
//pass
} else {
if (packer_opts.doPacking == STAGE_DO) {
if (packer_opts.doPacking == e_stage_action::DO) {
//Do the actual packing
status = vpr_pack(vpr_setup, arch);
if (!status) {
Expand All @@ -658,7 +658,7 @@ bool vpr_pack_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {
//Load the result from the .net file
vpr_load_packing(vpr_setup, arch);
} else {
VTR_ASSERT(packer_opts.doPacking == STAGE_LOAD);
VTR_ASSERT(packer_opts.doPacking == e_stage_action::LOAD);

// generate a .net file by legalizing an input flat placement file
if (packer_opts.load_flat_placement) {
Expand Down Expand Up @@ -799,7 +799,7 @@ bool vpr_load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
device_ctx.grid.clear();

// if running placement, use the fix clusters file produced by the legalizer
if (vpr_setup.PlacerOpts.doPlacement) {
if (vpr_setup.PlacerOpts.doPlacement != e_stage_action::SKIP) {
vpr_setup.PlacerOpts.constraints_file = vpr_setup.FileNameOpts.write_constraints_file;
}
return true;
Expand All @@ -811,15 +811,15 @@ bool vpr_place_flow(const Netlist<>& net_list,
VTR_LOG("\n");
const auto& placer_opts = vpr_setup.PlacerOpts;
const auto& filename_opts = vpr_setup.FileNameOpts;
if (placer_opts.doPlacement == STAGE_SKIP) {
if (placer_opts.doPlacement == e_stage_action::SKIP) {
//pass
} else {
if (placer_opts.doPlacement == STAGE_DO) {
if (placer_opts.doPlacement == e_stage_action::DO) {
//Do the actual placement
vpr_place(net_list, vpr_setup, arch);

} else {
VTR_ASSERT(placer_opts.doPlacement == STAGE_LOAD);
VTR_ASSERT(placer_opts.doPlacement == e_stage_action::LOAD);

//Load a previous placement
vpr_load_placement(vpr_setup, arch.directs);
Expand Down Expand Up @@ -943,7 +943,7 @@ RouteStatus vpr_route_flow(const Netlist<>& net_list,
const auto& device_ctx = g_vpr_ctx.device();
const auto& rr_graph = device_ctx.rr_graph;

if (router_opts.doRouting == STAGE_SKIP) {
if (router_opts.doRouting == e_stage_action::SKIP) {
//Assume successful
route_status = RouteStatus(true, -1);
} else { //Do or load
Expand Down Expand Up @@ -975,7 +975,7 @@ RouteStatus vpr_route_flow(const Netlist<>& net_list,
timing_info = make_constant_timing_info(0);
}

if (router_opts.doRouting == STAGE_DO) {
if (router_opts.doRouting == e_stage_action::DO) {
//Do the actual routing
if (NO_FIXED_CHANNEL_WIDTH == chan_width) {
//Find minimum channel width
Expand All @@ -991,7 +991,7 @@ RouteStatus vpr_route_flow(const Netlist<>& net_list,
filename_opts.RouteFile.c_str(),
is_flat);
} else {
VTR_ASSERT(router_opts.doRouting == STAGE_LOAD);
VTR_ASSERT(router_opts.doRouting == e_stage_action::LOAD);
//Load a previous routing
//if the previous load file is generated using flat routing,
//we need to create rr_graph with is_flat flag to add additional
Expand Down Expand Up @@ -1312,7 +1312,7 @@ void vpr_free_vpr_data_structures(t_arch& Arch,
void vpr_free_all(t_arch& Arch,
t_vpr_setup& vpr_setup) {
free_rr_graph();
if (vpr_setup.RouterOpts.doRouting) {
if (vpr_setup.RouterOpts.doRouting != e_stage_action::SKIP) {
free_route_structs();
}
vpr_free_vpr_data_structures(Arch, vpr_setup);
Expand Down Expand Up @@ -1414,12 +1414,12 @@ bool vpr_analysis_flow(const Netlist<>& net_list,
bool is_flat) {
auto& analysis_opts = vpr_setup.AnalysisOpts;

if (analysis_opts.doAnalysis == STAGE_SKIP) return true; //Skipped
if (analysis_opts.doAnalysis == e_stage_action::SKIP) return true; //Skipped

if (analysis_opts.doAnalysis == STAGE_AUTO && !route_status.success()) return false; //Not run
if (analysis_opts.doAnalysis == e_stage_action::SKIP_IF_PRIOR_FAIL && !route_status.success()) return false; //Not run

VTR_ASSERT_MSG(analysis_opts.doAnalysis == STAGE_DO
|| (analysis_opts.doAnalysis == STAGE_AUTO && route_status.success()),
VTR_ASSERT_MSG(analysis_opts.doAnalysis == e_stage_action::DO
|| (analysis_opts.doAnalysis == e_stage_action::SKIP_IF_PRIOR_FAIL && route_status.success()),
"Analysis should run only if forced, or implementation legal");

if (!route_status.success()) {
Expand Down
26 changes: 20 additions & 6 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,28 @@ struct t_netlist_opts {
int netlist_verbosity = 1; ///<Verbose output during netlist cleaning
};

///@brief Should a stage in the CAD flow be skipped, loaded from a file, or performed
enum e_stage_action {
STAGE_SKIP = 0,
STAGE_LOAD,
STAGE_DO,
STAGE_AUTO
/**
* @brief Specifies the action to take for a CAD flow stage.
*
* @details
* SKIP - Do not perform this algorithm at all (End flow early).
* LOAD - Load previous result from file.
* DO - Run the specified algorithm.
* SKIP_IF_PRIOR_FAIL - Run the specified algorithm if possible.
* Currently used to avoid analysis if we don't succeed at routing.
*/
enum class e_stage_action {
SKIP = 0,
LOAD,
DO,
SKIP_IF_PRIOR_FAIL,
NUM_STAGE_ACTIONS
};

///@brief String representations of e_stage_action
constexpr vtr::array<e_stage_action, const char*, (size_t)e_stage_action::NUM_STAGE_ACTIONS> stage_action_strings{
"DISABLED", "LOAD", "ENABLED", "SKIP IF PRIOR FAIL"};

/**
* @brief Options for packing
*
Expand Down