Skip to content

Commit

Permalink
Merge pull request #495 from antmicro/master+wip-analysis
Browse files Browse the repository at this point in the history
"post-synthesis" netlist writing fix
  • Loading branch information
litghost committed May 26, 2020
2 parents 7d6424b + e190bf5 commit 8980e46
Show file tree
Hide file tree
Showing 38 changed files with 721 additions and 529 deletions.
4 changes: 2 additions & 2 deletions .github/kokoro/continuous/strong_sanitized.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

build_file: "vtr-verilog-to-routing/.github/kokoro/run-vtr.sh"

# 1 hour
timeout_mins: 60
# 2 hour
timeout_mins: 120

action {
define_artifacts {
Expand Down
4 changes: 2 additions & 2 deletions .github/kokoro/presubmit/strong_sanitized.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

build_file: "vtr-verilog-to-routing/.github/kokoro/run-vtr.sh"

# 1 hour
timeout_mins: 60
# 2 hour
timeout_mins: 120

action {
define_artifacts {
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
script:
- ./.github/travis/build.sh
#We skip QoR since we are only checking for errors in sanitizer runs
- travis_wait 30 ./run_reg_test.pl vtr_reg_basic -show_failures -skip_qor -j2
- travis_wait 50 ./run_reg_test.pl vtr_reg_basic -show_failures -skip_qor -j2
#Currently strong regression with sanitizers is disabled as it exceeds the maximum travis job run-time
#- stage: Test
#name: "Sanitized Strong Regression Tests"
Expand Down
18 changes: 18 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ apt-get install \
ctags
```

#### Using Nix ####

Although the recommended platform is Debian or Ubuntu, Nix can be used to build VTR on other platforms, such as MacOS.

If you don't have [Nix](https://nixos.org/nix/), you can [get it](https://nixos.org/nix/download.html) with:

```shell
$ curl -L https://nixos.org/nix/install | sh
```

These commands will set up dependencies for Linux and MacOS and build VTR:

```shell
#In the VTR root
$ nix-shell dev/nix/shell.nix
$ make
```

### Building using the Makefile wrapper ###
Run `make` from the root of the VTR source tree

Expand Down
1 change: 1 addition & 0 deletions ODIN_II/SRC/include/Hashtable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <stdlib.h>
#include <stdint.h>
#include <string>
#include <unordered_map>
#include <string>

Expand Down
23 changes: 8 additions & 15 deletions ODIN_II/SRC/include/odin_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,25 @@ extern const char* odin_error_STR[];
extern std::vector<std::pair<std::string, int>> include_file_names;
extern int delayed_errors;
// causes an interrupt in GDB
static inline void _verbose_assert(bool condition, const char* condition_str, const char* odin_file_name, long odin_line_number, const char* odin_function_name) {
fflush(stdout);
if (!condition) {
fprintf(stderr, "Assertion failed(%s)@[%s]%s::%ld \n", condition_str, odin_file_name, odin_function_name, odin_line_number);
fflush(stderr);
std::abort();
}
}
void _verbose_assert(bool condition, const char* condition_str, const char* odin_file_name, long odin_line_number, const char* odin_function_name);

#define oassert(condition) _verbose_assert(condition, #condition, __FILE__, __LINE__, __func__)

void _log_message(odin_error error_type, long column, long line_number, long file, bool soft_error, const char* function_file_name, long function_line, const char* function_name, const char* message, ...);

#define error_message(error_type, line_number, file, message, ...) \
_log_message(error_type, -1, line_number, file, true, __FILE__, __LINE__, __func__, message, __VA_ARGS__)
_log_message(error_type, -1, line_number, file, true, __FILE__, __LINE__, __PRETTY_FUNCTION__, message, __VA_ARGS__)

#define warning_message(error_type, line_number, file, message, ...) \
_log_message(error_type, -1, line_number, file, false, __FILE__, __LINE__, __func__, message, __VA_ARGS__)
_log_message(error_type, -1, line_number, file, false, __FILE__, __LINE__, __PRETTY_FUNCTION__, message, __VA_ARGS__)

#define possible_error_message(error_type, line_number, file, message, ...) \
_log_message(error_type, -1, line_number, file, !global_args.permissive.value(), __FILE__, __LINE__, __func__, message, __VA_ARGS__)
_log_message(error_type, -1, line_number, file, !global_args.permissive.value(), __FILE__, __LINE__, __PRETTY_FUNCTION__, message, __VA_ARGS__)

#define delayed_error_message(error_type, column, line_number, file, message, ...) \
{ \
_log_message(error_type, column, line_number, file, false, __FILE__, __LINE__, __func__, message, __VA_ARGS__); \
delayed_errors += 1; \
#define delayed_error_message(error_type, column, line_number, file, message, ...) \
{ \
_log_message(error_type, column, line_number, file, false, __FILE__, __LINE__, __PRETTY_FUNCTION__, message, __VA_ARGS__); \
delayed_errors += 1; \
}

void verify_delayed_error(odin_error error_type);
Expand Down
95 changes: 67 additions & 28 deletions ODIN_II/SRC/odin_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void verify_delayed_error(odin_error error_type) {
}
}

static std::string make_marker_from_str(std::string str, int column) {
static std::string make_marker_from_str(std::string str, unsigned long column) {
str.erase(column);
for (size_t i = 0; i < str.size(); i++) {
if (str[i] != ' ' && str[i] != '\t') {
Expand All @@ -40,36 +40,54 @@ static std::string make_marker_from_str(std::string str, int column) {
return str;
}

static void print_culprit_line(long column, long line_number, long file) {
static std::string get_culprit_line(long line_number, const char* file) {
std::string culprit_line = "";

if (file >= 0 && (size_t)file < include_file_names.size()
&& line_number >= 0) {
FILE* input_file = fopen(include_file_names[file].first.c_str(), "r");
if (input_file) {
bool copy_characters = false;
int current_line_number = 0;

for (;;) {
int c = fgetc(input_file);
if (EOF == c) {
break;
} else if ('\n' == c) {
++current_line_number;
if (line_number == current_line_number) {
copy_characters = true;
} else if (copy_characters) {
break;
}
FILE* input_file = fopen(file, "r");
if (input_file) {
bool copy_characters = false;
int current_line_number = 0;

for (;;) {
int c = fgetc(input_file);
if (EOF == c) {
break;
} else if ('\n' == c) {
++current_line_number;
if (line_number == current_line_number) {
copy_characters = true;
} else if (copy_characters) {
culprit_line.push_back(c);
break;
}
} else if (copy_characters) {
culprit_line.push_back(c);
}
fclose(input_file);
}
fprintf(stderr, "%s\n", culprit_line.c_str());
fclose(input_file);
}
return culprit_line;
}

static void print_culprit_line(long column, long line_number, const char* file) {
std::string culprit_line = get_culprit_line(line_number, file);
if (!culprit_line.empty()) {
int num_printed;
fprintf(stderr, "%ld: %n%s\n", line_number + 1, &num_printed, culprit_line.c_str());
if (column >= 0) {
fprintf(stderr, "%s\n", make_marker_from_str(culprit_line, column).c_str());
fprintf(stderr, "%s\n", make_marker_from_str(culprit_line, num_printed + column).c_str());
}
}
}

static void print_culprit_line_with_context(long target_line, const char* file, long num_context_lines) {
for (long curr_line = std::max(target_line - num_context_lines, 0l); curr_line <= target_line + num_context_lines; curr_line++) {
std::string culprit_line = get_culprit_line(curr_line, file);
if (!culprit_line.empty()) {
int num_printed;
fprintf(stderr, "%ld: %n%s\n", curr_line + 1, &num_printed, culprit_line.c_str());
if (curr_line == target_line) {
const unsigned long first_char_pos = culprit_line.find_first_not_of(" \t");
fprintf(stderr, "%s\n", make_marker_from_str(culprit_line, num_printed + first_char_pos).c_str());
}
}
}
}
Expand All @@ -94,7 +112,7 @@ void _log_message(odin_error error_type, long column, long line_number, long fil
file_name = file_name.substr(slash_location + 1);
}

fprintf(stderr, " %s::%ld", file_name.c_str(), line_number + 1);
fprintf(stderr, " %s:%ld", file_name.c_str(), line_number + 1);
}

if (message != NULL) {
Expand All @@ -107,8 +125,29 @@ void _log_message(odin_error error_type, long column, long line_number, long fil
fprintf(stderr, "\n");
}

print_culprit_line(column, line_number, file);
if (file >= 0 && (size_t)file < include_file_names.size()
&& line_number >= 0) {
print_culprit_line(column, line_number, include_file_names[file].first.c_str());
}

fflush(stderr);
_verbose_assert(!fatal_error, "", function_file_name, function_line, function_name);
_verbose_assert(!fatal_error, NULL, function_file_name, function_line, function_name);
}

void _verbose_assert(bool condition, const char* condition_str, const char* odin_file_name, long odin_line_number, const char* odin_function_name) {
fflush(stdout);
if (!condition) {
fprintf(stderr, "%s:%ld: %s: ", odin_file_name, odin_line_number, odin_function_name);
if (condition_str) {
// We are an assertion, print the condition that failed and which line it occurred on
fprintf(stderr, "Assertion %s failed\n", condition_str);
// odin_line_number-1 since __LINE__ starts from 1
print_culprit_line_with_context(odin_line_number - 1, odin_file_name, 2);
} else {
// We are a parsing error, dont print the culprit line
fprintf(stderr, "Fatal error\n");
}
fflush(stderr);
std::abort();
}
}
6 changes: 3 additions & 3 deletions ODIN_II/SRC/odin_ii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ netlist_t* start_odin_ii(int argc, char** argv) {

/* read the FPGA architecture file */
if (global_args.arch_file.provenance() == argparse::Provenance::SPECIFIED) {
printf("Architecture: %s\n", basename(global_args.arch_file.value().c_str()));
printf("Architecture: %s\n", vtr::basename(global_args.arch_file.value()).c_str());
fflush(stdout);

printf("Reading FPGA Architecture file\n");
Expand All @@ -267,7 +267,7 @@ netlist_t* start_odin_ii(int argc, char** argv) {
/* do High level Synthesis */
if (!configuration.list_of_file_names.empty() && configuration.is_verilog_input) {
for (std::string v_file : global_args.verilog_files.value()) {
printf("Verilog: %s\n", basename(v_file.c_str()));
printf("Verilog: %s\n", vtr::basename(v_file).c_str());
}
fflush(stdout);

Expand All @@ -294,7 +294,7 @@ netlist_t* start_odin_ii(int argc, char** argv) {
configuration.list_of_file_names = {global_args.output_file};
current_parse_file = 0;
} else {
printf("Blif: %s\n", basename(global_args.blif_file.value().c_str()));
printf("Blif: %s\n", vtr::basename(global_args.blif_file.value()).c_str());
fflush(stdout);
}

Expand Down
1 change: 1 addition & 0 deletions ODIN_II/SRC/parse_making_ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "hard_blocks.h"
#include "vtr_util.h"
#include "vtr_memory.h"
#include "vtr_path.h"

#include "scope_util.h"

Expand Down
42 changes: 21 additions & 21 deletions ODIN_II/regression_test/benchmark/task/full/synthesis_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -483,24 +483,24 @@
"exit": 0,
"errors": [],
"warnings": [
"PARSE_TO_AST LU8PEEng.v::138 NWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::139 BLOCKWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::140 DDRSIZEWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::141 RAMSIZEWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::677 BLOCKWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::678 RAMWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::679 RAMNUMBYTES is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::680 RAMSIZEWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::686 TOPWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::2448 wFIFOINPUTWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::2456 aFIFOWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::2462 BURSTLEN is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::2466 MEMCONWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::2467 MEMCONNUMBYTES is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::2468 DDRSIZEWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::2471 RAMWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::2472 RAMNUMBYTES is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v::2473 RAMSIZEWIDTH is redefined, overwritting its value"
"PARSE_TO_AST LU8PEEng.v:138 NWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:139 BLOCKWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:140 DDRSIZEWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:141 RAMSIZEWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:677 BLOCKWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:678 RAMWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:679 RAMNUMBYTES is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:680 RAMSIZEWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:686 TOPWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:2448 wFIFOINPUTWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:2456 aFIFOWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:2462 BURSTLEN is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:2466 MEMCONWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:2467 MEMCONNUMBYTES is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:2468 DDRSIZEWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:2471 RAMWIDTH is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:2472 RAMNUMBYTES is redefined, overwritting its value",
"PARSE_TO_AST LU8PEEng.v:2473 RAMSIZEWIDTH is redefined, overwritting its value"
],
"max_rss(MiB)": 214.7,
"exec_time(ms)": 2846.7,
Expand All @@ -527,9 +527,9 @@
"exit": 0,
"errors": [],
"warnings": [
"NETLIST matmul.v::21 Could not resolve initial assignment to a constant value, skipping",
"NETLIST matmul.v::42 indexing into memory with matrix_multiplication has larger input than memory. Unused pins:",
"NETLIST matmul.v::46 indexing into memory with matrix_multiplication has larger input than memory. Unused pins:"
"NETLIST matmul.v:21 Could not resolve initial assignment to a constant value, skipping",
"NETLIST matmul.v:42 indexing into memory with matrix_multiplication has larger input than memory. Unused pins:",
"NETLIST matmul.v:46 indexing into memory with matrix_multiplication has larger input than memory. Unused pins:"
],
"max_rss(MiB)": 6.3,
"exec_time(ms)": 5.8,
Expand Down

0 comments on commit 8980e46

Please sign in to comment.