Skip to content

Commit ecb08bf

Browse files
fix segfault when logic block type can't be inferred
1 parent 08bad8f commit ecb08bf

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

vpr/src/base/vpr_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ t_ext_pin_util_targets& t_ext_pin_util_targets::operator=(t_ext_pin_util_targets
123123
return *this;
124124
}
125125

126-
t_ext_pin_util t_ext_pin_util_targets::get_pin_util(const std::string& block_type_name) const {
126+
t_ext_pin_util t_ext_pin_util_targets::get_pin_util(std::string_view block_type_name) const {
127127
auto itr = overrides_.find(block_type_name);
128128
if (itr != overrides_.end()) {
129129
return itr->second;
@@ -248,7 +248,7 @@ void t_pack_high_fanout_thresholds::set(const std::string& block_type_name, int
248248
overrides_[block_type_name] = threshold;
249249
}
250250

251-
int t_pack_high_fanout_thresholds::get_threshold(const std::string& block_type_name) const {
251+
int t_pack_high_fanout_thresholds::get_threshold(std::string_view block_type_name) const {
252252
auto itr = overrides_.find(block_type_name);
253253
if (itr != overrides_.end()) {
254254
return itr->second;

vpr/src/base/vpr_types.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <unordered_map>
2929
#include <unordered_set>
3030
#include <set>
31+
#include <string_view>
3132
#include "arch_types.h"
3233
#include "atom_netlist_fwd.h"
3334
#include "clustered_netlist_fwd.h"
@@ -196,7 +197,7 @@ class t_ext_pin_util_targets {
196197
t_ext_pin_util_targets& operator=(t_ext_pin_util_targets&& other) noexcept;
197198

198199
///@brief Returns the input pin util of the specified block (or default if unspecified)
199-
t_ext_pin_util get_pin_util(const std::string& block_type_name) const;
200+
t_ext_pin_util get_pin_util(std::string_view block_type_name) const;
200201

201202
///@brief Returns a string describing input/output pin utilization targets
202203
std::string to_string() const;
@@ -216,7 +217,7 @@ class t_ext_pin_util_targets {
216217

217218
private:
218219
t_ext_pin_util defaults_;
219-
std::map<std::string, t_ext_pin_util> overrides_;
220+
std::map<std::string, t_ext_pin_util, std::less<>> overrides_;
220221
};
221222

222223
class t_pack_high_fanout_thresholds {
@@ -227,7 +228,7 @@ class t_pack_high_fanout_thresholds {
227228
t_pack_high_fanout_thresholds& operator=(t_pack_high_fanout_thresholds&& other) noexcept;
228229

229230
///@brief Returns the high fanout threshold of the specifi ed block
230-
int get_threshold(const std::string& block_type_name) const;
231+
int get_threshold(std::string_view block_type_name) const;
231232

232233
///@brief Returns a string describing high fanout thresholds for different block types
233234
std::string to_string() const;
@@ -247,7 +248,7 @@ class t_pack_high_fanout_thresholds {
247248

248249
private:
249250
int default_;
250-
std::map<std::string, int> overrides_;
251+
std::map<std::string, int, std::less<>> overrides_;
251252
};
252253

253254
/* these are defined later, but need to declare here because it is used */

vpr/src/pack/cluster_util.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,6 @@ bool atom_cluster_noc_group_check(AtomBlockId blk_id,
13821382
NocGroupId& temp_cluster_noc_grp_id) {
13831383
const NocGroupId atom_noc_grp_id = g_vpr_ctx.cl_helper().atom_noc_grp_id[blk_id];
13841384

1385-
13861385
if (temp_cluster_noc_grp_id == NocGroupId::INVALID()) {
13871386
// the cluster does not have a NoC group
13881387
// assign the atom's NoC group to cluster

vpr/src/pack/noc_aware_cluster_util.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ void update_noc_reachability_partitions(const std::vector<AtomBlockId>& noc_atom
3131
const auto& grid = g_vpr_ctx.device().grid;
3232

3333
t_logical_block_type_ptr logic_block_type = infer_logic_block_type(grid);
34-
const size_t high_fanout_threshold = high_fanout_thresholds.get_threshold(logic_block_type->name);
34+
const char* logical_block_name = logic_block_type != nullptr ? logic_block_type->name : "";
35+
const size_t high_fanout_threshold = high_fanout_thresholds.get_threshold(logical_block_name);
3536

3637
// get the total number of atoms
3738
const size_t n_atoms = atom_ctx.nlist.blocks().size();

vpr/src/pack/pack.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ bool try_pack(t_packer_opts* packer_opts,
126126
int pack_iteration = 1;
127127
bool floorplan_regions_overfull = false;
128128

129-
auto constraints_backup = g_vpr_ctx.floorplanning().constraints;
130129
// find all NoC router atoms
131130
auto noc_atoms = find_noc_router_atoms();
132131
update_noc_reachability_partitions(noc_atoms);

0 commit comments

Comments
 (0)