Skip to content

Commit a44a9af

Browse files
authored
Merge pull request #3188 from verilog-to-routing/stage_reporting
Stage reporting update
2 parents a2277d1 + cabc231 commit a44a9af

File tree

8 files changed

+88
-72
lines changed

8 files changed

+88
-72
lines changed

utils/fasm/src/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ int main(int argc, const char **argv) {
7373
/* Read options, architecture, and circuit netlist */
7474
vpr_init(argc, argv, &Options, &vpr_setup, &Arch);
7575

76-
vpr_setup.PackerOpts.doPacking = STAGE_LOAD;
77-
vpr_setup.PlacerOpts.doPlacement = STAGE_LOAD;
78-
vpr_setup.APOpts.doAP = STAGE_SKIP;
79-
vpr_setup.RouterOpts.doRouting = STAGE_LOAD;
76+
vpr_setup.PackerOpts.doPacking = e_stage_action::LOAD;
77+
vpr_setup.PlacerOpts.doPlacement = e_stage_action::LOAD;
78+
vpr_setup.APOpts.doAP = e_stage_action::SKIP;
79+
vpr_setup.RouterOpts.doRouting = e_stage_action::LOAD;
8080
vpr_setup.RouterOpts.read_rr_edge_metadata = true;
81-
vpr_setup.AnalysisOpts.doAnalysis = STAGE_SKIP;
81+
vpr_setup.AnalysisOpts.doAnalysis = e_stage_action::SKIP;
8282

8383
bool flow_succeeded = false;
8484
flow_succeeded = vpr_flow(vpr_setup, Arch);

utils/fasm/test/test_fasm.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@ TEST_CASE("fasm_integration_test", "[fasm]") {
315315
vpr_init(sizeof(argv)/sizeof(argv[0]), argv,
316316
&options, &vpr_setup, &arch);
317317

318-
vpr_setup.PackerOpts.doPacking = STAGE_LOAD;
319-
vpr_setup.PlacerOpts.doPlacement = STAGE_LOAD;
320-
vpr_setup.APOpts.doAP = STAGE_SKIP;
321-
vpr_setup.RouterOpts.doRouting = STAGE_LOAD;
318+
vpr_setup.PackerOpts.doPacking = e_stage_action::LOAD;
319+
vpr_setup.PlacerOpts.doPlacement = e_stage_action::LOAD;
320+
vpr_setup.APOpts.doAP = e_stage_action::SKIP;
321+
vpr_setup.RouterOpts.doRouting = e_stage_action::LOAD;
322322
vpr_setup.RouterOpts.read_rr_edge_metadata = true;
323-
vpr_setup.AnalysisOpts.doAnalysis = STAGE_SKIP;
323+
vpr_setup.AnalysisOpts.doAnalysis = e_stage_action::SKIP;
324324

325325
bool flow_succeeded = vpr_flow(vpr_setup, arch);
326326
REQUIRE(flow_succeeded == true);

vpr/src/base/CheckSetup.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void CheckSetup(const t_packer_opts& packer_opts,
5050
"Timing analysis must be enabled for timing-driven placement.\n");
5151
}
5252

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

7777
// Rules for doing Analytical Placement
78-
if (ap_opts.doAP) {
78+
if (ap_opts.doAP != e_stage_action::SKIP) {
7979
// Make sure that the --place option was not set.
80-
if (placer_opts.doPlacement) {
80+
if (placer_opts.doPlacement != e_stage_action::SKIP) {
8181
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
8282
"Cannot perform both analytical and non-analytical placement.\n");
8383
}
8484
// Make sure that the --pack option was not set.
85-
if (packer_opts.doPacking) {
85+
if (packer_opts.doPacking != e_stage_action::SKIP) {
8686
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
8787
"Analytical placement should skip packing.\n");
8888
}
@@ -103,7 +103,7 @@ void CheckSetup(const t_packer_opts& packer_opts,
103103
// goes with ensuring that some blocks are fixed.
104104
}
105105

106-
if (router_opts.doRouting) {
106+
if (router_opts.doRouting != e_stage_action::SKIP) {
107107
if (!timing.timing_analysis_enabled
108108
&& (DEMAND_ONLY != router_opts.base_cost_type && DEMAND_ONLY_NORMALIZED_LENGTH != router_opts.base_cost_type)) {
109109
VPR_FATAL_ERROR(VPR_ERROR_OTHER,

vpr/src/base/SetupVPR.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -250,50 +250,50 @@ void SetupVPR(const t_options* options,
250250
&& !options->do_routing
251251
&& !options->do_analysis) {
252252
//run all stages if none specified
253-
packerOpts->doPacking = STAGE_DO;
254-
placerOpts->doPlacement = STAGE_DO;
255-
apOpts->doAP = STAGE_SKIP; // AP not default.
256-
routerOpts->doRouting = STAGE_DO;
257-
analysisOpts->doAnalysis = STAGE_AUTO; //Deferred until implementation status known
253+
packerOpts->doPacking = e_stage_action::DO;
254+
placerOpts->doPlacement = e_stage_action::DO;
255+
apOpts->doAP = e_stage_action::SKIP; // AP not default.
256+
routerOpts->doRouting = e_stage_action::DO;
257+
analysisOpts->doAnalysis = e_stage_action::SKIP_IF_PRIOR_FAIL; //Deferred until implementation status known
258258
} else {
259259
//We run all stages up to the specified stage
260260
//Note that by checking in reverse order (i.e. analysis to packing)
261261
//we ensure that earlier stages override the default 'LOAD' action
262262
//set by later stages
263263

264264
if (options->do_analysis) {
265-
packerOpts->doPacking = STAGE_LOAD;
266-
placerOpts->doPlacement = STAGE_LOAD;
267-
routerOpts->doRouting = STAGE_LOAD;
268-
analysisOpts->doAnalysis = STAGE_DO;
265+
packerOpts->doPacking = e_stage_action::LOAD;
266+
placerOpts->doPlacement = e_stage_action::LOAD;
267+
routerOpts->doRouting = e_stage_action::LOAD;
268+
analysisOpts->doAnalysis = e_stage_action::DO;
269269
}
270270

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

278278
if (options->do_placement) {
279-
packerOpts->doPacking = STAGE_LOAD;
280-
placerOpts->doPlacement = STAGE_DO;
279+
packerOpts->doPacking = e_stage_action::LOAD;
280+
placerOpts->doPlacement = e_stage_action::DO;
281281
}
282282

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

291291
if (options->do_packing) {
292-
packerOpts->doPacking = STAGE_DO;
292+
packerOpts->doPacking = e_stage_action::DO;
293293
}
294294

295295
if (options->do_legalize) {
296-
packerOpts->doPacking = STAGE_LOAD;
296+
packerOpts->doPacking = e_stage_action::LOAD;
297297
packerOpts->load_flat_placement = true;
298298
}
299299
}
@@ -473,7 +473,7 @@ static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts)
473473
RouterOpts->acc_fac = Options.acc_fac;
474474
RouterOpts->bend_cost = Options.bend_cost;
475475
if (Options.do_routing) {
476-
RouterOpts->doRouting = STAGE_DO;
476+
RouterOpts->doRouting = e_stage_action::DO;
477477
}
478478
RouterOpts->routing_failure_predictor = Options.routing_failure_predictor;
479479
RouterOpts->routing_budgets_algorithm = Options.routing_budgets_algorithm;
@@ -587,7 +587,7 @@ void SetupPackerOpts(const t_options& Options,
587587
PackerOpts->circuit_file_name = Options.CircuitFile;
588588

589589
if (Options.do_packing) {
590-
PackerOpts->doPacking = STAGE_DO;
590+
PackerOpts->doPacking = e_stage_action::DO;
591591
}
592592

593593
PackerOpts->allow_unrelated_clustering = Options.allow_unrelated_clustering;
@@ -629,7 +629,7 @@ static void SetupNetlistOpts(const t_options& Options, t_netlist_opts& NetlistOp
629629
*/
630630
static void SetupPlacerOpts(const t_options& Options, t_placer_opts* PlacerOpts) {
631631
if (Options.do_placement) {
632-
PlacerOpts->doPlacement = STAGE_DO;
632+
PlacerOpts->doPlacement = e_stage_action::DO;
633633
}
634634

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

714714
static void SetupAnalysisOpts(const t_options& Options, t_analysis_opts& analysis_opts) {
715715
if (Options.do_analysis) {
716-
analysis_opts.doAnalysis = STAGE_DO;
716+
analysis_opts.doAnalysis = e_stage_action::DO;
717717
}
718718

719719
analysis_opts.gen_post_synthesis_netlist = Options.Generate_Post_Synthesis_Netlist;

vpr/src/base/ShowSetup.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,30 @@ void ShowSetup(const t_vpr_setup& vpr_setup) {
3737
}
3838
VTR_LOG("\n");
3939

40-
VTR_LOG("Packer: %s\n", (vpr_setup.PackerOpts.doPacking ? "ENABLED" : "DISABLED"));
41-
VTR_LOG("Placer: %s\n", (vpr_setup.PlacerOpts.doPlacement ? "ENABLED" : "DISABLED"));
42-
VTR_LOG("Analytical Placer: %s\n", (vpr_setup.APOpts.doAP ? "ENABLED" : "DISABLED"));
43-
VTR_LOG("Router: %s\n", (vpr_setup.RouterOpts.doRouting ? "ENABLED" : "DISABLED"));
44-
VTR_LOG("Analysis: %s\n", (vpr_setup.AnalysisOpts.doAnalysis ? "ENABLED" : "DISABLED"));
40+
VTR_LOG("Packer: %s\n", stage_action_strings[vpr_setup.PackerOpts.doPacking]);
41+
VTR_LOG("Placer: %s\n", stage_action_strings[vpr_setup.PlacerOpts.doPlacement]);
42+
VTR_LOG("Analytical Placer: %s\n", stage_action_strings[vpr_setup.APOpts.doAP]);
43+
VTR_LOG("Router: %s\n", stage_action_strings[vpr_setup.RouterOpts.doRouting]);
44+
VTR_LOG("Analysis: %s\n", stage_action_strings[vpr_setup.AnalysisOpts.doAnalysis]);
4545
VTR_LOG("\n");
4646

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

4949
ShowNetlistOpts(vpr_setup.NetlistOpts);
5050

51-
if (vpr_setup.PackerOpts.doPacking) {
51+
if (vpr_setup.PackerOpts.doPacking != e_stage_action::SKIP) {
5252
ShowPackerOpts(vpr_setup.PackerOpts);
5353
}
54-
if (vpr_setup.PlacerOpts.doPlacement) {
54+
if (vpr_setup.PlacerOpts.doPlacement != e_stage_action::SKIP) {
5555
ShowPlacerOpts(vpr_setup.PlacerOpts);
5656
}
57-
if (vpr_setup.APOpts.doAP) {
57+
if (vpr_setup.APOpts.doAP != e_stage_action::SKIP) {
5858
ShowAnalyticalPlacerOpts(vpr_setup.APOpts);
5959
}
60-
if (vpr_setup.RouterOpts.doRouting) {
60+
if (vpr_setup.RouterOpts.doRouting != e_stage_action::SKIP) {
6161
ShowRouterOpts(vpr_setup.RouterOpts);
6262
}
63-
if (vpr_setup.AnalysisOpts.doAnalysis) {
63+
if (vpr_setup.AnalysisOpts.doAnalysis != e_stage_action::SKIP) {
6464
ShowAnalysisOpts(vpr_setup.AnalysisOpts);
6565
}
6666
if (vpr_setup.NocOpts.noc) {

vpr/src/base/ShowSetup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <ostream>
44
#include <string>
55
#include <vector>
6+
#include "vpr_types.h"
67

78
struct t_logical_block_type;
89
struct t_vpr_setup;
@@ -33,4 +34,5 @@ struct ClusteredNetlistStats {
3334
};
3435

3536
void ShowSetup(const t_vpr_setup& vpr_setup);
37+
3638
void writeClusteredNetlistStats(const std::string& block_usage_filename);

vpr/src/base/vpr_api.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
458458
vpr_create_device(vpr_setup, arch);
459459
// If packing is not skipped, cluster netlist contain valid information, so
460460
// we can print the resource usage and device utilization
461-
if (vpr_setup.PackerOpts.doPacking != STAGE_SKIP) {
461+
if (vpr_setup.PackerOpts.doPacking != e_stage_action::SKIP) {
462462
float target_device_utilization = vpr_setup.PackerOpts.target_device_utilization;
463463
// Print the number of resources in netlist and number of resources available in architecture
464464
print_resource_usage();
@@ -482,7 +482,7 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
482482
}
483483

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

642642
bool status = true;
643643

644-
if (packer_opts.doPacking == STAGE_SKIP) {
644+
if (packer_opts.doPacking == e_stage_action::SKIP) {
645645
//pass
646646
} else {
647-
if (packer_opts.doPacking == STAGE_DO) {
647+
if (packer_opts.doPacking == e_stage_action::DO) {
648648
//Do the actual packing
649649
status = vpr_pack(vpr_setup, arch);
650650
if (!status) {
@@ -658,7 +658,7 @@ bool vpr_pack_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {
658658
//Load the result from the .net file
659659
vpr_load_packing(vpr_setup, arch);
660660
} else {
661-
VTR_ASSERT(packer_opts.doPacking == STAGE_LOAD);
661+
VTR_ASSERT(packer_opts.doPacking == e_stage_action::LOAD);
662662

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

801801
// if running placement, use the fix clusters file produced by the legalizer
802-
if (vpr_setup.PlacerOpts.doPlacement) {
802+
if (vpr_setup.PlacerOpts.doPlacement != e_stage_action::SKIP) {
803803
vpr_setup.PlacerOpts.constraints_file = vpr_setup.FileNameOpts.write_constraints_file;
804804
}
805805
return true;
@@ -811,15 +811,15 @@ bool vpr_place_flow(const Netlist<>& net_list,
811811
VTR_LOG("\n");
812812
const auto& placer_opts = vpr_setup.PlacerOpts;
813813
const auto& filename_opts = vpr_setup.FileNameOpts;
814-
if (placer_opts.doPlacement == STAGE_SKIP) {
814+
if (placer_opts.doPlacement == e_stage_action::SKIP) {
815815
//pass
816816
} else {
817-
if (placer_opts.doPlacement == STAGE_DO) {
817+
if (placer_opts.doPlacement == e_stage_action::DO) {
818818
//Do the actual placement
819819
vpr_place(net_list, vpr_setup, arch);
820820

821821
} else {
822-
VTR_ASSERT(placer_opts.doPlacement == STAGE_LOAD);
822+
VTR_ASSERT(placer_opts.doPlacement == e_stage_action::LOAD);
823823

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

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

978-
if (router_opts.doRouting == STAGE_DO) {
978+
if (router_opts.doRouting == e_stage_action::DO) {
979979
//Do the actual routing
980980
if (NO_FIXED_CHANNEL_WIDTH == chan_width) {
981981
//Find minimum channel width
@@ -991,7 +991,7 @@ RouteStatus vpr_route_flow(const Netlist<>& net_list,
991991
filename_opts.RouteFile.c_str(),
992992
is_flat);
993993
} else {
994-
VTR_ASSERT(router_opts.doRouting == STAGE_LOAD);
994+
VTR_ASSERT(router_opts.doRouting == e_stage_action::LOAD);
995995
//Load a previous routing
996996
//if the previous load file is generated using flat routing,
997997
//we need to create rr_graph with is_flat flag to add additional
@@ -1312,7 +1312,7 @@ void vpr_free_vpr_data_structures(t_arch& Arch,
13121312
void vpr_free_all(t_arch& Arch,
13131313
t_vpr_setup& vpr_setup) {
13141314
free_rr_graph();
1315-
if (vpr_setup.RouterOpts.doRouting) {
1315+
if (vpr_setup.RouterOpts.doRouting != e_stage_action::SKIP) {
13161316
free_route_structs();
13171317
}
13181318
vpr_free_vpr_data_structures(Arch, vpr_setup);
@@ -1414,12 +1414,12 @@ bool vpr_analysis_flow(const Netlist<>& net_list,
14141414
bool is_flat) {
14151415
auto& analysis_opts = vpr_setup.AnalysisOpts;
14161416

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

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

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

14251425
if (!route_status.success()) {

vpr/src/base/vpr_types.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,28 @@ struct t_netlist_opts {
691691
int netlist_verbosity = 1; ///<Verbose output during netlist cleaning
692692
};
693693

694-
///@brief Should a stage in the CAD flow be skipped, loaded from a file, or performed
695-
enum e_stage_action {
696-
STAGE_SKIP = 0,
697-
STAGE_LOAD,
698-
STAGE_DO,
699-
STAGE_AUTO
694+
/**
695+
* @brief Specifies the action to take for a CAD flow stage.
696+
*
697+
* @details
698+
* SKIP - Do not perform this algorithm at all (End flow early).
699+
* LOAD - Load previous result from file.
700+
* DO - Run the specified algorithm.
701+
* SKIP_IF_PRIOR_FAIL - Run the specified algorithm if possible.
702+
* Currently used to avoid analysis if we don't succeed at routing.
703+
*/
704+
enum class e_stage_action {
705+
SKIP = 0,
706+
LOAD,
707+
DO,
708+
SKIP_IF_PRIOR_FAIL,
709+
NUM_STAGE_ACTIONS
700710
};
701711

712+
///@brief String representations of e_stage_action
713+
constexpr vtr::array<e_stage_action, const char*, (size_t)e_stage_action::NUM_STAGE_ACTIONS> stage_action_strings{
714+
"DISABLED", "LOAD", "ENABLED", "SKIP IF PRIOR FAIL"};
715+
702716
/**
703717
* @brief Options for packing
704718
*

0 commit comments

Comments
 (0)