Skip to content

Commit 9f06be2

Browse files
apply PR comments
1 parent 94e24be commit 9f06be2

File tree

7 files changed

+31
-28
lines changed

7 files changed

+31
-28
lines changed

libs/libarchfpga/src/physical_types.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ bool t_rr_switch_inf::operator==(const t_rr_switch_inf& other) const {
8686
}
8787

8888
std::size_t t_rr_switch_inf::Hasher::operator()(const t_rr_switch_inf& s) const {
89-
std::size_t seed = 0;
89+
std::size_t hash_val = 0;
9090

91-
auto hash_combine = [&seed](auto&& val) {
92-
seed ^= std::hash<std::decay_t<decltype(val)>>{}(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
91+
auto hash_combine = [&hash_val](auto&& val) {
92+
hash_val ^= std::hash<std::decay_t<decltype(val)>>{}(val) + 0x9e3779b9 + (hash_val << 6) + (hash_val >> 2);
9393
};
9494

9595
hash_combine(s.R);
@@ -104,7 +104,7 @@ std::size_t t_rr_switch_inf::Hasher::operator()(const t_rr_switch_inf& s) const
104104
hash_combine(s.intra_tile);
105105
hash_combine(static_cast<int>(s.type()));
106106

107-
return seed;
107+
return hash_val;
108108
}
109109

110110
void t_rr_switch_inf::set_type(SwitchType type_val) {

libs/libarchfpga/src/physical_types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,12 @@ struct t_rr_switch_inf {
19291929

19301930
bool operator==(const t_rr_switch_inf& other) const;
19311931

1932+
/**
1933+
* @brief Functor for computing a hash value for t_rr_switch_inf.
1934+
*
1935+
* This custom hasher enables the use of t_rr_switch_inf objects as keys
1936+
* in unordered containers such as std::unordered_map or std::unordered_set.
1937+
*/
19321938
struct Hasher {
19331939
std::size_t operator()(const t_rr_switch_inf& s) const;
19341940
};

libs/librrgraph/src/base/rr_graph_builder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ class RRGraphBuilder {
264264
node_storage_.alloc_and_load_edges(rr_edges_to_create);
265265
}
266266

267-
/** @brief Overrides the associated switch for a given edge. */
267+
/** @brief Overrides the associated switch for a given edge by
268+
* updating the edge to use the passed in switch. */
268269
inline void override_edge_switch(RREdgeId edge_id, RRSwitchId switch_id) {
269270
node_storage_.override_edge_switch(edge_id, switch_id);
270271
}

libs/librrgraph/src/base/rr_graph_storage.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class t_rr_graph_storage {
401401
}
402402

403403
/**
404-
* @brief Retrieve the RREdgeId that connect the given source and sink nodes.
404+
* @brief Retrieve the RREdgeId that connects the given source and sink nodes.
405405
* If the given source/sink nodes are not connected, RREdgeId::INVALID() is returned.
406406
*/
407407
RREdgeId edge_id(RRNodeId src, RRNodeId sink) const {
@@ -744,7 +744,8 @@ class t_rr_graph_storage {
744744
*/
745745
void partition_edges(const vtr::vector<RRSwitchId, t_rr_switch_inf>& rr_switches);
746746

747-
/** @brief Overrides the associated switch for a given edge. */
747+
/** @brief Overrides the associated switch for a given edge by
748+
* updating the edge to use the passed in switch. */
748749
void override_edge_switch(RREdgeId edge_id, RRSwitchId switch_id);
749750

750751
/** @brief Validate that edge data is partitioned correctly.*/

libs/librrgraph/src/io/rr_graph_reader.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <fstream>
2222
#include <unordered_set>
23+
#include <utility>
2324

2425
#include "vtr_time.h"
2526
#include "pugixml.hpp"
@@ -38,13 +39,11 @@
3839
* (source_node_id, sink_node_id) Tdel
3940
*
4041
* @param line The line to parse.
41-
* @param overridden_Tdel Parsed override delay.
4242
* @param rr_graph The RR graph for edge lookup using source-sink nodes.
43-
* @return The RR edge whose attributes are to be overridden.
43+
* @return A pair containing an RR edge and the overridden Tdel (intrinsic delay).
4444
*/
45-
static RREdgeId process_rr_edge_override(const std::string& line,
46-
float& overridden_Tdel,
47-
const RRGraphView& rr_graph);
45+
static std::pair<RREdgeId, float> process_rr_edge_override(const std::string& line,
46+
const RRGraphView& rr_graph);
4847

4948
/************************ Subroutine definitions ****************************/
5049
/* loads the given RR_graph file into the appropriate data structures
@@ -134,9 +133,8 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder,
134133
}
135134
}
136135

137-
static RREdgeId process_rr_edge_override(const std::string& line,
138-
float& overridden_Tdel,
139-
const RRGraphView& rr_graph) {
136+
static std::pair<RREdgeId, float> process_rr_edge_override(const std::string& line,
137+
const RRGraphView& rr_graph) {
140138
std::istringstream iss(line);
141139
char ch;
142140
RREdgeId edge_id;
@@ -165,11 +163,12 @@ static RREdgeId process_rr_edge_override(const std::string& line,
165163
VTR_LOG_ERROR("Invalid line format: %s\n", line.c_str());
166164
}
167165

166+
float overridden_Tdel;
168167
if (!(iss >> overridden_Tdel)) {
169168
VTR_LOG_ERROR("Couldn't parse the overridden delay in this line: %s\n", line.c_str());
170169
}
171170

172-
return edge_id;
171+
return {edge_id, overridden_Tdel};
173172
}
174173

175174
void load_rr_edge_delay_overrides(std::string_view filename,
@@ -184,20 +183,14 @@ void load_rr_edge_delay_overrides(std::string_view filename,
184183
}
185184

186185
std::string line;
187-
bool firstLine = true;
188186

189187
while (std::getline(file, line)) {
190-
if (firstLine) {
191-
if (line.empty() || line[0] != '#') {
192-
VTR_LOG_ERROR("Error: First line must start with #\n");
193-
}
194-
firstLine = false;
195-
continue; // Ignore first line
188+
if (line[0] == '#') {
189+
continue; // Ignore lines starting with '#'
196190
}
197191

198192
if (!line.empty()) {
199-
float overridden_Tdel;
200-
RREdgeId edge_id = process_rr_edge_override(line, overridden_Tdel, rr_graph);
193+
const auto [edge_id, overridden_Tdel] = process_rr_edge_override(line, rr_graph);
201194
RRSwitchId curr_switch_id = (RRSwitchId)rr_graph.edge_switch(edge_id);
202195
t_rr_switch_inf switch_override_info = rr_graph.rr_switch_inf(curr_switch_id);
203196

vpr/src/base/vpr_context.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,13 @@ struct DeviceContext : public Context {
270270
t_clock_arch* clock_arch;
271271

272272
/// @brief Name of rrgraph file read (if any).
273-
/// Used to determine if the file is already loaded when reading rrgraph.
273+
/// Used to determine if the specified rr-graph file is already loaded,
274+
/// so we can avoid redundant reading of the rr-graph
274275
std::string loaded_rr_graph_filename;
275276

276277
/// @brief Name of rrgraph edge override file read (if any).
277-
/// Used to determine if the file is already loaded when reading rrgraph edge overrides.
278+
/// Used to determine if the specified rr-graph edge override file is already loaded,
279+
/// so we can avoid redundant reading of the rr-graph
278280
std::string loaded_rr_edge_override_filename;
279281

280282
/*******************************************************************

vpr/src/base/vpr_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ struct t_noc_opts {
13151315
* Only important if the route_type is DETAILED.
13161316
*/
13171317
struct t_det_routing_arch {
1318-
/// Should the tracks be uni-directional or bi-directional? (UDSD by AY)
1318+
/// Should the tracks be uni-directional or bi-directional?
13191319
enum e_directionality directionality;
13201320
int Fs;
13211321

0 commit comments

Comments
 (0)