Skip to content

Commit 13f37a6

Browse files
Merge pull request #2746 from AlexandreSinger/feature-ap-flow-upstreaming
[AP] Added AP Flow to VPR
2 parents b9760a9 + 7219c18 commit 13f37a6

File tree

17 files changed

+187
-11
lines changed

17 files changed

+187
-11
lines changed

doc/src/arch/reference.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ The valid tags within the ``<layout>`` tag are:
158158

159159
.. note:: At most one ``<auto_layout>`` can be specified.
160160

161+
.. _fixed_arch_grid_layout:
162+
161163
.. arch:tag:: <fixed_layout name="string" width="int" height="int">
162164
163165
:req_param name:

doc/src/vpr/command_line_usage.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ VPR runs all stages of (pack, place, route, and analysis) if none of :option:`--
8282

8383
**Default:** ``off``
8484

85+
.. option:: --analytical_place
86+
87+
Run the analytical placement flow.
88+
This flows uses an integrated packing and placement algorithm which uses information from the primitive level to improve clustering and placement;
89+
as such, the :option:`--pack` and :option:`--place` options should not be set when this option is set.
90+
This flow requires that the device has a fixed size and some of the primitive blocks are fixed somewhere on the device grid.
91+
92+
.. seealso:: See :ref:`Fixed FPGA Grid Layout <fixed_arch_grid_layout>` and :option:`--device` for how to fix the device size.
93+
94+
.. seealso:: See :ref:`VPR Placement Constraints <placement_constraints>` for how to fix primitive blocks in a design to the device grid.
95+
96+
.. warning::
97+
98+
This analytical placement flow is experimental and under active development.
99+
100+
**Default:** ``off``
101+
85102
.. option:: --route
86103

87104
Run routing stage

libs/libvtrutil/src/vpr_error.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ enum e_vpr_error {
1414
VPR_ERROR_ARCH,
1515
VPR_ERROR_PACK,
1616
VPR_ERROR_PLACE,
17+
VPR_ERROR_AP,
1718
VPR_ERROR_ROUTE,
1819
VPR_ERROR_TIMING,
1920
VPR_ERROR_POWER,
2021
VPR_ERROR_SDC,
2122

2223
// File parsing errors
2324
VPR_ERROR_NET_F, // Error while parsing the packed netlist file
24-
VPR_ERROR_PLACE_F, // Error while parsning the placement file
25+
VPR_ERROR_PLACE_F, // Error while parsing the placement file
2526
VPR_ERROR_BLIF_F, // Error while parsing the blif file
2627
VPR_ERROR_IC_NETLIST_F, // Error while parsing the interchange netlist file
2728

utils/fasm/src/main.cpp

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

75-
vpr_setup.PackerOpts.doPacking = STAGE_LOAD;
76-
vpr_setup.PlacerOpts.doPlacement = STAGE_LOAD;
77-
vpr_setup.RouterOpts.doRouting = STAGE_LOAD;
75+
vpr_setup.PackerOpts.doPacking = STAGE_LOAD;
76+
vpr_setup.PlacerOpts.doPlacement = STAGE_LOAD;
77+
vpr_setup.APOpts.doAP = STAGE_SKIP;
78+
vpr_setup.RouterOpts.doRouting = STAGE_LOAD;
7879
vpr_setup.RouterOpts.read_rr_edge_metadata = true;
79-
vpr_setup.AnalysisOpts.doAnalysis = STAGE_SKIP;
80+
vpr_setup.AnalysisOpts.doAnalysis = STAGE_SKIP;
8081

8182
bool flow_succeeded = false;
8283
flow_succeeded = vpr_flow(vpr_setup, Arch);

utils/fasm/test/test_fasm.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +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.RouterOpts.doRouting = STAGE_LOAD;
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;
321322
vpr_setup.RouterOpts.read_rr_edge_metadata = true;
322-
vpr_setup.AnalysisOpts.doAnalysis = STAGE_SKIP;
323+
vpr_setup.AnalysisOpts.doAnalysis = STAGE_SKIP;
323324

324325
bool flow_succeeded = vpr_flow(vpr_setup, arch);
325326
REQUIRE(flow_succeeded == true);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @file
3+
* @author Alex Singer
4+
* @date September 2024
5+
* @brief Implementation of the Analytical Placement flow.
6+
*/
7+
8+
#include "analytical_placement_flow.h"
9+
#include "atom_netlist.h"
10+
#include "globals.h"
11+
#include "prepack.h"
12+
#include "vpr_context.h"
13+
#include "vpr_error.h"
14+
#include "vpr_types.h"
15+
#include "vtr_time.h"
16+
17+
void run_analytical_placement_flow(t_vpr_setup& vpr_setup) {
18+
(void)vpr_setup;
19+
// Start an overall timer for the Analytical Placement flow.
20+
vtr::ScopedStartFinishTimer timer("Analytical Placement Flow");
21+
22+
// The global state used/modified by this flow.
23+
const AtomNetlist& atom_nlist = g_vpr_ctx.atom().nlist;
24+
const DeviceContext& device_ctx = g_vpr_ctx.device();
25+
26+
// Run the prepacker
27+
Prepacker prepacker;
28+
prepacker.init(atom_nlist, device_ctx.logical_block_types);
29+
30+
// AP is currently under-construction. Fail gracefully just in case this
31+
// is somehow being called.
32+
VPR_FATAL_ERROR(VPR_ERROR_AP,
33+
"Analytical Placement flow not implemented yet");
34+
}
35+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @file
3+
* @author Alex Singer
4+
* @date September 2024
5+
* @brief Methods for running the Analytical Placement flow.
6+
*/
7+
8+
#pragma once
9+
10+
// Forward declarations
11+
struct t_vpr_setup;
12+
13+
/**
14+
* @brief Run the Analaytical Placement flow.
15+
*
16+
* @param vpr_setup The setup options provided by the user.
17+
*/
18+
void run_analytical_placement_flow(t_vpr_setup& vpr_setup);
19+

vpr/src/base/CheckSetup.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
void CheckSetup(const t_packer_opts& PackerOpts,
1111
const t_placer_opts& PlacerOpts,
12+
const t_ap_opts& APOpts,
1213
const t_router_opts& RouterOpts,
1314
const t_server_opts& ServerOpts,
1415
const t_det_routing_arch& RoutingArch,
@@ -72,6 +73,28 @@ void CheckSetup(const t_packer_opts& PackerOpts,
7273
NUM_PL_MOVE_TYPES);
7374
}
7475

76+
// Rules for doing Analytical Placement
77+
if (APOpts.doAP) {
78+
// Make sure that the --place option was not set.
79+
if (PlacerOpts.doPlacement) {
80+
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
81+
"Cannot perform both analytical and non-analytical placement.\n");
82+
}
83+
// Make sure that the --pack option was not set.
84+
if (PackerOpts.doPacking) {
85+
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
86+
"Analytical placement should skip packing.\n");
87+
}
88+
89+
// TODO: Should check that read_vpr_constraint_file is non-empty or
90+
// check within analytical placement that the floorplanning has
91+
// some fixed blocks somewhere. Maybe we can live without fixed
92+
// blocks.
93+
94+
// TODO: Should we enforce that the size of the device is fixed. This
95+
// goes with ensuring that some blocks are fixed.
96+
}
97+
7598
if (RouterOpts.doRouting) {
7699
if (!Timing.timing_analysis_enabled
77100
&& (DEMAND_ONLY != RouterOpts.base_cost_type && DEMAND_ONLY_NORMALIZED_LENGTH != RouterOpts.base_cost_type)) {

vpr/src/base/CheckSetup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const int DYNAMIC_PORT_RANGE_MAX = 65535;
77

88
void CheckSetup(const t_packer_opts& PackerOpts,
99
const t_placer_opts& PlacerOpts,
10+
const t_ap_opts& APOpts,
1011
const t_router_opts& RouterOpts,
1112
const t_server_opts& ServerOpts,
1213
const t_det_routing_arch& RoutingArch,

vpr/src/base/SetupVPR.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void SetupVPR(const t_options* Options,
9797
t_netlist_opts* NetlistOpts,
9898
t_packer_opts* PackerOpts,
9999
t_placer_opts* PlacerOpts,
100+
t_ap_opts* APOpts,
100101
t_annealing_sched* AnnealSched,
101102
t_router_opts* RouterOpts,
102103
t_analysis_opts* AnalysisOpts,
@@ -244,11 +245,13 @@ void SetupVPR(const t_options* Options,
244245
if (!Options->do_packing
245246
&& !Options->do_legalize
246247
&& !Options->do_placement
248+
&& !Options->do_analytical_placement
247249
&& !Options->do_routing
248250
&& !Options->do_analysis) {
249251
//run all stages if none specified
250252
PackerOpts->doPacking = STAGE_DO;
251253
PlacerOpts->doPlacement = STAGE_DO;
254+
APOpts->doAP = STAGE_SKIP; // AP not default.
252255
RouterOpts->doRouting = STAGE_DO;
253256
AnalysisOpts->doAnalysis = STAGE_AUTO; //Deferred until implementation status known
254257
} else {
@@ -276,6 +279,14 @@ void SetupVPR(const t_options* Options,
276279
PlacerOpts->doPlacement = STAGE_DO;
277280
}
278281

282+
if (Options->do_analytical_placement) {
283+
// In the Analytical Placement flow, packing and placement are
284+
// integrated. Thus, these stages are skipped.
285+
PackerOpts->doPacking = STAGE_SKIP;
286+
PlacerOpts->doPlacement = STAGE_SKIP;
287+
APOpts->doAP = STAGE_DO;
288+
}
289+
279290
if (Options->do_packing) {
280291
PackerOpts->doPacking = STAGE_DO;
281292
}

0 commit comments

Comments
 (0)