Skip to content

Commit 04959b7

Browse files
authored
Merge branch 'master' into openfpga
2 parents 39c80f4 + 1415193 commit 04959b7

File tree

4 files changed

+90
-92
lines changed

4 files changed

+90
-92
lines changed

.github/workflows/nightly_test.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@ on:
44
# We want to run the CI when anything is pushed to master.
55
# Since master is a protected branch this only happens when a PR is merged.
66
# This is a double check in case the PR was stale and had some issues.
7-
push:
8-
branches:
9-
- master
10-
paths-ignore: # Prevents from running if only docs are updated
11-
- 'doc/**'
12-
- '**/*README*'
13-
- '**.md'
14-
- '**.rst'
15-
pull_request:
16-
paths-ignore: # Prevents from running if only docs are updated
17-
- 'doc/**'
18-
- '**/*README*'
19-
- '**.md'
20-
- '**.rst'
7+
# NOTE: This was turned off in late October 2024 since the Nightly Tests were
8+
# no longer working on the self-hosted runners. Will turn this back on
9+
# once the issue is resolved.
10+
# push:
11+
# branches:
12+
# - master
13+
# paths-ignore: # Prevents from running if only docs are updated
14+
# - 'doc/**'
15+
# - '**/*README*'
16+
# - '**.md'
17+
# - '**.rst'
18+
# pull_request:
19+
# paths-ignore: # Prevents from running if only docs are updated
20+
# - 'doc/**'
21+
# - '**/*README*'
22+
# - '**.md'
23+
# - '**.rst'
2124
workflow_dispatch:
2225
schedule:
2326
- cron: '0 0 * * *' # daily

doc/src/vpr/command_line_usage.rst

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,12 +1074,16 @@ The following options are only used when FPGA device and netlist contain a NoC r
10741074

10751075
.. note:: noc_flows_file are required to specify if NoC optimization is turned on (--noc on).
10761076

1077-
.. option:: --noc_routing_algorithm {xy_routing | bfs_routing}
1077+
.. option:: --noc_routing_algorithm {xy_routing | bfs_routing | west_first_routing | north_last_routing | negative_first_routing | odd_even_routing}
10781078

10791079
Controls the algorithm used by the NoC to route packets.
10801080

10811081
* ``xy_routing`` Uses the direction oriented routing algorithm. This is recommended to be used with mesh NoC topologies.
1082-
* ``bfs_routing`` Uses the breadth first search algorithm. The objective is to find a route that uses a minimum number of links. This can be used with any NoC topology.
1082+
* ``bfs_routing`` Uses the breadth first search algorithm. The objective is to find a route that uses a minimum number of links. This algorithm is not guaranteed to generate deadlock-free traffic flow routes, but can be used with any NoC topology.
1083+
* ``west_first_routing`` Uses the west-first routing algorithm. This is recommended to be used with mesh NoC topologies.
1084+
* ``north_last_routing`` Uses the north-last routing algorithm. This is recommended to be used with mesh NoC topologies.
1085+
* ``negative_first_routing`` Uses the negative-first routing algorithm. This is recommended to be used with mesh NoC topologies.
1086+
* ``odd_even_routing`` Uses the odd-even routing algorithm. This is recommended to be used with mesh NoC topologies.
10831087

10841088
**Default:** ``bfs_routing``
10851089

@@ -1091,28 +1095,45 @@ The following options are only used when FPGA device and netlist contain a NoC r
10911095
* ``noc_placement_weighting = 1`` means noc placement is considered equal to timing and wirelength.
10921096
* ``noc_placement_weighting > 1`` means the placement is increasingly dominated by NoC parameters.
10931097

1094-
**Default:** ``0.6``
1098+
**Default:** ``5.0``
1099+
1100+
.. option:: --noc_aggregate_bandwidth_weighting <float>
1101+
1102+
Controls the importance of minimizing the NoC aggregate bandwidth. This value can be >=0, where 0 would mean the aggregate bandwidth has no relevance to placement.
1103+
Other positive numbers specify the importance of minimizing the NoC aggregate bandwidth compared to other NoC-related cost terms.
1104+
Weighting factors for NoC-related cost terms are normalized internally. Therefore, their absolute values are not important, and
1105+
only their relative ratios determine the importance of each cost term.
1106+
1107+
**Default:** ``0.38``
10951108

10961109
.. option:: --noc_latency_constraints_weighting <float>
10971110

1098-
Controls the importance of meeting all the NoC traffic flow latency constraints.
1111+
Controls the importance of meeting all the NoC traffic flow latency constraints. This value can be >=0, where 0 would mean latency constraints have no relevance to placement.
1112+
Other positive numbers specify the importance of meeting latency constraints compared to other NoC-related cost terms.
1113+
Weighting factors for NoC-related cost terms are normalized internally. Therefore, their absolute values are not important, and
1114+
only their relative ratios determine the importance of each cost term.
10991115

1100-
* ``latency_constraints = 0`` means the latency constraints have no relevance to placement.
1101-
* ``0 < latency_constraints < 1`` means the latency constraints are weighted equally to the sum of other placement cost components.
1102-
* ``latency_constraints > 1`` means the placement is increasingly dominated by reducing the latency constraints of the traffic flows.
1103-
1104-
**Default:** ``1``
1116+
**Default:** ``0.6``
11051117

11061118
.. option:: --noc_latency_weighting <float>
11071119

11081120
Controls the importance of reducing the latencies of the NoC traffic flows.
1109-
This value can be >=0,
1121+
This value can be >=0, where 0 would mean the latencies have no relevance to placement
1122+
Other positive numbers specify the importance of minimizing aggregate latency compared to other NoC-related cost terms.
1123+
Weighting factors for NoC-related cost terms are normalized internally. Therefore, their absolute values are not important, and
1124+
only their relative ratios determine the importance of each cost term.
11101125

1111-
* ``latency = 0`` means the latencies have no relevance to placement.
1112-
* ``0 < latency < 1`` means the latencies are weighted equally to the sum of other placement cost components.
1113-
* ``latency > 1`` means the placement is increasingly dominated by reducing the latencies of the traffic flows.
1114-
1115-
**Default:** ``0.05``
1126+
**Default:** ``0.02``
1127+
1128+
.. option:: --noc_congestion_weighting <float>
1129+
1130+
Controls the importance of reducing the congestion of the NoC links.
1131+
This value can be >=0, where 0 would mean the congestion has no relevance to placement.
1132+
Other positive numbers specify the importance of minimizing congestion compared to other NoC-related cost terms.
1133+
Weighting factors for NoC-related cost terms are normalized internally. Therefore, their absolute values are not important, and
1134+
only their relative ratios determine the importance of each cost term.
1135+
1136+
**Default:** ``0.25``
11161137

11171138
.. option:: --noc_swap_percentage <float>
11181139

@@ -1122,7 +1143,7 @@ The following options are only used when FPGA device and netlist contain a NoC r
11221143
* ``0`` means NoC blocks will be moved at the same rate as other blocks.
11231144
* ``100`` means all swaps attempted by the placer are NoC router blocks.
11241145

1125-
**Default:** ``40``
1146+
**Default:** ``0``
11261147

11271148
.. option:: --noc_placement_file_name <file>
11281149

libs/libvtrutil/src/vtr_vector.h

Lines changed: 34 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <cstddef>
55
#include <iterator>
66
#include <algorithm>
7+
#include <tuple>
8+
79
#include "vtr_range.h"
810

911
namespace vtr {
@@ -56,9 +58,6 @@ class vector : private std::vector<V, Allocator> {
5658
class key_iterator;
5759
typedef vtr::Range<key_iterator> key_range;
5860

59-
class pair_iterator;
60-
typedef vtr::Range<pair_iterator> pair_range;
61-
6261
public:
6362
//Pass through std::vector's types
6463
using typename storage::allocator_type;
@@ -157,16 +156,41 @@ class vector : private std::vector<V, Allocator> {
157156
}
158157

159158
/**
160-
* @brief Returns a range containing the key-value pairs.
159+
* @brief Provides an iterable object to enumerate the vector.
160+
*
161+
* This function allows for easy enumeration, yielding a tuple of (index, element)
162+
* pairs in each iteration. It is similar in functionality to Python's `enumerate()`.
163+
* This function can be used in range-based with structured binding to iterate over
164+
* indices and values at the same time.
161165
*
162-
* This function returns a range object that represents the sequence of key-value
163-
* pairs within the vector. The range can be used to iterate over the pairs using
164-
* standard range-based loops or algorithms.
166+
* vtr::vector<IdType, ValueType> vec;
167+
* for (const auto& [idx, value] : vec) {
168+
* ...
169+
* }
170+
* It should be noted that value is returned by reference even if "&"
171+
* does not appear after auto keyword. However, it is recommended to use "&"
172+
* explicitly to avoid any confusion about value's scope.
165173
*
166-
* @return A `pair_range` object representing the range of key-value pairs.
174+
* @ return An iterable wrapper that can be used in a range-based for loop to obtain
175+
* (index, element) pairs.
167176
*/
168-
pair_range pairs() const {
169-
return vtr::make_range(pair_begin(), pair_end());
177+
auto pairs() const {
178+
struct enumerated_iterator {
179+
key_type i;
180+
vector::const_iterator iter;
181+
182+
bool operator!=(const enumerated_iterator& other) const { return iter != other.iter; }
183+
void operator++() { i = key_type(size_t(i) + 1); iter++; }
184+
std::tuple<key_type, decltype(*iter)&> operator*() { return std::tie(i, *iter); }
185+
};
186+
187+
struct enumerated_wrapper {
188+
const vector& vec;
189+
auto begin() { return enumerated_iterator{ key_type(0), vec.begin() }; }
190+
auto end() { return enumerated_iterator{ key_type(vec.size()), vec.end() }; }
191+
};
192+
193+
return enumerated_wrapper{ *this };
170194
}
171195

172196
public:
@@ -218,59 +242,9 @@ class vector : private std::vector<V, Allocator> {
218242
value_type value_;
219243
};
220244

221-
/**
222-
* @brief A bidirectional iterator for a vtr:vector object.
223-
*
224-
* The `pair_iterator` class provides a way to iterate over key-value pairs
225-
* within a vtr::vector container. It supports bidirectional iteration,
226-
* allowing the user to traverse the container both forwards and backwards.
227-
*/
228-
class pair_iterator {
229-
public:
230-
using iterator_category = std::bidirectional_iterator_tag;
231-
using difference_type = std::ptrdiff_t;
232-
using value_type = std::pair<key_type, V>;
233-
using pointer = value_type*;
234-
using reference = value_type&;
235-
236-
/// @brief constructor
237-
pair_iterator(vector<K, V, Allocator>& vec, key_type init)
238-
: vec_(vec), value_(init, vec[init]) {}
239-
240-
/// @brief ++ operator
241-
pair_iterator& operator++() {
242-
value_ = std::make_pair(key_type(size_t(value_.first) + 1), vec_[key_type(size_t(value_.first) + 1)]);
243-
return *this;
244-
}
245-
/// @brief -- operator
246-
pair_iterator& operator--() {
247-
value_ = std::make_pair(key_type(size_t(value_.first) - 1), vec_[key_type(size_t(value_.first) - 1)]);
248-
return *this;
249-
}
250-
/// @brief dereference operator
251-
reference operator*() { return value_; }
252-
/// @brief -> operator
253-
pointer operator->() { return &value_; }
254-
255-
/// @brief == operator
256-
friend bool operator==(const pair_iterator& lhs, const pair_iterator& rhs) { return lhs.value_.first == rhs.value_.first; }
257-
/// @brief != operator
258-
friend bool operator!=(const pair_iterator& lhs, const pair_iterator& rhs) { return !(lhs == rhs); }
259-
260-
private:
261-
/// @brief Reference to the vector of key-value pairs.
262-
vector<K, V, Allocator>& vec_;
263-
// @brief The current key-value pair being pointed to by the iterator.
264-
value_type value_;
265-
};
266-
267245
private:
268246
key_iterator key_begin() const { return key_iterator(key_type(0)); }
269247
key_iterator key_end() const { return key_iterator(key_type(size())); }
270-
271-
pair_iterator pair_begin() const { return pair_iterator(*const_cast<vector<K, V, Allocator>*>(this), key_type(0)); }
272-
pair_iterator pair_end() const { return pair_iterator(*const_cast<vector<K, V, Allocator>*>(this), key_type(size())); }
273248
};
274-
275249
} // namespace vtr
276250
#endif

vpr/test/test_odd_even_routing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "channel_dependency_graph.h"
66

77
#include <random>
8+
#include <iostream>
89

910
namespace {
1011

@@ -225,7 +226,7 @@ TEST_CASE("test_route_flow", "[vpr_noc_odd_even_routing]") {
225226
compare_routes(golden_path, found_path, noc_model);
226227
}
227228

228-
SECTION("Test case where multiple traffic flows are router, and routes are checked for turn legality and deadlock freedom.") {
229+
SECTION("Test case where multiple traffic flows are routed, and routes are checked for turn legality and deadlock freedom.") {
229230
std::random_device device;
230231
std::mt19937 rand_num_gen(device());
231232
std::uniform_int_distribution<std::mt19937::result_type> dist(0, 99);
@@ -248,7 +249,6 @@ TEST_CASE("test_route_flow", "[vpr_noc_odd_even_routing]") {
248249
vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> traffic_flow_routes(traffic_flow_storage.get_number_of_traffic_flows());
249250

250251
for (const auto& [id, traffic_flow] : traffic_flow_storage.get_all_traffic_flows().pairs()) {
251-
252252
NocRouterId src_router_id = noc_model.get_router_at_grid_location(block_locs[traffic_flow.source_router_cluster_id].loc);
253253
NocRouterId dst_router_id = noc_model.get_router_at_grid_location(block_locs[traffic_flow.sink_router_cluster_id].loc);
254254

0 commit comments

Comments
 (0)