Skip to content

Commit

Permalink
Add flat version of sync_netlists_to_routing
Browse files Browse the repository at this point in the history
  • Loading branch information
duck2 committed Aug 15, 2024
1 parent 21d0150 commit 7ba4dd1
Show file tree
Hide file tree
Showing 13 changed files with 453 additions and 81 deletions.
14 changes: 3 additions & 11 deletions utils/fasm/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ using namespace std;
#include "fasm.h"

#include "post_routing_pb_pin_fixup.h"
#include "sync_netlists_to_routing_flat.h"

/*
* Exit codes to signal success/failure to scripts
Expand Down Expand Up @@ -86,15 +87,7 @@ int main(int argc, const char **argv) {
bool is_flat = vpr_setup.RouterOpts.flat_routing;
if (flow_succeeded) {
if(is_flat) {
sync_netlists_to_routing((const Netlist<>&) g_vpr_ctx.atom().nlist,
g_vpr_ctx.device(),
g_vpr_ctx.mutable_atom(),
g_vpr_ctx.atom().lookup,
g_vpr_ctx.mutable_clustering(),
g_vpr_ctx.placement(),
g_vpr_ctx.routing(),
vpr_setup.PackerOpts.pack_verbosity > 2,
is_flat);
sync_netlists_to_routing_flat();
} else {
sync_netlists_to_routing((const Netlist<>&) g_vpr_ctx.clustering().clb_nlist,
g_vpr_ctx.device(),
Expand All @@ -103,8 +96,7 @@ int main(int argc, const char **argv) {
g_vpr_ctx.mutable_clustering(),
g_vpr_ctx.placement(),
g_vpr_ctx.routing(),
vpr_setup.PackerOpts.pack_verbosity > 2,
is_flat);
vpr_setup.PackerOpts.pack_verbosity > 2);
}
}

Expand Down
25 changes: 15 additions & 10 deletions utils/fasm/test/test_fasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
#include "fasm_utils.h"
#include "arch_util.h"
#include "rr_graph_writer.h"
#include "post_routing_pb_pin_fixup.h"
#include <sstream>
#include <fstream>
#include <regex>
#include <cmath>
#include <algorithm>

#include "post_routing_pb_pin_fixup.h"
#include "sync_netlists_to_routing_flat.h"

static constexpr const char kArchFile[] = "test_fasm_arch.xml";
static constexpr const char kRrGraphFile[] = "test_fasm_rrgraph.xml";

Expand Down Expand Up @@ -327,15 +329,18 @@ TEST_CASE("fasm_integration_test", "[fasm]") {
/* Sync netlist to the actual routing (necessary if there are block
ports with equivalent pins) */
if (flow_succeeded) {
sync_netlists_to_routing((const Netlist<>&) g_vpr_ctx.clustering().clb_nlist,
g_vpr_ctx.device(),
g_vpr_ctx.mutable_atom(),
g_vpr_ctx.atom().lookup,
g_vpr_ctx.mutable_clustering(),
g_vpr_ctx.placement(),
g_vpr_ctx.routing(),
vpr_setup.PackerOpts.pack_verbosity > 2,
is_flat);
if (is_flat) {
sync_netlists_to_routing_flat();
} else {
sync_netlists_to_routing((const Netlist<>&) g_vpr_ctx.clustering().clb_nlist,
g_vpr_ctx.device(),
g_vpr_ctx.mutable_atom(),
g_vpr_ctx.atom().lookup,
g_vpr_ctx.mutable_clustering(),
g_vpr_ctx.placement(),
g_vpr_ctx.routing(),
vpr_setup.PackerOpts.pack_verbosity > 2);
}
}

std::stringstream fasm_string;
Expand Down
1 change: 0 additions & 1 deletion vpr/src/base/atom_lookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ ClusterNetId AtomLookup::clb_net(const AtomNetId net_id) const {
}

void AtomLookup::set_atom_clb_net(const AtomNetId net_id, const ClusterNetId clb_net_index) {
VTR_ASSERT(net_id);
//If either are invalid remove any mapping
if (!net_id && clb_net_index != ClusterNetId::INVALID()) {
//Remove
Expand Down
27 changes: 14 additions & 13 deletions vpr/src/base/vpr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#include "arch_util.h"

#include "post_routing_pb_pin_fixup.h"

#include "sync_netlists_to_routing_flat.h"

#include "load_flat_place.h"

Expand Down Expand Up @@ -1434,27 +1434,28 @@ bool vpr_analysis_flow(const Netlist<>& net_list,
* - Turn on verbose output when users require verbose output
* for packer (default verbosity is set to 2 for compact logs)
*/
if (!is_flat) {
if (route_status.success()) {
if (route_status.success()) {
if (is_flat) {
sync_netlists_to_routing_flat();
} else {
sync_netlists_to_routing(net_list,
g_vpr_ctx.device(),
g_vpr_ctx.mutable_atom(),
g_vpr_ctx.atom().lookup,
g_vpr_ctx.mutable_clustering(),
g_vpr_ctx.placement(),
g_vpr_ctx.routing(),
vpr_setup.PackerOpts.pack_verbosity > 2,
is_flat);

std::string post_routing_packing_output_file_name = vpr_setup.PackerOpts.output_file + ".post_routing";
write_packing_results_to_xml(vpr_setup.PackerOpts.global_clocks,
Arch.architecture_id,
post_routing_packing_output_file_name.c_str());
} else {
VTR_LOG_WARN("Synchronization between packing and routing results is not applied due to illegal circuit implementation\n");
vpr_setup.PackerOpts.pack_verbosity > 2);
}
VTR_LOG("\n");

std::string post_routing_packing_output_file_name = vpr_setup.PackerOpts.output_file + ".post_routing";
write_packing_results_to_xml(vpr_setup.PackerOpts.global_clocks,
Arch.architecture_id,
post_routing_packing_output_file_name.c_str());
} else {
VTR_LOG_WARN("Synchronization between packing and routing results is not applied due to illegal circuit implementation\n");
}
VTR_LOG("\n");

vpr_analysis(net_list,
vpr_setup,
Expand Down
3 changes: 3 additions & 0 deletions vpr/src/base/vpr_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ struct RoutingContext : public Context {
* @brief User specified routing constraints
*/
UserRouteConstraints constraints;

/** Is flat routing enabled? */
bool is_flat;
};

/**
Expand Down
34 changes: 8 additions & 26 deletions vpr/src/pack/post_routing_pb_pin_fixup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ static void update_cluster_pin_with_post_routing_results(const Netlist<>& net_li
const AtomContext& atom_ctx,
const DeviceContext& device_ctx,
ClusteringContext& clustering_ctx,
const vtr::vector<RRNodeId, ParentNetId>& rr_node_nets,
const vtr::vector<RRNodeId, ClusterNetId>& rr_node_nets,
const t_pl_loc& grid_coord,
const ClusterBlockId& blk_id,
size_t& num_mismatches,
const bool& verbose,
bool is_flat) {
const bool& verbose) {
const int sub_tile_z = grid_coord.sub_tile;
const int coord_x = grid_coord.x;
const int coord_y = grid_coord.y;
Expand Down Expand Up @@ -210,15 +209,7 @@ static void update_cluster_pin_with_post_routing_results(const Netlist<>& net_li
continue;
}

ClusterNetId cluster_equivalent_net_id = ClusterNetId::INVALID();
if (is_flat) {
cluster_equivalent_net_id = atom_ctx.lookup.clb_net(convert_to_atom_net_id(routing_net_id));
if (routing_net_id != ParentNetId::INVALID()) {
VTR_ASSERT(cluster_equivalent_net_id != ClusterNetId::INVALID());
}
} else {
cluster_equivalent_net_id = convert_to_cluster_net_id(routing_net_id);
}
ClusterNetId cluster_equivalent_net_id = convert_to_cluster_net_id(routing_net_id);

/* If the net from the routing results matches the net from the packing results,
* nothing to be changed. Move on to the next net.
Expand Down Expand Up @@ -1050,20 +1041,17 @@ void sync_netlists_to_routing(const Netlist<>& net_list,
ClusteringContext& clustering_ctx,
const PlacementContext& placement_ctx,
const RoutingContext& routing_ctx,
const bool& verbose,
bool is_flat) {
const bool& verbose) {
vtr::ScopedStartFinishTimer timer("Synchronize the packed netlist to routing optimization");

/* Reset the database for post-routing clb net mapping */
clustering_ctx.post_routing_clb_pin_nets.clear();
clustering_ctx.pre_routing_net_pin_mapping.clear();

/* Create net-to-rr_node mapping */
vtr::vector<RRNodeId, ParentNetId> rr_node_nets = annotate_rr_node_nets(net_list,
vtr::vector<RRNodeId, ClusterNetId> rr_node_nets = annotate_rr_node_nets(clustering_ctx,
device_ctx,
routing_ctx,
verbose,
is_flat);
verbose);

IntraLbPbPinLookup intra_lb_pb_pin_lookup(device_ctx.logical_block_types);

Expand All @@ -1076,12 +1064,7 @@ void sync_netlists_to_routing(const Netlist<>& net_list,
/* Update the core logic (center blocks of the FPGA) */
for (const ParentBlockId& blk_id : net_list.blocks()) {
/* We know the entrance to grid info and mapping results, do the fix-up for this block */
ClusterBlockId clb_blk_id;
if (is_flat) {
clb_blk_id = atom_look_up.atom_clb(convert_to_atom_block_id(blk_id));
} else {
clb_blk_id = convert_to_cluster_block_id(blk_id);
}
ClusterBlockId clb_blk_id = convert_to_cluster_block_id(blk_id);
VTR_ASSERT(clb_blk_id != ClusterBlockId::INVALID());

if (seen_block_ids.insert(clb_blk_id).second) {
Expand All @@ -1093,8 +1076,7 @@ void sync_netlists_to_routing(const Netlist<>& net_list,
placement_ctx.block_locs[clb_blk_id].loc,
clb_blk_id,
num_mismatches,
verbose,
is_flat);
verbose);

update_cluster_routing_traces_with_post_routing_results(atom_ctx,
intra_lb_pb_pin_lookup,
Expand Down
3 changes: 1 addition & 2 deletions vpr/src/pack/post_routing_pb_pin_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ void sync_netlists_to_routing(const Netlist<>& net_list,
ClusteringContext& clustering_ctx,
const PlacementContext& placement_ctx,
const RoutingContext& routing_ctx,
const bool& verbose,
bool is_flat);
const bool& verbose);

#endif
Loading

0 comments on commit 7ba4dd1

Please sign in to comment.