-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RTL Simulation Enhancements #562
Closed
Closed
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1012e15
multithreading verilator
57a4b52
added docs, verified ENABLE_PRINTF_PATTERN
d2de2e7
reverted gemmini change
40d4d47
cleaned up whitespace in verilator Makefile
376656a
added gemmini branch for CISC isa
69b455f
Update sims/verilator/Makefile
ssteffl b6122c4
Update bin/numa_prefix
ssteffl 9250d04
batch of fixes based on feedback
3a03e98
more updates based on PR feedback
fd6b7d6
reverted gemmini again after accidental bump
f7106d0
mt-verilator verified on nvdla, ariane, and rocket. and other PR fixes
5b7f2d6
fixed emulator.cc regression
b895220
added 'make help', added NUMACTL make variable
23ff1ef
included PR feedback
30c77d7
forgot the --max-num-width 1048576 fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ target | |
*.stamp | ||
*.vcd | ||
*.swp | ||
*.swo | ||
*.log | ||
*# | ||
*~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env python | ||
ssteffl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#============================================================================= | ||
# this enables the PRINTF_COND around points of interest | ||
#============================================================================= | ||
|
||
import sys | ||
import re | ||
from textwrap import dedent as dd | ||
|
||
#============================================================================= | ||
# subroutines | ||
#============================================================================= | ||
def print_usage(): | ||
print(dd(""" | ||
enable_printfs <in_file> <out_file> [pattern1] [pattern2] ... | ||
------------------------------------------------------------- | ||
Selectively enables verbose printf() in your verilog. Right | ||
now, you either get no verbose logging, or 100% verbose logging, but many | ||
times, you might want to just enable logging in a specific module. THIS | ||
SCRIPT IS A TEMPORARY HACK: post-processes the verilog file to remove the | ||
`ifdef PRINTF_COND wrappers around the specific printf()s you care about. | ||
You must manually specify python-compatible regex patterns on the cmdline | ||
to match() the strings in the printf you care about. Multiple patterns are | ||
treated as logical OR, not AND. | ||
""")) | ||
exit(1) | ||
|
||
#============================================================================= | ||
if __name__ == "__main__": | ||
if len(sys.argv) < 3: | ||
print_usage() | ||
|
||
# parse inputs | ||
in_file = sys.argv[1] | ||
out_file = sys.argv[2] | ||
trigger = re.compile(".*`ifdef PRINTF_COND.*") | ||
targets = [] | ||
for idx in range(3, len(sys.argv)): | ||
if len(sys.argv[idx]) > 0: | ||
targets.append(re.compile(sys.argv[idx])) | ||
|
||
# read input lines | ||
in_lines = [] | ||
with open(in_file, "r") as f: | ||
in_lines = f.readlines() | ||
|
||
# enable PRINTF_COND lines around points of interest | ||
enables = 0 | ||
out_lines = [] | ||
idx = 0 | ||
idx_end = len(in_lines) | ||
while(idx < idx_end): | ||
if trigger.match(in_lines[idx]): | ||
matches_target = False | ||
for target in targets: | ||
if target.match(in_lines[idx+4]): | ||
matches_target = True | ||
break | ||
if matches_target: | ||
enables += 1 | ||
out_lines += in_lines[idx+3:idx+6] | ||
else: | ||
out_lines += in_lines[idx:idx+9] | ||
idx += 9 | ||
else: | ||
out_lines.append(in_lines[idx]) | ||
idx += 1 | ||
|
||
# write to output file | ||
with open(out_file, "w") as f: | ||
f.writelines(out_lines) | ||
|
||
print("INFO: enabled {} printfs in {}".format(enables, out_file)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env perl | ||
ssteffl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#============================================================================ | ||
# really simple script, which just prints out the numactl cmd to | ||
# prefix before your actual command. it determines this based on free memory | ||
# size attached to every node. | ||
#============================================================================ | ||
|
||
use strict; | ||
use warnings; | ||
|
||
my $path = `which numactl`; | ||
if(length($path) > 0) { | ||
my ($head_line, @rest) = map {chomp; $_} `numactl -H`; | ||
|
||
if($head_line =~ /available: (\d+) nodes/) { | ||
my $node_count = $1; | ||
my $best_node_id = undef | ||
my $best_cpus = undef; | ||
my $best_free_size = undef; | ||
|
||
foreach my $num (1..$node_count) { | ||
my $cpus_line = shift(@rest); | ||
my $mem_size_line = shift(@rest); | ||
my $mem_free_line = shift(@rest); | ||
|
||
if($cpus_line =~ /node (\d+) cpus: (\d.*\d)$/) { | ||
my ($node_id, $cpus) = ($1, $2); | ||
$cpus =~ s/\s+/,/g; | ||
|
||
if($mem_free_line =~ /node $node_id free: (\d+) \S+$/) { | ||
my $free_size = $1; | ||
if(!defined($best_free_size) || ($free_size > $best_free_size)) { | ||
$best_node_id = $node_id; | ||
$best_cpus = $cpus; | ||
$best_free_size = $free_size; | ||
} | ||
} else { | ||
die("malformed mem-free line: $mem_free_line\n"); | ||
} | ||
} else { | ||
die("malformed cpus line: $cpus_line\n"); | ||
} | ||
} | ||
print("numactl -m $best_node_id -C $best_cpus --"); | ||
} else { | ||
die("malformed head line: $head_line\n"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule gemmini
updated
18 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is useful, but I'd argue this is also out of scope for the PR. Is this worked into the build flow at all? That would be a nice feature to add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think its in the scope of this pr. this is my "verilator enhancements" pr. i'm removed the build-script stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this script is a hack. this could be done in a firrtl pass, and hopefully the firrtl-pass would not be too slow compared to this hacky solution.
however, the firrtl pass does not exist, so we must live with this hack for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR title is
Multithread verilator
. This is what goes into the release notes, merge commit, etc. If this is aVerilator enhancement
PR you need to adjust the title/description.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to agree with John here. I think the multi-threading work will take significantly longer to get in/reviewed, whereas the printf stuff would be a quick merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR scope adjusted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still like to see this worked into the build flow in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on the other hand, it is nice to not have to invoke the JVM and run all the firrtl passes again just to change which printfs get displayed. So I can see a case for having the printf filtering happen after the
make verilog
target completes.Although I admit again, that the current solution is a hack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you need to invoke the JVM? Just have another intermediate make target that runs this script