Skip to content

Commit 3eb220f

Browse files
authored
Merge branch 'master' into ipa_end_user_doc
2 parents 86eca51 + 9dd5ff6 commit 3eb220f

File tree

111 files changed

+3915
-3089
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+3915
-3089
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,17 @@ jobs:
184184
include: [
185185
{
186186
name: 'Basic',
187-
params: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on',
187+
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on',
188188
suite: 'vtr_reg_basic'
189189
},
190190
{
191191
name: 'Basic_odin',
192-
params: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DWITH_PARMYS=OFF -DWITH_ODIN=on',
192+
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DWITH_PARMYS=OFF -DWITH_ODIN=on',
193193
suite: 'vtr_reg_basic_odin'
194194
},
195195
{
196196
name: 'Basic with NO_GRAPHICS',
197-
params: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVPR_USE_EZGL=off',
197+
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVPR_USE_EZGL=off',
198198
suite: 'vtr_reg_basic'
199199
},
200200
{
@@ -204,32 +204,32 @@ jobs:
204204
},
205205
{
206206
name: 'Basic with CAPNPROTO disabled',
207-
params: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVTR_ENABLE_CAPNPROTO=off',
207+
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVTR_ENABLE_CAPNPROTO=off',
208208
suite: 'vtr_reg_basic'
209209
},
210210
{
211211
name: 'Basic with VTR_ENABLE_DEBUG_LOGGING',
212-
params: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVTR_ENABLE_DEBUG_LOGGING=on',
212+
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVTR_ENABLE_DEBUG_LOGGING=on',
213213
suite: 'vtr_reg_basic'
214214
},
215215
{
216216
name: 'Basic_odin with VTR_ENABLE_DEBUG_LOGGING',
217-
params: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVTR_ENABLE_DEBUG_LOGGING=on -DWITH_PARMYS=OFF -DWITH_ODIN=on',
217+
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVTR_ENABLE_DEBUG_LOGGING=on -DWITH_PARMYS=OFF -DWITH_ODIN=on',
218218
suite: 'vtr_reg_basic_odin'
219219
},
220220
{
221221
name: 'Strong',
222-
params: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on',
222+
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on',
223223
suite: 'vtr_reg_strong'
224224
},
225225
{
226226
name: 'Strong_odin',
227-
params: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DWITH_PARMYS=OFF -DWITH_ODIN=on',
227+
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DWITH_PARMYS=OFF -DWITH_ODIN=on',
228228
suite: 'vtr_reg_strong_odin'
229229
},
230230
{
231231
name: 'Valgrind Memory',
232-
params: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DWITH_ODIN=on',
232+
params: '-DCMAKE_COMPILE_WARNING_AS_ERROR=on -DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DWITH_ODIN=on',
233233
suite: 'vtr_reg_valgrind_small'
234234
}
235235
]

README.developers.md

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,70 @@ and should be used when making changes to Odin.
344344
## Unit Tests
345345

346346
VTR also has a limited set of unit tests, which can be run with:
347+
347348
```shell
348349
#From the VTR root directory
349350
$ make && make test
350351
```
351352

353+
This will run `test_vtrutil`, `test_vpr`, `test_fasm`, and `test_archfpga`. Each test suite is added in their CMake
354+
files.
355+
356+
### Running Individual Testers
357+
358+
To run one of the four testers listed above on its own, navigate to the appropriate folder:
359+
360+
| Test | Directory |
361+
|-----------------|------------------------------------|
362+
| `test_archfpga` | `$VTR_ROOT/build/libs/libarchfpga` |
363+
| `test_vtrutil` | `$VTR_ROOT/build/libs/libvtrutil` |
364+
| `test_fasm` | `$VTR_ROOT/build/utils/fasm` |
365+
| `test_vpr` | `$VTR_ROOT/build/vpr` |
366+
367+
To see tester options, run it with `-h`:
368+
369+
```shell
370+
# Using test_vpr as an example
371+
# From $VTR_ROOT/build/vpr
372+
$ ./test_vpr -h
373+
```
374+
375+
To see the names of each unit test, use `--list-tests`:
376+
377+
```shell
378+
# From $VTR_ROOT/build/vpr
379+
$ ./test_vpr --list-tests
380+
```
381+
382+
The output should look similar to this:
383+
384+
```shell
385+
All available test cases:
386+
test_route_flow
387+
[vpr_noc_bfs_routing]
388+
test_find_block_with_matching_name
389+
[vpr_clustered_netlist]
390+
connection_router
391+
[vpr]
392+
binary_heap
393+
[vpr]
394+
edge_groups_create_sets
395+
[vpr]
396+
read_interchange_models
397+
[vpr]
398+
399+
... # many more test cases
400+
401+
52 test cases
402+
```
403+
404+
To run specific unit tests, pass them as arguments. For example:
405+
406+
```shell
407+
# From $VTR_ROOT/build/vpr
408+
$ ./test_vpr test_route_flow connection_router
409+
```
410+
352411
# Evaluating Quality of Result (QoR) Changes
353412
VTR uses highly tuned and optimized algorithms and data structures.
354413
Changes which effect these can have significant impacts on the quality of VTR's design implementations (timing, area etc.) and VTR's run-time/memory usage.
@@ -972,6 +1031,64 @@ This describes adding a test to `vtr_reg_strong`, but the process is similar for
9721031
$ git commit
9731032
```
9741033

1034+
## Creating Unit Tests
1035+
1036+
You can find the source code for the unit tests in their respective directories. New unit tests must also be created in
1037+
these directories.
1038+
1039+
| Test | Directory |
1040+
|-----------------|-----------------------------------|
1041+
| `test_archfpga` | `$VTR_ROOT/libs/libarchfpga/test` |
1042+
| `test_vtrutil` | `$VTR_ROOT/libs/libvtrutil/test` |
1043+
| `test_fasm` | `$VTR_ROOT/utils/fasm/test` |
1044+
| `test_vpr` | `$VTR_ROOT/vpr/test` |
1045+
1046+
VTR uses [Catch2](https://github.com/catchorg/Catch2) for its unit testing framework. For a full tutorial of how to use
1047+
the framework, see `$VTR_ROOT/libs/EXTERNAL/libcatch2/docs/Readme.md`.
1048+
1049+
### Example: Creating and Running a VPR Test Case
1050+
1051+
Navigate to `$VTR_ROOT/vpr/test`.
1052+
1053+
```shell
1054+
$ cd $VTR_ROOT/vpr/test
1055+
```
1056+
1057+
From here, let's create and open a new file `test_new_vpr.cpp` (begin the file name with `test_`). Be sure to `#include "catch2/catch_test_macros.hpp"`.
1058+
Introduce a test case using the `TEST_CASE` macro, and include a name and a tag. For boolean assertions, use `REQUIRE`.
1059+
1060+
```shell
1061+
#include "catch2/catch_test_macros.hpp"
1062+
1063+
// To choose a tag (written with square brackets "[tag]"), see examples from when you run ./test_vpr
1064+
// --list-tests in the tester exectuable directory, as shown earlier. A good default tag name is the name
1065+
// of the tester: in this case, [vpr].
1066+
TEST_CASE("a_vpr_test_name", "[vpr]") {
1067+
int x = 0;
1068+
REQUIRE(x == 0);
1069+
}
1070+
```
1071+
1072+
To run our test case, we must navigate back to `$VTR_ROOT/build/vpr` (from the table
1073+
under [Running Individual Testers](#running-individual-testers)). Since we created a test, we need to rebuild the
1074+
tester. Then, we can run our test.
1075+
1076+
```shell
1077+
$ cd $VTR_ROOT/build/vpr
1078+
$ make // rebuild tester
1079+
$ ./test_vpr a_vpr_test_name // run new unit test
1080+
```
1081+
1082+
Output:
1083+
1084+
```shell
1085+
Filters: "a_vpr_test_name"
1086+
Randomness seeded to: 2089861684
1087+
===============================================================================
1088+
All tests passed (1 assertion in 1 test case)
1089+
```
1090+
1091+
9751092
# Debugging Aids
9761093
VTR has support for several additional tools/features to aid debugging.
9771094
@@ -1352,5 +1469,4 @@ The following outlines the procedure to following when making an official VTR re
13521469
* GitHub will automatically create a release based on the tag
13531470
* Add the new change log entry to the [GitHub release description](https://github.com/verilog-to-routing/vtr-verilog-to-routing/releases)
13541471
* Update the [ReadTheDocs configuration](https://readthedocs.org/projects/vtr/versions/) to build and serve documentation for the relevant tag (e.g. `v8.0.0`)
1355-
* Send a release announcement email to the [vtr-announce](mailto:[email protected]) mailing list (make sure to thank all contributors!)
1356-
1472+
* Send a release announcement email to the [vtr-announce](mailto:[email protected]) mailing list (make sure to thank all contributors!)

libs/libarchfpga/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ target_link_libraries(read_arch libarchfpga)
5757

5858
#Supress IPO link warnings if IPO is enabled
5959
get_target_property(READ_ARCH_USES_IPO read_arch INTERPROCEDURAL_OPTIMIZATION)
60-
if (READ_ARCH_USES_IPO)
60+
if(READ_ARCH_USES_IPO)
6161
set_property(TARGET read_arch APPEND PROPERTY LINK_FLAGS ${IPO_LINK_WARN_SUPRESS_FLAGS})
6262
endif()
6363

@@ -70,3 +70,8 @@ install(FILES ${LIB_HEADERS} DESTINATION include/libarchfpga)
7070
file(GLOB_RECURSE TEST_SOURCES test/*.cpp)
7171
add_executable(test_archfpga ${TEST_SOURCES})
7272
target_link_libraries(test_archfpga Catch2::Catch2WithMain libarchfpga)
73+
74+
add_test(NAME test_archfpga
75+
COMMAND test_archfpga
76+
--colour-mode ansi
77+
)

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,28 @@
55

66
#ifdef VTR_ENABLE_CAPNPROTO
77

8-
#include <algorithm>
9-
#include <kj/std/iostream.h>
10-
#include <limits>
11-
#include <map>
12-
#include <regex>
13-
#include <set>
14-
#include <stdlib.h>
15-
#include <string>
16-
#include <string.h>
17-
#include <zlib.h>
18-
#include <sstream>
19-
20-
#include "vtr_assert.h"
21-
#include "vtr_digest.h"
22-
#include "vtr_log.h"
23-
#include "vtr_memory.h"
24-
#include "vtr_util.h"
25-
26-
#include "arch_check.h"
27-
#include "arch_error.h"
28-
#include "arch_util.h"
29-
#include "arch_types.h"
30-
8+
# include <algorithm>
9+
# include <kj/std/iostream.h>
10+
# include <limits>
11+
# include <map>
12+
# include <regex>
13+
# include <set>
14+
# include <stdlib.h>
15+
# include <string>
16+
# include <string.h>
17+
# include <zlib.h>
18+
# include <sstream>
19+
20+
# include "vtr_assert.h"
21+
# include "vtr_digest.h"
22+
# include "vtr_log.h"
23+
# include "vtr_memory.h"
24+
# include "vtr_util.h"
25+
26+
# include "arch_check.h"
27+
# include "arch_error.h"
28+
# include "arch_util.h"
29+
# include "arch_types.h"
3130

3231
/*
3332
* FPGA Interchange Device frontend
@@ -2503,7 +2502,7 @@ struct ArchReader {
25032502
}
25042503
};
25052504

2506-
#endif // VTR_ENABLE_CAPNPROTO
2505+
#endif // VTR_ENABLE_CAPNPROTO
25072506

25082507
void FPGAInterchangeReadArch(const char* FPGAInterchangeDeviceFile,
25092508
const bool /*timing_enabled*/,
@@ -2551,12 +2550,12 @@ void FPGAInterchangeReadArch(const char* FPGAInterchangeDeviceFile,
25512550

25522551
ArchReader reader(arch, device_reader, FPGAInterchangeDeviceFile, PhysicalTileTypes, LogicalBlockTypes);
25532552
reader.read_arch();
2554-
#else // VTR_ENABLE_CAPNPROTO
2553+
#else // VTR_ENABLE_CAPNPROTO
25552554
// If CAPNPROTO is disabled, throw an error.
25562555
(void)FPGAInterchangeDeviceFile;
25572556
(void)arch;
25582557
(void)PhysicalTileTypes;
25592558
(void)LogicalBlockTypes;
25602559
throw vtr::VtrError("Unable to read FPGA interchange if CAPNPROTO is not enabled", __FILE__, __LINE__);
2561-
#endif // VTR_ENABLE_CAPNPROTO
2560+
#endif // VTR_ENABLE_CAPNPROTO
25622561
}

libs/libarchfpga/src/read_fpga_interchange_arch.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
#ifdef VTR_ENABLE_CAPNPROTO
77

8-
#include "DeviceResources.capnp.h"
9-
#include "LogicalNetlist.capnp.h"
10-
#include "capnp/serialize.h"
11-
#include "capnp/serialize-packed.h"
12-
#include <fcntl.h>
13-
#include <unistd.h>
14-
15-
#endif // VTR_ENABLE_CAPNPROTO
8+
# include "DeviceResources.capnp.h"
9+
# include "LogicalNetlist.capnp.h"
10+
# include "capnp/serialize.h"
11+
# include "capnp/serialize-packed.h"
12+
# include <fcntl.h>
13+
# include <unistd.h>
14+
15+
#endif // VTR_ENABLE_CAPNPROTO
1616

1717
#ifdef __cplusplus
1818
extern "C" {

libs/librrgraph/src/base/rr_graph_obj.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ void RRGraph::set_node_segment(const RRNodeId& node, const RRSegmentId& segment_
10411041
*/
10421042
void RRGraph::partition_node_in_edges(const RRNodeId& node) {
10431043
//Partition the edges so the first set of edges are all configurable, and the later are not
1044-
auto first_non_config_edge = std::partition(node_in_edges_[node].begin(), node_in_edges_[node].end(),
1044+
auto first_non_config_edge = std::stable_partition(node_in_edges_[node].begin(), node_in_edges_[node].end(),
10451045
[&](const RREdgeId edge) { return edge_is_configurable(edge); }); /* Condition to partition edges */
10461046

10471047
size_t num_conf_edges = std::distance(node_in_edges_[node].begin(), first_non_config_edge);
@@ -1060,7 +1060,7 @@ void RRGraph::partition_node_in_edges(const RRNodeId& node) {
10601060
*/
10611061
void RRGraph::partition_node_out_edges(const RRNodeId& node) {
10621062
//Partition the edges so the first set of edges are all configurable, and the later are not
1063-
auto first_non_config_edge = std::partition(node_out_edges_[node].begin(), node_out_edges_[node].end(),
1063+
auto first_non_config_edge = std::stable_partition(node_out_edges_[node].begin(), node_out_edges_[node].end(),
10641064
[&](const RREdgeId edge) { return edge_is_configurable(edge); }); /* Condition to partition edges */
10651065

10661066
size_t num_conf_edges = std::distance(node_out_edges_[node].begin(), first_non_config_edge);

libs/librrgraph/src/base/rr_node_impl.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,35 @@
33
// This file provides the inline proxy implemenation for t_rr_node.
44
// See the t_rr_node class comment for additional details.
55

6-
#include "rr_node_types.h"
6+
#include <cstddef>
7+
#include <iterator>
78
#include "rr_node.h"
89
#include "rr_graph_storage.h"
910

10-
class node_idx_iterator : public std::iterator<std::bidirectional_iterator_tag, const t_rr_node> {
11+
class node_idx_iterator {
1112
public:
13+
using iterator_category = std::bidirectional_iterator_tag;
14+
using difference_type = std::ptrdiff_t;
15+
using value_type = const t_rr_node;
16+
using pointer = value_type*;
17+
using reference = value_type&;
18+
1219
node_idx_iterator(t_rr_node value)
1320
: value_(value) {}
1421

15-
iterator operator++() {
22+
node_idx_iterator& operator++() {
1623
value_.next_node();
1724
return *this;
1825
}
19-
iterator operator--() {
26+
node_idx_iterator& operator--() {
2027
value_.prev_node();
2128
return *this;
2229
}
2330
reference operator*() const { return value_; }
2431
pointer operator->() const { return &value_; }
2532

26-
friend bool operator==(const node_idx_iterator lhs, const node_idx_iterator rhs) { return lhs.value_.id() == rhs.value_.id(); }
27-
friend bool operator!=(const node_idx_iterator lhs, const node_idx_iterator rhs) { return !(lhs == rhs); }
33+
friend bool operator==(const node_idx_iterator& lhs, const node_idx_iterator& rhs) { return lhs.value_.id() == rhs.value_.id(); }
34+
friend bool operator!=(const node_idx_iterator& lhs, const node_idx_iterator& rhs) { return !(lhs == rhs); }
2835

2936
private:
3037
t_rr_node value_;

0 commit comments

Comments
 (0)