Skip to content

Commit 91aed46

Browse files
replace t_clb_to_clb_directs* with std::vector<t_clb_to_clb_directs>&
1 parent 31f617a commit 91aed46

File tree

1 file changed

+20
-39
lines changed

1 file changed

+20
-39
lines changed

vpr/src/route/rr_graph.cpp

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static void build_bidir_rr_opins(RRGraphBuilder& rr_graph_builder,
155155
const t_chan_details& chan_details_y,
156156
const DeviceGrid& grid,
157157
const std::vector<t_direct_inf>& directs,
158-
const t_clb_to_clb_directs* clb_to_clb_directs,
158+
const std::vector<t_clb_to_clb_directs>& clb_to_clb_directs,
159159
const int num_seg_types);
160160

161161
static void build_unidir_rr_opins(RRGraphBuilder& rr_graph_builder,
@@ -175,7 +175,7 @@ static void build_unidir_rr_opins(RRGraphBuilder& rr_graph_builder,
175175
bool* Fc_clipped,
176176
const t_unified_to_parallel_seg_index& seg_index_map,
177177
const std::vector<t_direct_inf>& directs,
178-
const t_clb_to_clb_directs* clb_to_clb_directs,
178+
const std::vector<t_clb_to_clb_directs>& clb_to_clb_directs,
179179
const int num_seg_types,
180180
int& edge_count);
181181

@@ -189,7 +189,7 @@ static int get_opin_direct_connections(RRGraphBuilder& rr_graph_builder,
189189
RRNodeId from_rr_node,
190190
t_rr_edge_info_set& rr_edges_to_create,
191191
const std::vector<t_direct_inf>& directs,
192-
const t_clb_to_clb_directs* clb_to_clb_directs);
192+
const std::vector<t_clb_to_clb_directs>& clb_to_clb_directs);
193193

194194
static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder& rr_graph_builder,
195195
t_rr_graph_storage& L_rr_node,
@@ -218,7 +218,7 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
218218
const enum e_directionality directionality,
219219
bool* Fc_clipped,
220220
const std::vector<t_direct_inf>& directs,
221-
const t_clb_to_clb_directs* clb_to_clb_directs,
221+
const std::vector<t_clb_to_clb_directs>& clb_to_clb_directs,
222222
bool is_global_graph,
223223
const enum e_clock_modeling clock_modeling,
224224
bool is_flat,
@@ -596,7 +596,8 @@ static void rr_graph_externals(const std::vector<t_segment_inf>& segment_inf,
596596
int wire_to_rr_ipin_switch,
597597
enum e_base_cost_type base_cost_type);
598598

599-
static t_clb_to_clb_directs* alloc_and_load_clb_to_clb_directs(const std::vector<t_direct_inf>& directs, const int delayless_switch);
599+
static std::vector<t_clb_to_clb_directs> alloc_and_load_clb_to_clb_directs(const std::vector<t_direct_inf>& directs,
600+
int delayless_switch);
600601

601602
static std::vector<t_seg_details> alloc_and_load_global_route_seg_details(int global_route_switch);
602603

@@ -1106,10 +1107,7 @@ static void build_rr_graph(const t_graph_type graph_type,
11061107
auto& device_ctx = g_vpr_ctx.mutable_device();
11071108
const auto& rr_graph = device_ctx.rr_graph;
11081109

1109-
t_clb_to_clb_directs* clb_to_clb_directs = nullptr;
1110-
if (!directs.empty()) {
1111-
clb_to_clb_directs = alloc_and_load_clb_to_clb_directs(directs, delayless_switch);
1112-
}
1110+
std::vector<t_clb_to_clb_directs> clb_to_clb_directs = alloc_and_load_clb_to_clb_directs(directs, delayless_switch);
11131111

11141112
/* START SEG_DETAILS */
11151113
size_t num_segments = segment_inf.size();
@@ -1564,11 +1562,6 @@ static void build_rr_graph(const t_graph_type graph_type,
15641562

15651563
track_to_pin_lookup_x.clear();
15661564
track_to_pin_lookup_y.clear();
1567-
1568-
if (clb_to_clb_directs != nullptr) {
1569-
delete[] clb_to_clb_directs;
1570-
}
1571-
15721565
// We are done with building the RR Graph. Thus, we can clear the storages only used
15731566
// to build the RR Graph
15741567
device_ctx.rr_graph_builder.clear_temp_storage();
@@ -2150,11 +2143,12 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
21502143
const enum e_directionality directionality,
21512144
bool* Fc_clipped,
21522145
const std::vector<t_direct_inf>& directs,
2153-
const t_clb_to_clb_directs* clb_to_clb_directs,
2146+
const std::vector<t_clb_to_clb_directs>& clb_to_clb_directs,
21542147
bool is_global_graph,
21552148
const enum e_clock_modeling clock_modeling,
21562149
bool /*is_flat*/,
21572150
const int route_verbosity) {
2151+
VTR_ASSERT(directs.size() == clb_to_clb_directs.size());
21582152
//We take special care when creating RR graph edges (there are typically many more
21592153
//edges than nodes in an RR graph).
21602154
//
@@ -2734,7 +2728,7 @@ static void build_bidir_rr_opins(RRGraphBuilder& rr_graph_builder,
27342728
const t_chan_details& chan_details_y,
27352729
const DeviceGrid& grid,
27362730
const std::vector<t_direct_inf>& directs,
2737-
const t_clb_to_clb_directs* clb_to_clb_directs,
2731+
const std::vector<t_clb_to_clb_directs>& clb_to_clb_directs,
27382732
const int num_seg_types) {
27392733
//Don't connect pins which are not adjacent to channels around the perimeter
27402734
if ((i == 0 && side != RIGHT)
@@ -4234,7 +4228,7 @@ static void build_unidir_rr_opins(RRGraphBuilder& rr_graph_builder,
42344228
bool* Fc_clipped,
42354229
const t_unified_to_parallel_seg_index& seg_index_map,
42364230
const std::vector<t_direct_inf>& directs,
4237-
const t_clb_to_clb_directs* clb_to_clb_directs,
4231+
const std::vector<t_clb_to_clb_directs>& clb_to_clb_directs,
42384232
const int num_seg_types,
42394233
int& rr_edge_count) {
42404234
/*
@@ -4343,15 +4337,12 @@ static void build_unidir_rr_opins(RRGraphBuilder& rr_graph_builder,
43434337
* This data structure supplements the the info in the "directs" data structure
43444338
* TODO: The function that does this parsing in placement is poorly done because it lacks generality on heterogeniety, should replace with this one
43454339
*/
4346-
static t_clb_to_clb_directs* alloc_and_load_clb_to_clb_directs(const std::vector<t_direct_inf>& directs, int delayless_switch) {
4347-
t_clb_to_clb_directs* clb_to_clb_directs;
4348-
t_physical_tile_type_ptr physical_tile = nullptr;
4349-
t_physical_tile_port tile_port;
4350-
4351-
auto& device_ctx = g_vpr_ctx.device();
4340+
static std::vector<t_clb_to_clb_directs> alloc_and_load_clb_to_clb_directs(const std::vector<t_direct_inf>& directs,
4341+
int delayless_switch) {
4342+
const auto& device_ctx = g_vpr_ctx.device();
43524343

4353-
const int num_directs = directs.size();
4354-
clb_to_clb_directs = new t_clb_to_clb_directs[num_directs];
4344+
const int num_directs = (int)directs.size();
4345+
std::vector<t_clb_to_clb_directs> clb_to_clb_directs(num_directs);
43554346

43564347
for (int i = 0; i < num_directs; i++) {
43574348
//clb_to_clb_directs[i].from_clb_type;
@@ -4367,20 +4358,15 @@ static t_clb_to_clb_directs* alloc_and_load_clb_to_clb_directs(const std::vector
43674358
auto [start_pin_index, end_pin_index, tile_name, port_name] = parse_direct_pin_name(directs[i].from_pin, directs[i].line);
43684359

43694360
// Figure out which type, port, and pin is used
4370-
for (const t_physical_tile_type& type : device_ctx.physical_tile_types) {
4371-
if (tile_name == type.name) {
4372-
physical_tile = &type;
4373-
break;
4374-
}
4375-
}
4361+
t_physical_tile_type_ptr physical_tile = find_tile_type_by_name(tile_name, device_ctx.physical_tile_types);
43764362

43774363
if (physical_tile == nullptr) {
43784364
VPR_THROW(VPR_ERROR_ARCH, "Unable to find block %s.\n", tile_name.c_str());
43794365
}
43804366

43814367
clb_to_clb_directs[i].from_clb_type = physical_tile;
43824368

4383-
tile_port = find_tile_port_by_name(physical_tile, port_name);
4369+
t_physical_tile_port tile_port = find_tile_port_by_name(physical_tile, port_name);
43844370

43854371
if (start_pin_index == OPEN) {
43864372
VTR_ASSERT(start_pin_index == end_pin_index);
@@ -4456,7 +4442,7 @@ static int get_opin_direct_connections(RRGraphBuilder& rr_graph_builder,
44564442
RRNodeId from_rr_node,
44574443
t_rr_edge_info_set& rr_edges_to_create,
44584444
const std::vector<t_direct_inf>& directs,
4459-
const t_clb_to_clb_directs* clb_to_clb_directs) {
4445+
const std::vector<t_clb_to_clb_directs>& clb_to_clb_directs) {
44604446
auto& device_ctx = g_vpr_ctx.device();
44614447

44624448
t_physical_tile_type_ptr curr_type = device_ctx.grid.get_physical_type({x, y, layer});
@@ -4585,7 +4571,6 @@ static std::vector<bool> alloc_and_load_perturb_opins(const t_physical_tile_type
45854571
const std::vector<t_segment_inf>& segment_inf) {
45864572
int i, Fc_max, iclass, num_wire_types;
45874573
int num, max_primes, factor, num_factors;
4588-
int* prime_factors;
45894574
float step_size = 0;
45904575
float n = 0;
45914576
float threshold = 0.07;
@@ -4629,10 +4614,7 @@ static std::vector<bool> alloc_and_load_perturb_opins(const t_physical_tile_type
46294614
max_primes = (int)floor(log((float)num_wire_types) / log(2.0));
46304615
max_primes = std::max(max_primes, 1); //Minimum of 1 to ensure we allocate space for at least one prime_factor
46314616

4632-
prime_factors = new int[max_primes];
4633-
for (i = 0; i < max_primes; i++) {
4634-
prime_factors[i] = 0;
4635-
}
4617+
std::vector<int>prime_factors(max_primes, 0);
46364618

46374619
/* Find the prime factors of num_wire_types */
46384620
num = num_wire_types;
@@ -4671,7 +4653,6 @@ static std::vector<bool> alloc_and_load_perturb_opins(const t_physical_tile_type
46714653
perturb_opins[0] = false;
46724654
}
46734655
}
4674-
delete[] prime_factors;
46754656

46764657
return perturb_opins;
46774658
}

0 commit comments

Comments
 (0)