Skip to content

Commit a3e6a37

Browse files
authored
Merge branch 'master' into bug-fix-asymmetric-grid-bidirectional-routing
2 parents 8281c7b + 72af920 commit a3e6a37

File tree

84 files changed

+8948
-615
lines changed

Some content is hidden

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

84 files changed

+8948
-615
lines changed

libs/EXTERNAL/libargparse/src/argparse.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <algorithm>
2-
#include <array>
32
#include <list>
43
#include <cassert>
54
#include <string>
65
#include <set>
76
#include <limits>
7+
#include <utility>
88

99
#include "argparse.hpp"
1010
#include "argparse_util.hpp"
@@ -16,16 +16,16 @@ namespace argparse {
1616
* ArgumentParser
1717
*/
1818

19-
ArgumentParser::ArgumentParser(std::string prog_name, std::string description_str, std::ostream& os)
20-
: description_(description_str)
19+
ArgumentParser::ArgumentParser(const std::string& prog_name, std::string description_str, std::ostream& os)
20+
: description_(std::move(description_str))
2121
, formatter_(new DefaultFormatter())
2222
, os_(os)
2323
{
2424
prog(prog_name);
2525
argument_groups_.push_back(ArgumentGroup("arguments"));
2626
}
2727

28-
ArgumentParser& ArgumentParser::prog(std::string prog_name, bool basename_only) {
28+
ArgumentParser& ArgumentParser::prog(const std::string& prog_name, bool basename_only) {
2929
if (basename_only) {
3030
prog_ = basename(prog_name);
3131
} else {
@@ -35,17 +35,17 @@ namespace argparse {
3535
}
3636

3737
ArgumentParser& ArgumentParser::version(std::string version_str) {
38-
version_ = version_str;
38+
version_ = std::move(version_str);
3939
return *this;
4040
}
4141

4242
ArgumentParser& ArgumentParser::epilog(std::string epilog_str) {
43-
epilog_ = epilog_str;
43+
epilog_ = std::move(epilog_str);
4444
return *this;
4545
}
4646

4747
ArgumentGroup& ArgumentParser::add_argument_group(std::string description_str) {
48-
argument_groups_.push_back(ArgumentGroup(description_str));
48+
argument_groups_.push_back(ArgumentGroup(std::move(description_str)));
4949
return argument_groups_[argument_groups_.size() - 1];
5050
}
5151

@@ -72,7 +72,7 @@ namespace argparse {
7272
void ArgumentParser::parse_args_throw(int argc, const char* const* argv) {
7373
std::vector<std::string> arg_strs;
7474
for (int i = 1; i < argc; ++i) {
75-
arg_strs.push_back(argv[i]);
75+
arg_strs.emplace_back(argv[i]);
7676
}
7777

7878
parse_args_throw(arg_strs);
@@ -241,7 +241,7 @@ namespace argparse {
241241
} else if (arg->nargs() == '+' || arg->nargs() == '*') {
242242
if (arg->nargs() == '+') {
243243
assert(nargs_read >= 1);
244-
assert(values.size() >= 1);
244+
assert(!values.empty());
245245
}
246246

247247
for (const auto& value : values) {
@@ -410,11 +410,11 @@ namespace argparse {
410410
* ArgumentGroup
411411
*/
412412
ArgumentGroup::ArgumentGroup(std::string name_str)
413-
: name_(name_str)
413+
: name_(std::move(name_str))
414414
{}
415415

416416
ArgumentGroup& ArgumentGroup::epilog(std::string str) {
417-
epilog_ = str;
417+
epilog_ = std::move(str);
418418
return *this;
419419
}
420420
std::string ArgumentGroup::name() const { return name_; }
@@ -425,10 +425,10 @@ namespace argparse {
425425
* Argument
426426
*/
427427
Argument::Argument(std::string long_opt, std::string short_opt)
428-
: long_opt_(long_opt)
429-
, short_opt_(short_opt) {
428+
: long_opt_(std::move(long_opt))
429+
, short_opt_(std::move(short_opt)) {
430430

431-
if (long_opt_.size() < 1) {
431+
if (long_opt_.empty()) {
432432
throw ArgParseError("Argument must be at least one character long");
433433
}
434434

@@ -445,7 +445,7 @@ namespace argparse {
445445
}
446446

447447
Argument& Argument::help(std::string help_str) {
448-
help_ = help_str;
448+
help_ = std::move(help_str);
449449
return *this;
450450
}
451451

@@ -476,12 +476,12 @@ namespace argparse {
476476
}
477477

478478
Argument& Argument::metavar(std::string metavar_str) {
479-
metavar_ = metavar_str;
479+
metavar_ = std::move(metavar_str);
480480
return *this;
481481
}
482482

483483
Argument& Argument::choices(std::vector<std::string> choice_values) {
484-
choices_ = choice_values;
484+
choices_ = std::move(choice_values);
485485
return *this;
486486
}
487487

@@ -536,7 +536,7 @@ namespace argparse {
536536
}
537537

538538
Argument& Argument::group_name(std::string grp) {
539-
group_name_ = grp;
539+
group_name_ = std::move(grp);
540540
return *this;
541541
}
542542

libs/EXTERNAL/libargparse/src/argparse.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ namespace argparse {
3434
class ArgumentParser {
3535
public:
3636
//Initializes an argument parser
37-
ArgumentParser(std::string prog_name, std::string description_str=std::string(), std::ostream& os=std::cout);
37+
ArgumentParser(const std::string& prog_name, std::string description_str=std::string(), std::ostream& os=std::cout);
3838

3939
//Overrides the program name
40-
ArgumentParser& prog(std::string prog, bool basename_only=true);
40+
ArgumentParser& prog(const std::string& prog, bool basename_only=true);
4141

4242
//Sets the program version
4343
ArgumentParser& version(std::string version);

libs/librrgraph/src/base/rr_graph_storage.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ class edge_sort_iterator {
155155
using pointer = edge_swapper*;
156156
using difference_type = ssize_t;
157157

158+
// In order for this class to be used as an iterator within the std library,
159+
// it needs to "act" like a pointer. One thing that it should do is that a
160+
// const variable of this type should be de-referenceable. Therefore, this
161+
// method should be const method; however, this requires modifying the class
162+
// and may yield worst performance. For now the std::stable_sort allows this
163+
// but in the future it may not. If this breaks, this is why.
164+
// See issue #2517 and PR #2522
158165
edge_swapper& operator*() {
159166
return this->swapper_;
160167
}
@@ -419,7 +426,7 @@ size_t t_rr_graph_storage::count_rr_switches(
419426
// values.
420427
//
421428
// This sort is safe to do because partition_edges() has not been invoked yet.
422-
std::sort(
429+
std::stable_sort(
423430
edge_sort_iterator(this, 0),
424431
edge_sort_iterator(this, edge_dest_node_.size()),
425432
edge_compare_dest_node());
@@ -527,7 +534,7 @@ void t_rr_graph_storage::partition_edges(const vtr::vector<RRSwitchId, t_rr_swit
527534
// by assign_first_edges()
528535
// - Edges within a source node have the configurable edges before the
529536
// non-configurable edges.
530-
std::sort(
537+
std::stable_sort(
531538
edge_sort_iterator(this, 0),
532539
edge_sort_iterator(this, edge_src_node_.size()),
533540
edge_compare_src_node_and_configurable_first(rr_switches));

libs/libvtrutil/cmake/modules/configure_version.cmake

+11-8
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
#Figure out the git revision
55
find_package(Git QUIET)
66
if(GIT_FOUND)
7-
exec_program(${GIT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}
8-
ARGS describe --always --long --dirty
9-
OUTPUT_VARIABLE VTR_VCS_REVISION
10-
RETURN_VALUE GIT_DESCRIBE_RETURN_VALUE)
7+
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --long --dirty
8+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
9+
OUTPUT_VARIABLE VTR_VCS_REVISION
10+
OUTPUT_STRIP_TRAILING_WHITESPACE
11+
RESULT_VARIABLE GIT_DESCRIBE_RETURN_VALUE)
1112

1213
if(NOT GIT_DESCRIBE_RETURN_VALUE EQUAL 0)
1314
#Git describe failed, usually this means we
@@ -18,10 +19,12 @@ if(GIT_FOUND)
1819

1920
#Call again with exclude to get the revision excluding any tags
2021
#(i.e. just the commit ID and dirty flag)
21-
exec_program(${GIT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}
22-
ARGS describe --always --long --dirty --exclude '*'
23-
OUTPUT_VARIABLE VTR_VCS_REVISION_SHORT
24-
RETURN_VALUE GIT_DESCRIBE_RETURN_VALUE)
22+
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --long --dirty --exclude '*'
23+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
24+
OUTPUT_VARIABLE VTR_VCS_REVISION_SHORT
25+
OUTPUT_STRIP_TRAILING_WHITESPACE
26+
RESULT_VARIABLE GIT_DESCRIBE_RETURN_VALUE)
27+
2528
if(NOT GIT_DESCRIBE_RETURN_VALUE EQUAL 0)
2629
#Git describe failed, usually this means we
2730
#aren't in a git repo -- so don't set a VCS

libs/libvtrutil/src/vtr_util.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ std::string string_fmt(const char* fmt, ...) {
125125

126126
///@brief Returns a std::string formatted using a printf-style format string taking an explicit va_list
127127
std::string vstring_fmt(const char* fmt, va_list args) {
128-
// We need to copy the args so we don't change them before the true formating
128+
// We need to copy the args so we don't change them before the true formatting
129129
va_list va_args_copy;
130130
va_copy(va_args_copy, args);
131131

libs/libvtrutil/test/test_array_view.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct test_tag;
88
using TestStrongId = vtr::StrongId<test_tag>;
99

1010
TEST_CASE("Array view", "[array_view/array_view]") {
11-
std::array<uint16_t, 10> arr;
11+
std::array<uint16_t, 10> arr = {0};
1212
vtr::array_view<uint16_t> arr_view(arr.data(), arr.size());
1313

1414
const vtr::array_view<uint16_t>& carr_view = arr_view;
@@ -56,7 +56,7 @@ TEST_CASE("Array view", "[array_view/array_view]") {
5656
}
5757

5858
TEST_CASE("Array view id", "[array_view/array_view_id]") {
59-
std::array<uint16_t, 10> arr;
59+
std::array<uint16_t, 10> arr = {0};
6060
vtr::array_view_id<TestStrongId, uint16_t> arr_view(arr.data(), arr.size());
6161

6262
const vtr::array_view_id<TestStrongId, uint16_t>& carr_view = arr_view;

utils/vqm2blif/src/base/cleanup.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void remove_one_lut_nodes ( busvec* buses, std::unordered_map<std::string, int>
297297
t_node_port_association* source_port;
298298
t_node_port_association* prev_port;
299299
netvec* prev_bus;
300-
t_net* prev_net;
300+
t_net* prev_net = nullptr;
301301

302302
netvec* vcc_bus = get_bus_from_hash (hash_table, const_cast<char*>("vcc"), buses);
303303
VTR_ASSERT(vcc_bus != NULL);
@@ -658,7 +658,7 @@ void verify_netlist ( t_node** nodes, int num_nodes, busvec* buses, std::unorder
658658
auto hash_entry = hash_table.find(ref_pin->name);
659659

660660
VTR_ASSERT(hash_entry != hash_table.end());
661-
VTR_ASSERT((unsigned int)hash_entry->second == i);
661+
VTR_ASSERT((unsigned int)hash_entry->second == (unsigned int)i);
662662

663663
for (int j = 0; (unsigned int)j < temp_bus->size(); j++){
664664
temp_net = &(temp_bus->at(j));
@@ -903,4 +903,4 @@ void reorganize_module_node_list(t_module* module)
903903
}
904904

905905
//============================================================================================
906-
//============================================================================================
906+
//============================================================================================

vpr/src/base/SetupVPR.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -735,13 +735,12 @@ static void SetupNocOpts(const t_options& Options, t_noc_opts* NocOpts) {
735735
NocOpts->noc_flows_file = Options.noc_flows_file;
736736
NocOpts->noc_routing_algorithm = Options.noc_routing_algorithm;
737737
NocOpts->noc_placement_weighting = Options.noc_placement_weighting;
738+
NocOpts->noc_aggregate_bandwidth_weighting = Options.noc_agg_bandwidth_weighting;
738739
NocOpts->noc_latency_constraints_weighting = Options.noc_latency_constraints_weighting;
739740
NocOpts->noc_latency_weighting = Options.noc_latency_weighting;
740741
NocOpts->noc_congestion_weighting = Options.noc_congestion_weighting;
741742
NocOpts->noc_swap_percentage = Options.noc_swap_percentage;
742743
NocOpts->noc_placement_file_name = Options.noc_placement_file_name;
743-
744-
return;
745744
}
746745

747746
static void find_ipin_cblock_switch_index(const t_arch& Arch, int& wire_to_arch_ipin_switch, int& wire_to_arch_ipin_switch_between_dice) {

vpr/src/base/ShowSetup.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ static void ShowPlacerOpts(const t_placer_opts& PlacerOpts,
608608
}
609609

610610
VTR_LOG("PlacerOpts.constraints_file: ");
611-
if (PlacerOpts.constraints_file == "") {
611+
if (PlacerOpts.constraints_file.empty()) {
612612
VTR_LOG("No constraints file given\n");
613613
} else {
614614
VTR_LOG("Using constraints file '%s'\n", PlacerOpts.constraints_file.c_str());
@@ -795,6 +795,7 @@ static void ShowNocOpts(const t_noc_opts& NocOpts) {
795795
VTR_LOG("NocOpts.noc_flows_file: %s\n", NocOpts.noc_flows_file.c_str());
796796
VTR_LOG("NocOpts.noc_routing_algorithm: %s\n", NocOpts.noc_routing_algorithm.c_str());
797797
VTR_LOG("NocOpts.noc_placement_weighting: %f\n", NocOpts.noc_placement_weighting);
798+
VTR_LOG("NocOpts.noc_aggregate_bandwidth_weighting: %f\n", NocOpts.noc_aggregate_bandwidth_weighting);
798799
VTR_LOG("NocOpts.noc_latency_constraints_weighting: %f\n", NocOpts.noc_latency_constraints_weighting);
799800
VTR_LOG("NocOpts.noc_latency_weighting: %f\n", NocOpts.noc_latency_weighting);
800801
VTR_LOG("NocOpts.noc_congestion_weighting: %f\n", NocOpts.noc_congestion_weighting);

vpr/src/base/read_options.cpp

+21-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include "argparse.hpp"
77

8-
#include "vtr_memory.h"
98
#include "vtr_log.h"
109
#include "vtr_util.h"
1110
#include "vtr_path.h"
@@ -14,7 +13,7 @@
1413
using argparse::ConvertedValue;
1514
using argparse::Provenance;
1615

17-
///@brief Read and process VPR's command-line aruments
16+
///@brief Read and process VPR's command-line arguments
1817
t_options read_options(int argc, const char** argv) {
1918
t_options args = t_options(); //Explicitly initialize for zero initialization
2019

@@ -1259,7 +1258,7 @@ struct ParsePostSynthNetlistUnconnOutputHandling {
12591258
}
12601259
};
12611260

1262-
argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& args) {
1261+
argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_options& args) {
12631262
std::string description =
12641263
"Implements the specified circuit onto the target FPGA architecture"
12651264
" by performing packing/placement/routing, and analyzes the result.\n"
@@ -2807,10 +2806,15 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
28072806
.help(
28082807
"Controls the algorithm used by the NoC to route packets.\n"
28092808
"* xy_routing: Uses the direction oriented routing algorithm. This is recommended to be used with mesh NoC topologies.\n"
2810-
"* bfs_routing: Uses the breadth first search algorithm. The objective is to find a route that uses a minimum number of links.\n"
2811-
"This can be used with any NoC topology\n")
2809+
"* bfs_routing: Uses the breadth first search algorithm. The objective is to find a route that uses a minimum number of links."
2810+
" This algorithm is not guaranteed to generate deadlock-free traffic flow routes, but can be used with any NoC topology\n"
2811+
"* west_first_routing: Uses the west-first routing algorithm. This is recommended to be used with mesh NoC topologies.\n"
2812+
"* north_last_routing: Uses the north-last routing algorithm. This is recommended to be used with mesh NoC topologies.\n"
2813+
"* negative_first_routing: Uses the negative-first routing algorithm. This is recommended to be used with mesh NoC topologies.\n"
2814+
"* odd_even_routing: Uses the odd-even routing algorithm. This is recommended to be used with mesh NoC topologies.\n")
28122815
.default_value("bfs_routing")
2813-
.choices({"xy_routing", "bfs_routing"})
2816+
.choices({"xy_routing", "bfs_routing", "west_first_routing", "north_last_routing", "negative_first_routing",
2817+
"odd_even_routing"})
28142818
.show_in(argparse::ShowIn::HELP_ONLY);
28152819

28162820
noc_grp.add_argument<double>(args.noc_placement_weighting, "--noc_placement_weighting")
@@ -2822,6 +2826,16 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
28222826
.default_value("5.0")
28232827
.show_in(argparse::ShowIn::HELP_ONLY);
28242828

2829+
noc_grp.add_argument<double>(args.noc_agg_bandwidth_weighting, "--noc_aggregate_bandwidth_weighting")
2830+
.help(
2831+
"Controls the importance of minimizing the NoC aggregate bandwidth.\n"
2832+
"This value can be >=0, where 0 would mean the aggregate bandwidth has no relevance to placement.\n"
2833+
"Other positive numbers specify the importance of minimizing the NoC aggregate bandwidth to other NoC-related cost terms.\n"
2834+
"Weighting factors for NoC-related cost terms are normalized internally. Therefore, their absolute values are not important, and"
2835+
"only their relative ratios determine the importance of each cost term.")
2836+
.default_value("0.38")
2837+
.show_in(argparse::ShowIn::HELP_ONLY);
2838+
28252839
noc_grp.add_argument<double>(args.noc_latency_constraints_weighting, "--noc_latency_constraints_weighting")
28262840
.help(
28272841
"Controls the importance of meeting all the NoC traffic flow latency constraints.\n"
@@ -2849,7 +2863,7 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
28492863
"Other positive numbers specify the importance of minimizing congestion to other NoC-related cost terms.\n"
28502864
"Weighting factors for NoC-related cost terms are normalized internally. Therefore, their absolute values are not important, and"
28512865
"only their relative ratios determine the importance of each cost term.")
2852-
.default_value("0.00")
2866+
.default_value("0.25")
28532867
.show_in(argparse::ShowIn::HELP_ONLY);
28542868

28552869
noc_grp.add_argument<double>(args.noc_swap_percentage, "--noc_swap_percentage")

vpr/src/base/read_options.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ struct t_options {
153153
argparse::ArgValue<std::string> noc_flows_file;
154154
argparse::ArgValue<std::string> noc_routing_algorithm;
155155
argparse::ArgValue<double> noc_placement_weighting;
156+
argparse::ArgValue<double> noc_agg_bandwidth_weighting;
156157
argparse::ArgValue<double> noc_latency_constraints_weighting;
157158
argparse::ArgValue<double> noc_latency_weighting;
158159
argparse::ArgValue<double> noc_congestion_weighting;
@@ -241,7 +242,7 @@ struct t_options {
241242
argparse::ArgValue<std::string> write_timing_summary;
242243
};
243244

244-
argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& args);
245+
argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_options& args);
245246
t_options read_options(int argc, const char** argv);
246247
void set_conditional_defaults(t_options& args);
247248
bool verify_args(const t_options& args);

vpr/src/draw/draw.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ void init_graphics_state(bool show_graphics_val,
204204
(void)route_type;
205205
(void)save_graphics;
206206
(void)graphics_commands;
207+
(void)is_flat;
207208
#endif // NO_GRAPHICS
208209
}
209210

0 commit comments

Comments
 (0)