Skip to content

Commit c5a844e

Browse files
committed
remove traceback, replace rt_node with RouteTree
1 parent b86ab99 commit c5a844e

Some content is hidden

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

66 files changed

+4222
-3653
lines changed

libs/libvtrutil/src/tl_optional.hpp

Lines changed: 2067 additions & 0 deletions
Large diffs are not rendered by default.

libs/libvtrutil/src/vtr_optional.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
/* std::optional with optional refs.
4+
* currently: import TartanLlama's optional into the vtr namespace
5+
* documentation at https://tl.tartanllama.xyz/en/latest/api/optional.html */
6+
7+
#include "tl_optional.hpp"
8+
9+
namespace vtr {
10+
template<class T>
11+
using optional = tl::optional<T>;
12+
13+
using nullopt_t = tl::nullopt_t;
14+
static constexpr nullopt_t nullopt = tl::nullopt;
15+
16+
using bad_optional_access = tl::bad_optional_access;
17+
}

utils/fasm/src/fasm.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -619,31 +619,29 @@ void FasmWriterVisitor::check_for_lut(const t_pb* atom) {
619619
}
620620

621621
void FasmWriterVisitor::visit_atom_impl(const t_pb* atom) {
622-
check_for_lut(atom);
623-
check_for_param(atom);
622+
check_for_lut(atom);
623+
check_for_param(atom);
624624
}
625625

626-
void FasmWriterVisitor::walk_route_tree(const RRGraphBuilder& rr_graph_builder, const t_rt_node *root) {
627-
for (t_linked_rt_edge* edge = root->u.child_list; edge != nullptr; edge = edge->next) {
628-
auto *meta = vpr::rr_edge_metadata(rr_graph_builder, root->inode, edge->child->inode, edge->iswitch, fasm_features);
626+
void FasmWriterVisitor::walk_route_tree(const RRGraphBuilder& rr_graph_builder, const RouteTreeNode& root) {
627+
for(auto& child: root.child_nodes()){
628+
auto* meta = vpr::rr_edge_metadata(rr_graph_builder, size_t(root.inode), size_t(child.inode), size_t(child.parent_switch), fasm_features);
629+
629630
if(meta != nullptr) {
630631
output_fasm_features(meta->as_string().get(strings_), "", "");
631632
}
632633

633-
walk_route_tree(rr_graph_builder, edge->child);
634+
walk_route_tree(rr_graph_builder, child);
634635
}
635636
}
636637

637638
void FasmWriterVisitor::walk_routing() {
638639
auto& route_ctx = g_vpr_ctx.mutable_routing();
639640
const auto& device_ctx = g_vpr_ctx.device();
640641

641-
for(const auto &trace : route_ctx.trace) {
642-
t_trace *head = trace.head;
643-
if (!head) continue;
644-
t_rt_node* root = traceback_to_route_tree(head, is_flat_);
645-
walk_route_tree(device_ctx.rr_graph_builder, root);
646-
free_route_tree(root);
642+
for(const auto &tree : route_ctx.route_trees) {
643+
if (!tree) continue;
644+
walk_route_tree(device_ctx.rr_graph_builder, tree.value().root);
647645
}
648646
}
649647

utils/fasm/src/fasm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class FasmWriterVisitor : public NetlistVisitor {
7373
void check_for_lut(const t_pb* atom);
7474
void output_fasm_mux(std::string fasm_mux, t_interconnect *interconnect, const t_pb_graph_pin *mux_input_pin);
7575
void walk_routing();
76-
void walk_route_tree(const RRGraphBuilder& rr_graph_builder, const t_rt_node *root);
76+
void walk_route_tree(const RRGraphBuilder& rr_graph_builder, const RouteTreeNode& root);
7777
std::string build_clb_prefix(const t_pb *pb, const t_pb_graph_node* pb_graph_node, bool* is_parent_pb_null) const;
7878
const LutOutputDefinition* find_lut(const t_pb_graph_node* pb_graph_node);
7979
void check_for_param(const t_pb *atom);

utils/fasm/src/main.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,7 @@ int main(int argc, const char **argv) {
120120
(float) (entire_flow_end - entire_flow_begin) / CLOCKS_PER_SEC);
121121

122122
/* free data structures */
123-
if(is_flat) {
124-
vpr_free_all((const Netlist<>&) g_vpr_ctx.atom().nlist, Arch, vpr_setup);
125-
} else {
126-
vpr_free_all((const Netlist<>&) g_vpr_ctx.clustering().clb_nlist, Arch, vpr_setup);
127-
}
123+
vpr_free_all(Arch, vpr_setup);
128124

129125

130126
} catch (const tatum::Error& tatum_error) {

utils/fasm/test/test_fasm.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "catch2/catch_test_macros.hpp"
22
#include "catch2/matchers/catch_matchers_all.hpp"
33

4+
#include "route_common.h"
5+
#include "route_tree_timing.h"
46
#include "vpr_api.h"
57
#include "vtr_util.h"
68
#include "rr_metadata.h"
@@ -23,7 +25,6 @@ namespace {
2325

2426
// ============================================================================
2527

26-
using Catch::Matchers::Equals;
2728
using Catch::Matchers::StartsWith;
2829
using Catch::Matchers::ContainsSubstring;
2930

@@ -296,7 +297,7 @@ TEST_CASE("fasm_integration_test", "[fasm]") {
296297
echo_enabled,
297298
echo_file_name,
298299
is_flat);
299-
vpr_free_all((const Netlist<>&) g_vpr_ctx.clustering().clb_nlist, arch, vpr_setup);
300+
vpr_free_all(arch, vpr_setup);
300301
}
301302

302303
t_vpr_setup vpr_setup;
@@ -586,20 +587,17 @@ TEST_CASE("fasm_integration_test", "[fasm]") {
586587

587588
// Verify routes
588589
const auto & route_ctx = g_vpr_ctx.routing();
589-
for(const auto &trace : route_ctx.trace) {
590-
const t_trace *head = trace.head;
591-
while(head != nullptr) {
592-
const t_trace *next = head->next;
593-
594-
if(next != nullptr && head->iswitch != OPEN) {
595-
const auto next_inode = next->index;
596-
auto iter = routing_edges.find(std::make_tuple(head->index, next_inode, head->iswitch));
590+
for(const auto& root : route_ctx.route_trees) {
591+
if(!root)
592+
continue;
593+
594+
for(auto& rt_node: root.value()) {
595+
for(auto& child_node: rt_node.child_nodes()){
596+
auto iter = routing_edges.find(std::make_tuple(size_t(rt_node.inode), size_t(child_node.inode), size_t(child_node.parent_switch)));
597597
if (iter == routing_edges.end()) {
598-
FAIL_CHECK("source: " << head->index << " sink: " << next_inode << " switch:" << head->iswitch);
598+
FAIL_CHECK("source: " << size_t(rt_node.inode) << " sink: " << size_t(child_node.inode) << " switch:" << size_t(child_node.parent_switch));
599599
}
600600
}
601-
602-
head = next;
603601
}
604602
}
605603

@@ -635,7 +633,7 @@ TEST_CASE("fasm_integration_test", "[fasm]") {
635633
CHECK(found_mux4);
636634

637635

638-
vpr_free_all((const Netlist<>&) g_vpr_ctx.clustering().clb_nlist, arch, vpr_setup);
636+
vpr_free_all(arch, vpr_setup);
639637
}
640638

641639
} // namespace

utils/route_diag/src/main.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void do_one_route(const Netlist<>& net_list,
7474
const auto& rr_graph = device_ctx.rr_graph;
7575
auto& route_ctx = g_vpr_ctx.routing();
7676

77-
t_rt_node* rt_root = init_route_tree_to_source_no_net(source_node);
77+
RouteTree tree((RRNodeId(source_node)));
7878

7979
/* Update base costs according to fanout and criticality rules */
8080
update_rr_base_costs(1);
@@ -118,29 +118,29 @@ static void do_one_route(const Netlist<>& net_list,
118118
-1,
119119
false,
120120
std::unordered_map<RRNodeId, int>());
121-
std::tie(found_path, cheapest) = router.timing_driven_route_connection_from_route_tree(rt_root,
122-
sink_node,
123-
cost_params,
124-
bounding_box,
125-
router_stats,
126-
conn_params);
121+
std::tie(found_path, cheapest) = router.timing_driven_route_connection_from_route_tree(tree.root,
122+
sink_node,
123+
cost_params,
124+
bounding_box,
125+
router_stats,
126+
conn_params);
127127

128128
if (found_path) {
129129
VTR_ASSERT(cheapest.index == sink_node);
130130

131-
t_rt_node* rt_node_of_sink = update_route_tree(&cheapest, OPEN, nullptr, router_opts.flat_routing);
131+
vtr::optional<RouteTreeNode&> rt_node_of_sink;
132+
std::tie(std::ignore, rt_node_of_sink) = update_route_tree(tree, &cheapest, OPEN, nullptr, router_opts.flat_routing);
132133

133134
//find delay
134-
float net_delay = rt_node_of_sink->Tdel;
135+
float net_delay = rt_node_of_sink.value().Tdel;
135136
VTR_LOG("Routed successfully, delay = %g!\n", net_delay);
136137
VTR_LOG("\n");
137-
print_route_tree_node(rt_root);
138+
print_route_tree_node(tree.root);
138139
VTR_LOG("\n");
139-
print_route_tree(rt_root);
140+
print_route_tree(tree.root);
140141
VTR_LOG("\n");
141142

142-
VTR_ASSERT_MSG(route_ctx.rr_node_route_inf[rt_root->inode].occ() <= rr_graph.node_capacity(RRNodeId(rt_root->inode)), "SOURCE should never be congested");
143-
free_route_tree(rt_root);
143+
VTR_ASSERT_MSG(route_ctx.rr_node_route_inf[size_t(tree.root.inode)].occ() <= rr_graph.node_capacity(tree.root.inode), "SOURCE should never be congested");
144144
} else {
145145
VTR_LOG("Routed failed");
146146
}
@@ -347,10 +347,10 @@ int main(int argc, const char **argv) {
347347
vpr_setup.Segments,
348348
is_flat);
349349
}
350-
free_routing_structs(net_list);
350+
free_routing_structs();
351351

352352
/* free data structures */
353-
vpr_free_all(net_list, Arch, vpr_setup);
353+
vpr_free_all(Arch, vpr_setup);
354354

355355
} catch (const tatum::Error& tatum_error) {
356356
vtr::printf_error(__FILE__, __LINE__, "STA Engine: %s\n", tatum_error.what());

0 commit comments

Comments
 (0)