Skip to content

Commit de7ac0d

Browse files
avoid calling vtr::strdup() for t_logical_block_type.name and call c_str() when needed
1 parent f0e8378 commit de7ac0d

14 files changed

+24
-24
lines changed

libs/libarchfpga/src/arch_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ t_physical_tile_type get_empty_physical_type(const char* name /*= EMPTY_BLOCK_NA
535535

536536
t_logical_block_type get_empty_logical_type(const char* name /*=EMPTY_BLOCK_NAME*/) {
537537
t_logical_block_type type;
538-
type.name = vtr::strdup(name);
538+
type.name = name;
539539
type.pb_type = nullptr;
540540

541541
return type;

libs/libarchfpga/src/physical_types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ bool t_physical_tile_type::is_empty() const {
141141
*/
142142

143143
bool t_logical_block_type::is_empty() const {
144-
return std::string(name) == std::string(EMPTY_BLOCK_NAME);
144+
return name == std::string(EMPTY_BLOCK_NAME);
145145
}
146146

147147
/**

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,10 +1076,10 @@ struct ArchReader {
10761076
continue;
10771077

10781078
// Check for duplicates
1079-
auto is_duplicate = [name](t_logical_block_type l) { return std::string(l.name) == name; };
1079+
auto is_duplicate = [name](const t_logical_block_type& l)-> bool { return l.name == name; };
10801080
VTR_ASSERT(std::find_if(ltypes_.begin(), ltypes_.end(), is_duplicate) == ltypes_.end());
10811081

1082-
ltype.name = vtr::strdup(name.c_str());
1082+
ltype.name = name;
10831083
ltype.index = ++index;
10841084

10851085
auto pb_type = new t_pb_type;
@@ -2089,7 +2089,7 @@ struct ArchReader {
20892089
// Create constant complex block
20902090
t_logical_block_type block;
20912091

2092-
block.name = vtr::strdup(const_block_.c_str());
2092+
block.name = (const_block_;
20932093
block.index = ltypes_.size();
20942094

20952095
auto pb_type = new t_pb_type;

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3613,7 +3613,7 @@ static void ProcessComplexBlocks(pugi::xml_node Node,
36133613

36143614
/* Load type name */
36153615
auto Prop = get_attribute(CurBlockType, "name", loc_data).value();
3616-
LogicalBlockType.name = vtr::strdup(Prop);
3616+
LogicalBlockType.name = Prop;
36173617

36183618
auto [_, success] = pb_type_descriptors.insert(LogicalBlockType.name);
36193619
if (!success) {

vpr/src/pack/cluster.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
250250
VTR_LOGV(verbosity > 2,
251251
"Complex block %d: '%s' (%s) ", total_clb_num,
252252
cluster_legalizer.get_cluster_pb(legalization_cluster_id)->name,
253-
cluster_legalizer.get_cluster_type(legalization_cluster_id)->name);
253+
cluster_legalizer.get_cluster_type(legalization_cluster_id)->name.c_str());
254254
VTR_LOGV(verbosity > 2, ".");
255255
//Progress dot for seed-block
256256
fflush(stdout);

vpr/src/pack/cluster_router.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ bool try_intra_lb_route(t_lb_router_data* router_data,
507507
--inet;
508508
auto& atom_ctx = g_vpr_ctx.atom();
509509
VTR_LOGV(verbosity > 3, "Net '%s' is impossible to route within proposed %s cluster\n",
510-
atom_ctx.nlist.net_name(lb_nets[inet].atom_net_id).c_str(), router_data->lb_type->name);
510+
atom_ctx.nlist.net_name(lb_nets[inet].atom_net_id).c_str(), router_data->lb_type->name.c_str());
511511
is_routed = false;
512512
}
513513
router_data->pres_con_fac *= router_data->params.pres_fac_mult;

vpr/src/pack/cluster_util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,13 +1061,13 @@ void start_new_cluster(ClusterLegalizer& cluster_legalizer,
10611061
}
10621062

10631063
if (success) {
1064-
VTR_LOGV(verbosity > 2, "\tPASSED_SEED: Block Type %s\n", type->name);
1064+
VTR_LOGV(verbosity > 2, "\tPASSED_SEED: Block Type %s\n", type->name.c_str());
10651065
// If clustering succeeds return the new_cluster_id and type.
10661066
legalization_cluster_id = new_cluster_id;
10671067
block_type = type;
10681068
break;
10691069
} else {
1070-
VTR_LOGV(verbosity > 2, "\tFAILED_SEED: Block Type %s\n", type->name);
1070+
VTR_LOGV(verbosity > 2, "\tFAILED_SEED: Block Type %s\n", type->name.c_str());
10711071
}
10721072
}
10731073

vpr/src/pack/constraints_report.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bool floorplan_constraints_regions_overfull(const ClusterLegalizer& cluster_lega
4646
floorplanning_ctx.overfull_partition_regions.push_back(pr);
4747
VTR_LOG("\n\nA partition including the following regions has been assigned %d blocks of type %s, "
4848
"but only has %d tiles of that type\n",
49-
num_assigned_blocks, block_type.name, num_tiles);
49+
num_assigned_blocks, block_type.name.c_str(), num_tiles);
5050
for (const Region& reg : regions) {
5151
const vtr::Rect<int>& rect = reg.get_rect();
5252
const auto [layer_low, layer_high] = reg.get_layer_range();

vpr/src/pack/pack.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ bool try_pack(t_packer_opts* packer_opts,
214214
resource_avail += ", ";
215215
}
216216

217-
resource_reqs += std::string(iter->first->name) + ": " + std::to_string(iter->second);
217+
resource_reqs += iter->first->name + ": " + std::to_string(iter->second);
218218

219219
int num_instances = 0;
220220
for (auto type : iter->first->equivalent_tiles)
221221
num_instances += grid.num_instances(type, -1);
222222

223-
resource_avail += std::string(iter->first->name) + ": " + std::to_string(num_instances);
223+
resource_avail += iter->first->name + ": " + std::to_string(num_instances);
224224
}
225225

226226
VPR_FATAL_ERROR(VPR_ERROR_OTHER, "Failed to find device which satisfies resource requirements required: %s (available %s)", resource_reqs.c_str(), resource_avail.c_str());
@@ -352,7 +352,7 @@ static bool try_size_device_grid(const t_arch& arch,
352352
if (util > 1.) {
353353
fits_on_device = false;
354354
}
355-
VTR_LOG("\tBlock Utilization: %.2f Type: %s\n", util, type.name);
355+
VTR_LOG("\tBlock Utilization: %.2f Type: %s\n", util, type.name.c_str());
356356
}
357357
VTR_LOG("\n");
358358

vpr/src/pack/pack_report.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void report_packing_pin_usage(std::ostream& os, const VprContext& ctx) {
6666
if (total_input_pins[type] != 0) {
6767
os << "\t\tHistogram:\n";
6868
auto input_histogram = build_histogram(inputs_used[type], 10, 0, total_input_pins[type]);
69-
for (auto line : format_histogram(input_histogram)) {
69+
for (const std::string& line : format_histogram(input_histogram)) {
7070
os << "\t\t" << line << "\n";
7171
}
7272
}

vpr/src/place/initial_placement.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static void check_initial_placement_legality(const vtr::vector_map<ClusterBlockI
251251
VTR_LOG("Block %s (# %d) of type %s could not be placed during initial placement iteration %d\n",
252252
cluster_ctx.clb_nlist.block_name(blk_id).c_str(),
253253
blk_id,
254-
cluster_ctx.clb_nlist.block_type(blk_id)->name,
254+
cluster_ctx.clb_nlist.block_type(blk_id)->name.c_str(),
255255
MAX_INIT_PLACE_ATTEMPTS - 1);
256256
unplaced_blocks++;
257257
}
@@ -275,13 +275,13 @@ static void check_initial_placement_legality(const vtr::vector_map<ClusterBlockI
275275
for (const auto& movable_blk_id : movable_blocks_of_type) {
276276
if (block_locs[movable_blk_id].is_fixed) {
277277
VPR_FATAL_ERROR(VPR_ERROR_PLACE, "Fixed block %d of logical type %s was mistakenly marked as movable during initial placement.\n",
278-
(size_t)movable_blk_id, logical_block_type.name);
278+
(size_t)movable_blk_id, logical_block_type.name.c_str());
279279
}
280280
if (cluster_ctx.clb_nlist.block_type(movable_blk_id)->index != logical_block_type.index) {
281281
VPR_FATAL_ERROR(VPR_ERROR_PLACE, "Clustered block %d of logical type %s was mistakenly marked as logical type %s.\n",
282282
(size_t)movable_blk_id,
283-
cluster_ctx.clb_nlist.block_type(movable_blk_id)->name,
284-
logical_block_type.name);
283+
cluster_ctx.clb_nlist.block_type(movable_blk_id)->name.c_str(),
284+
logical_block_type.name.c_str());
285285
}
286286
}
287287
}

vpr/src/place/move_generator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void MoveTypeStat::print_placement_move_types_stats() {
8686
int rejected = rejected_moves[itype.index][imove];
8787
int aborted = moves - (accepted + rejected);
8888
if (count == 0) {
89-
VTR_LOG("%-18.20s", itype.name);
89+
VTR_LOG("%-18.20s", itype.name.c_str());
9090
} else {
9191
VTR_LOG(" ");
9292
}

vpr/src/place/place_macro.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ static void mark_direct_of_ports(int idirect,
475475
int num_ports = ports.size();
476476
for (int iport = 0; iport < num_ports; iport++) {
477477
// Find ports with the same port_name
478-
if (port_name == ports[iport].name ) {
478+
if (port_name == ports[iport].name) {
479479
int num_port_pins = ports[iport].num_pins;
480480

481481
// Check whether the end_pin_index is valid

vpr/test/test_interchange_device.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ TEST_CASE("read_interchange_luts", "[vpr]") {
9494
REQUIRE(lut_element.lut_bels.size() == 1);
9595

9696
for (auto lut_bel : lut_element.lut_bels) {
97-
CHECK(std::find(lut_bels.begin(), lut_bels.end(), lut_bel.name) != lut_bels.end());
97+
CHECK(lut_bels.find(lut_bel.name) != lut_bels.end());
9898
REQUIRE(lut_bel.output_pin == std::string("O"));
99-
for (auto lut_pin : lut_bel.input_pins)
100-
CHECK(std::find(lut_bel_pins.begin(), lut_bel_pins.end(), lut_pin) != lut_bel_pins.end());
99+
for (const std::string &lut_pin : lut_bel.input_pins)
100+
CHECK(lut_bel_pins.find(lut_pin) != lut_bel_pins.end());
101101
}
102102
}
103103
}

0 commit comments

Comments
 (0)