Skip to content

Commit 05e2917

Browse files
Merge branch 'master' into reconstruction_from_flat_placement_dicrepancy_debugging
2 parents 6664fcb + 4c81b1d commit 05e2917

File tree

65 files changed

+606
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+606
-405
lines changed

.github/workflows/nightly_test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ on:
2222
# - '**.md'
2323
# - '**.rst'
2424
workflow_dispatch:
25-
schedule:
26-
- cron: '0 0 * * *' # daily
2725

2826
# We want to cancel previous runs for a given PR or branch / ref if another CI
2927
# run is requested.

.github/workflows/nightly_test_manual.yml

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ name: NightlyTestManual
44
on:
55
workflow_dispatch:
66

7+
# Automatically runs every Sunday 5 AM UTC.
8+
# Results should be ready ~15 hours later (Sunday 8 PM UTC), on time for Monday mornings.
9+
schedule:
10+
- cron: '0 5 * * 0'
11+
712
# We want to cancel previous runs for a given PR or branch / ref if another CI
813
# run is requested.
914
# See: https://docs.github.com/en/actions/using-jobs/using-concurrency
@@ -57,15 +62,38 @@ jobs:
5762
# Run all of the nightly tests.
5863
# TODO: We could expose more parallelism if we had one task list which ran
5964
# all of these.
60-
- name: 'Run Nightly Tests'
65+
- name: 'Run Nightly Test 1'
66+
run: |
67+
source .venv/bin/activate
68+
./run_reg_test.py -j12 vtr_reg_nightly_test1
69+
70+
- name: 'Run Nightly Test 2'
71+
run: |
72+
source .venv/bin/activate
73+
./run_reg_test.py -j12 vtr_reg_nightly_test2
74+
75+
- name: 'Run Nightly Test 3'
6176
run: |
6277
source .venv/bin/activate
63-
./run_reg_test.py -j12 \
64-
vtr_reg_nightly_test1 \
65-
vtr_reg_nightly_test2 \
66-
vtr_reg_nightly_test3 \
67-
vtr_reg_nightly_test4 \
68-
vtr_reg_nightly_test5 \
69-
vtr_reg_nightly_test6 \
70-
vtr_reg_nightly_test7
78+
./run_reg_test.py -j12 vtr_reg_nightly_test3
79+
7180
81+
- name: 'Run Nightly Test 4'
82+
run: |
83+
source .venv/bin/activate
84+
./run_reg_test.py -j12 vtr_reg_nightly_test4
85+
86+
- name: 'Run Nightly Test 5'
87+
run: |
88+
source .venv/bin/activate
89+
./run_reg_test.py -j12 vtr_reg_nightly_test5
90+
91+
- name: 'Run Nightly Test 6'
92+
run: |
93+
source .venv/bin/activate
94+
./run_reg_test.py -j12 vtr_reg_nightly_test6
95+
96+
- name: 'Run Nightly Test 7'
97+
run: |
98+
source .venv/bin/activate
99+
./run_reg_test.py -j12 vtr_reg_nightly_test7

vpr/src/analytical_place/full_legalizer.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,13 @@ class APClusterPlacer {
101101
private:
102102
// Get the macro for the given cluster block.
103103
t_pl_macro get_macro(ClusterBlockId clb_blk_id) {
104-
const auto& place_macros = g_vpr_ctx.placement().blk_loc_registry().place_macros();
105104
// Basically stolen from initial_placement.cpp:place_one_block
106105
// TODO: Make this a cleaner interface and share the code.
107-
int imacro = place_macros.get_imacro_from_iblk(clb_blk_id);
106+
int imacro = place_macros_.get_imacro_from_iblk(clb_blk_id);
108107

109108
// If this block is part of a macro, return it.
110109
if (imacro != -1) {
111-
return place_macros[imacro];
110+
return place_macros_[imacro];
112111
}
113112
// If not, create a "fake" macro with a single element.
114113
t_pl_macro_member macro_member;
@@ -121,20 +120,22 @@ class APClusterPlacer {
121120
return pl_macro;
122121
}
123122

123+
const PlaceMacros& place_macros_;
124+
124125
public:
125126
/**
126127
* @brief Constructor for the APClusterPlacer
127128
*
128129
* Initializes internal and global state necessary to place clusters on the
129130
* FPGA device.
130131
*/
131-
APClusterPlacer() {
132+
APClusterPlacer(const PlaceMacros& place_macros)
133+
: place_macros_(place_macros) {
132134
// FIXME: This was stolen from place/place.cpp
133135
// it used a static method, just taking what I think I will need.
134136
auto& blk_loc_registry = g_vpr_ctx.mutable_placement().mutable_blk_loc_registry();
135-
const auto& directs = g_vpr_ctx.device().arch->directs;
136137

137-
init_placement_context(blk_loc_registry, directs);
138+
init_placement_context(blk_loc_registry);
138139

139140
// stolen from place/place.cpp:alloc_and_load_try_swap_structs
140141
// FIXME: set cube_bb to false by hand, should be passed in.
@@ -149,7 +150,7 @@ class APClusterPlacer {
149150
blk_loc_registry.clear_all_grid_locs();
150151

151152
// Deal with the placement constraints.
152-
propagate_place_constraints(blk_loc_registry.place_macros());
153+
propagate_place_constraints(place_macros_);
153154

154155
mark_fixed_blocks(blk_loc_registry);
155156

@@ -384,6 +385,7 @@ void NaiveFullLegalizer::create_clusters(const PartialPlacement& p_placement) {
384385
}
385386

386387
void NaiveFullLegalizer::place_clusters(const ClusteredNetlist& clb_nlist,
388+
const PlaceMacros& place_macros,
387389
const PartialPlacement& p_placement) {
388390
// PLACING:
389391
// Create a lookup from the AtomBlockId to the APBlockId
@@ -405,7 +407,7 @@ void NaiveFullLegalizer::place_clusters(const ClusteredNetlist& clb_nlist,
405407
// Move the clusters to where they want to be first.
406408
// TODO: The fixed clusters should probably be moved first for legality
407409
// reasons.
408-
APClusterPlacer ap_cluster_placer;
410+
APClusterPlacer ap_cluster_placer(place_macros);
409411
std::vector<ClusterBlockId> unplaced_clusters;
410412
for (ClusterBlockId cluster_blk_id : clb_nlist.blocks()) {
411413
// Assume that the cluster will always want to be placed wherever the
@@ -466,8 +468,18 @@ void NaiveFullLegalizer::legalize(const PartialPlacement& p_placement) {
466468
// TODO: Eventually should be returned from the create_clusters method.
467469
const ClusteredNetlist& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
468470

471+
// Alloc and load the placement macros.
472+
VTR_ASSERT(!g_vpr_ctx.placement().place_macros);
473+
g_vpr_ctx.mutable_placement().place_macros = std::make_unique<PlaceMacros>(g_vpr_ctx.device().arch->directs,
474+
g_vpr_ctx.device().physical_tile_types,
475+
g_vpr_ctx.clustering().clb_nlist,
476+
g_vpr_ctx.atom().nlist,
477+
g_vpr_ctx.atom().lookup);
478+
479+
const PlaceMacros& place_macros = *g_vpr_ctx.placement().place_macros;
480+
469481
// Place the clusters based on where the atoms want to be placed.
470-
place_clusters(clb_nlist, p_placement);
482+
place_clusters(clb_nlist, place_macros, p_placement);
471483

472484
// Verify that the placement created by the full legalizer is valid.
473485
unsigned num_placement_errors = verify_placement(g_vpr_ctx);

vpr/src/analytical_place/full_legalizer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class AtomNetlist;
1919
class ClusteredNetlist;
2020
class DeviceGrid;
2121
class PartialPlacement;
22+
class PlaceMacros;
2223
class Prepacker;
2324
struct t_arch;
2425
struct t_logical_block_type;
@@ -125,6 +126,7 @@ class NaiveFullLegalizer : public FullLegalizer {
125126
* placement.
126127
*/
127128
void place_clusters(const ClusteredNetlist& clb_nlist,
129+
const PlaceMacros& place_macros,
128130
const PartialPlacement& p_placement);
129131

130132
};

vpr/src/base/blk_loc_registry.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ int BlkLocRegistry::net_pin_to_tile_pin_index(const ClusterNetId net_id, int net
4545
return this->tile_pin_index(pin_id);
4646
}
4747

48-
const PlaceMacros& BlkLocRegistry::place_macros() const {
49-
return place_macros_;
50-
}
51-
52-
PlaceMacros& BlkLocRegistry::mutable_place_macros() {
53-
return place_macros_;
54-
}
55-
5648
void BlkLocRegistry::set_block_location(ClusterBlockId blk_id, const t_pl_loc& location) {
5749
const auto& device_ctx = g_vpr_ctx.device();
5850
const auto& cluster_ctx = g_vpr_ctx.clustering();
@@ -289,3 +281,4 @@ t_physical_tile_loc BlkLocRegistry::get_coordinate_of_pin(ClusterPinId pin) cons
289281

290282
return tile_loc;
291283
}
284+

vpr/src/base/blk_loc_registry.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "vtr_vector_map.h"
66
#include "vpr_types.h"
77
#include "grid_block.h"
8-
#include "place_macro.h"
98

109
struct t_block_loc;
1110
struct t_pl_blocks_to_be_moved;
@@ -37,13 +36,6 @@ class BlkLocRegistry {
3736
///@brief Clustered pin placement mapping with physical pin
3837
vtr::vector_map<ClusterPinId, int> physical_pins_;
3938

40-
/**
41-
* @brief Contains information about placement macros.
42-
* A placement macro is a set of clustered blocks that must be placed
43-
* in a way that is compliant with relative locations specified by the macro.
44-
*/
45-
PlaceMacros place_macros_;
46-
4739
/// @brief Stores ClusterBlockId of all movable clustered blocks
4840
/// (blocks that are not locked down to a single location)
4941
std::vector<ClusterBlockId> movable_blocks_;
@@ -67,12 +59,6 @@ class BlkLocRegistry {
6759
///@brief Returns the physical pin of the tile, related to the given ClusterNedId, and the net pin index.
6860
int net_pin_to_tile_pin_index(const ClusterNetId net_id, int net_pin_index) const;
6961

70-
///@brief Returns a constant reference to placement macros.
71-
const PlaceMacros& place_macros() const;
72-
73-
///@brief Returns a mutable reference to placement macros.
74-
PlaceMacros& mutable_place_macros();
75-
7662
/// @brief Returns a constant reference to the vector of ClusterBlockIds of all movable clustered blocks.
7763
const std::vector<ClusterBlockId>& movable_blocks() const { return movable_blocks_; }
7864

@@ -170,3 +156,4 @@ class BlkLocRegistry {
170156

171157
e_expected_transaction expected_transaction_;
172158
};
159+

vpr/src/base/place_and_route.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <algorithm>
66

77
#include "FlatPlacementInfo.h"
8+
#include "place_macro.h"
89
#include "vtr_assert.h"
910
#include "vtr_log.h"
1011

vpr/src/base/vpr_api.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
#include <cstdio>
1515
#include <cstring>
1616
#include <cmath>
17+
#include <memory>
18+
#include <vector>
1719

1820
#include "FlatPlacementInfo.h"
1921
#include "cluster_util.h"
22+
#include "physical_types.h"
23+
#include "place_macro.h"
2024
#include "verify_placement.h"
2125
#include "vpr_context.h"
2226
#include "vtr_assert.h"
@@ -741,7 +745,9 @@ bool vpr_load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
741745
return true;
742746
}
743747

744-
bool vpr_place_flow(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_arch& arch) {
748+
bool vpr_place_flow(const Netlist<>& net_list,
749+
t_vpr_setup& vpr_setup,
750+
const t_arch& arch) {
745751
VTR_LOG("\n");
746752
const auto& placer_opts = vpr_setup.PlacerOpts;
747753
const auto& filename_opts = vpr_setup.FileNameOpts;
@@ -756,7 +762,7 @@ bool vpr_place_flow(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_a
756762
VTR_ASSERT(placer_opts.doPlacement == STAGE_LOAD);
757763

758764
//Load a previous placement
759-
vpr_load_placement(vpr_setup, arch);
765+
vpr_load_placement(vpr_setup, arch.directs);
760766
}
761767

762768
post_place_sync();
@@ -781,7 +787,9 @@ bool vpr_place_flow(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_a
781787
return true;
782788
}
783789

784-
void vpr_place(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_arch& arch) {
790+
void vpr_place(const Netlist<>& net_list,
791+
t_vpr_setup& vpr_setup,
792+
const t_arch& arch) {
785793
bool is_flat = false;
786794
if (vpr_setup.PlacerOpts.place_algorithm.is_timing_driven()) {
787795
// Prime lookahead cache to avoid adding lookahead computation cost to
@@ -828,7 +836,8 @@ void vpr_place(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_arch&
828836
block_locs);
829837
}
830838

831-
void vpr_load_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
839+
void vpr_load_placement(t_vpr_setup& vpr_setup,
840+
const std::vector<t_direct_inf> directs) {
832841
vtr::ScopedStartFinishTimer timer("Load Placement");
833842

834843
const auto& device_ctx = g_vpr_ctx.device();
@@ -837,7 +846,14 @@ void vpr_load_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
837846
const auto& filename_opts = vpr_setup.FileNameOpts;
838847

839848
//Initialize placement data structures, which will be filled when loading placement
840-
init_placement_context(blk_loc_registry, arch.directs);
849+
init_placement_context(blk_loc_registry);
850+
851+
// Alloc and load the placement macros.
852+
place_ctx.place_macros = std::make_unique<PlaceMacros>(directs,
853+
device_ctx.physical_tile_types,
854+
g_vpr_ctx.clustering().clb_nlist,
855+
g_vpr_ctx.atom().nlist,
856+
g_vpr_ctx.atom().lookup);
841857

842858
//Load an existing placement from a file
843859
place_ctx.placement_id = read_place(filename_opts.NetFile.c_str(), filename_opts.PlaceFile.c_str(),

vpr/src/base/vpr_api.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,18 @@ bool vpr_load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch);
7171
/* Placement */
7272

7373
///@brief Perform, load or skip the placement stage
74-
bool vpr_place_flow(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_arch& arch);
74+
bool vpr_place_flow(const Netlist<>& net_list,
75+
t_vpr_setup& vpr_setup,
76+
const t_arch& arch);
7577

7678
///@brief Perform placement
77-
void vpr_place(const Netlist<>& net_list, t_vpr_setup& vpr_setup, const t_arch& arch);
79+
void vpr_place(const Netlist<>& net_list,
80+
t_vpr_setup& vpr_setup,
81+
const t_arch& arch);
7882

7983
///@brief Loads a previous placement
80-
void vpr_load_placement(t_vpr_setup& vpr_setup, const t_arch& arch);
84+
void vpr_load_placement(t_vpr_setup& vpr_setup,
85+
const std::vector<t_direct_inf> directs);
8186

8287
/* Routing */
8388

vpr/src/base/vpr_context.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <mutex>
77

88
#include "FlatPlacementInfo.h"
9+
#include "place_macro.h"
910
#include "user_place_constraints.h"
1011
#include "user_route_constraints.h"
1112
#include "vpr_types.h"
@@ -362,6 +363,16 @@ struct PlacementContext : public Context {
362363
*/
363364
void unlock_loc_vars() { VTR_ASSERT_SAFE(!loc_vars_are_accessible_); loc_vars_are_accessible_ = true; }
364365

366+
/**
367+
* @brief Collection of all the placement macros in the netlist. A placement
368+
* macro is a set of clustered blocks that must be placed in a way
369+
* that is compliant with relative locations specified by the macro.
370+
* Macros are used during placement and are not modified after they
371+
* are created.
372+
* This is created at the start of placement.
373+
*/
374+
std::unique_ptr<PlaceMacros> place_macros;
375+
365376
/**
366377
* @brief Compressed grid space for each block type
367378
*

vpr/src/draw/draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry) {
569569
draw_state->draw_rr_node[inode].node_highlighted = false;
570570
}
571571
}
572-
draw_coords->tile_width = clb_width;
572+
draw_coords->set_tile_width(clb_width);
573573
draw_coords->pin_size = 0.3;
574574
for (const auto& type : device_ctx.physical_tile_types) {
575575
auto num_pins = type.num_pins;

vpr/src/draw/draw_basic.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,9 @@ void draw_placement_macros(ezgl::renderer* g) {
776776
t_draw_coords* draw_coords = get_draw_coords_vars();
777777

778778
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
779-
const auto& place_macros = draw_state->get_graphics_blk_loc_registry_ref().place_macros();
779+
780+
VTR_ASSERT(g_vpr_ctx.placement().place_macros);
781+
const PlaceMacros& place_macros = *g_vpr_ctx.placement().place_macros;
780782

781783
for (const t_pl_macro& pl_macro : place_macros.macros()) {
782784

vpr/src/draw/draw_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ struct t_draw_coords {
410410
///@brief constructor
411411
t_draw_coords();
412412

413+
///@brief Sets the tile width
414+
inline void set_tile_width(float new_tile_width) {
415+
tile_width = new_tile_width;
416+
}
417+
413418
///@brief returns tile width
414419
float get_tile_width();
415420

0 commit comments

Comments
 (0)