@@ -155,7 +155,7 @@ static void build_bidir_rr_opins(RRGraphBuilder& rr_graph_builder,
155
155
const t_chan_details& chan_details_y,
156
156
const DeviceGrid& grid,
157
157
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,
159
159
const int num_seg_types);
160
160
161
161
static void build_unidir_rr_opins (RRGraphBuilder& rr_graph_builder,
@@ -175,7 +175,7 @@ static void build_unidir_rr_opins(RRGraphBuilder& rr_graph_builder,
175
175
bool * Fc_clipped,
176
176
const t_unified_to_parallel_seg_index& seg_index_map,
177
177
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,
179
179
const int num_seg_types,
180
180
int & edge_count);
181
181
@@ -189,7 +189,7 @@ static int get_opin_direct_connections(RRGraphBuilder& rr_graph_builder,
189
189
RRNodeId from_rr_node,
190
190
t_rr_edge_info_set& rr_edges_to_create,
191
191
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);
193
193
194
194
static std::function<void (t_chan_width*)> alloc_and_load_rr_graph (RRGraphBuilder& rr_graph_builder,
195
195
t_rr_graph_storage& L_rr_node,
@@ -218,7 +218,7 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
218
218
const enum e_directionality directionality,
219
219
bool * Fc_clipped,
220
220
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,
222
222
bool is_global_graph,
223
223
const enum e_clock_modeling clock_modeling,
224
224
bool is_flat,
@@ -596,7 +596,8 @@ static void rr_graph_externals(const std::vector<t_segment_inf>& segment_inf,
596
596
int wire_to_rr_ipin_switch,
597
597
enum e_base_cost_type base_cost_type);
598
598
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);
600
601
601
602
static std::vector<t_seg_details> alloc_and_load_global_route_seg_details (int global_route_switch);
602
603
@@ -1106,10 +1107,7 @@ static void build_rr_graph(const t_graph_type graph_type,
1106
1107
auto & device_ctx = g_vpr_ctx.mutable_device ();
1107
1108
const auto & rr_graph = device_ctx.rr_graph ;
1108
1109
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);
1113
1111
1114
1112
/* START SEG_DETAILS */
1115
1113
size_t num_segments = segment_inf.size ();
@@ -1564,11 +1562,6 @@ static void build_rr_graph(const t_graph_type graph_type,
1564
1562
1565
1563
track_to_pin_lookup_x.clear ();
1566
1564
track_to_pin_lookup_y.clear ();
1567
-
1568
- if (clb_to_clb_directs != nullptr ) {
1569
- delete[] clb_to_clb_directs;
1570
- }
1571
-
1572
1565
// We are done with building the RR Graph. Thus, we can clear the storages only used
1573
1566
// to build the RR Graph
1574
1567
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
2150
2143
const enum e_directionality directionality,
2151
2144
bool * Fc_clipped,
2152
2145
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,
2154
2147
bool is_global_graph,
2155
2148
const enum e_clock_modeling clock_modeling,
2156
2149
bool /* is_flat*/ ,
2157
2150
const int route_verbosity) {
2151
+ VTR_ASSERT (directs.size () == clb_to_clb_directs.size ());
2158
2152
// We take special care when creating RR graph edges (there are typically many more
2159
2153
// edges than nodes in an RR graph).
2160
2154
//
@@ -2734,7 +2728,7 @@ static void build_bidir_rr_opins(RRGraphBuilder& rr_graph_builder,
2734
2728
const t_chan_details& chan_details_y,
2735
2729
const DeviceGrid& grid,
2736
2730
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,
2738
2732
const int num_seg_types) {
2739
2733
// Don't connect pins which are not adjacent to channels around the perimeter
2740
2734
if ((i == 0 && side != RIGHT)
@@ -4234,7 +4228,7 @@ static void build_unidir_rr_opins(RRGraphBuilder& rr_graph_builder,
4234
4228
bool * Fc_clipped,
4235
4229
const t_unified_to_parallel_seg_index& seg_index_map,
4236
4230
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,
4238
4232
const int num_seg_types,
4239
4233
int & rr_edge_count) {
4240
4234
/*
@@ -4343,15 +4337,12 @@ static void build_unidir_rr_opins(RRGraphBuilder& rr_graph_builder,
4343
4337
* This data structure supplements the the info in the "directs" data structure
4344
4338
* TODO: The function that does this parsing in placement is poorly done because it lacks generality on heterogeniety, should replace with this one
4345
4339
*/
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 ();
4352
4343
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) ;
4355
4346
4356
4347
for (int i = 0 ; i < num_directs; i++) {
4357
4348
// 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
4367
4358
auto [start_pin_index, end_pin_index, tile_name, port_name] = parse_direct_pin_name (directs[i].from_pin , directs[i].line );
4368
4359
4369
4360
// 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 );
4376
4362
4377
4363
if (physical_tile == nullptr ) {
4378
4364
VPR_THROW (VPR_ERROR_ARCH, " Unable to find block %s.\n " , tile_name.c_str ());
4379
4365
}
4380
4366
4381
4367
clb_to_clb_directs[i].from_clb_type = physical_tile;
4382
4368
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);
4384
4370
4385
4371
if (start_pin_index == OPEN) {
4386
4372
VTR_ASSERT (start_pin_index == end_pin_index);
@@ -4456,7 +4442,7 @@ static int get_opin_direct_connections(RRGraphBuilder& rr_graph_builder,
4456
4442
RRNodeId from_rr_node,
4457
4443
t_rr_edge_info_set& rr_edges_to_create,
4458
4444
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) {
4460
4446
auto & device_ctx = g_vpr_ctx.device ();
4461
4447
4462
4448
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
4585
4571
const std::vector<t_segment_inf>& segment_inf) {
4586
4572
int i, Fc_max, iclass, num_wire_types;
4587
4573
int num, max_primes, factor, num_factors;
4588
- int * prime_factors;
4589
4574
float step_size = 0 ;
4590
4575
float n = 0 ;
4591
4576
float threshold = 0.07 ;
@@ -4629,10 +4614,7 @@ static std::vector<bool> alloc_and_load_perturb_opins(const t_physical_tile_type
4629
4614
max_primes = (int )floor (log ((float )num_wire_types) / log (2.0 ));
4630
4615
max_primes = std::max (max_primes, 1 ); // Minimum of 1 to ensure we allocate space for at least one prime_factor
4631
4616
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 );
4636
4618
4637
4619
/* Find the prime factors of num_wire_types */
4638
4620
num = num_wire_types;
@@ -4671,7 +4653,6 @@ static std::vector<bool> alloc_and_load_perturb_opins(const t_physical_tile_type
4671
4653
perturb_opins[0 ] = false ;
4672
4654
}
4673
4655
}
4674
- delete[] prime_factors;
4675
4656
4676
4657
return perturb_opins;
4677
4658
}
0 commit comments