forked from f4pga/f4pga-arch-defs
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request f4pga#871 from litghost/add_qor_tool
Add QoR tool
- Loading branch information
Showing
15 changed files
with
130 additions
and
1 deletion.
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
""" Gathers statistics from VPR runs, like pack/place/route runtimes and Fmax. | ||
""" | ||
import argparse | ||
import csv | ||
import os | ||
import sys | ||
|
||
|
||
def scan_runtime(fname): | ||
""" Find runtime of VPR log (if any), else returns empty str. """ | ||
try: | ||
with open(fname, 'r') as f: | ||
for l in f: | ||
pass | ||
|
||
if not l.startswith('The entire flow of VPR took'): | ||
return "" | ||
|
||
return str(float(l.split()[6])) | ||
except FileNotFoundError: | ||
return "" | ||
|
||
|
||
def scan_critical(fname): | ||
""" Find critical path and Fmax from VPR log (if any). | ||
Returns | ||
------- | ||
critical_path : str | ||
Critical path delay in nsec | ||
fmax : str | ||
Fmax in MHz. | ||
""" | ||
try: | ||
with open(fname, 'r') as f: | ||
for l in f: | ||
if l.startswith('Final critical path:'): | ||
parts = l.split() | ||
if len(parts) >= 7: | ||
critical_path = float(parts[3]) | ||
fmax = float(parts[6]) | ||
return str(critical_path), str(fmax) | ||
except FileNotFoundError: | ||
pass | ||
|
||
return "", "" | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.add_argument("build_dir") | ||
|
||
args = parser.parse_args() | ||
|
||
fields = [ | ||
"path", "pack time (sec)", "place time (sec)", "route time (sec)", | ||
"Fmax (MHz)", "t_crit (ns)" | ||
] | ||
w = csv.DictWriter(sys.stdout, fields) | ||
w.writeheader() | ||
for root, dirs, files in os.walk(args.build_dir): | ||
if 'pack.log' in files: | ||
d = {} | ||
|
||
d['path'] = root | ||
d['pack time (sec)'] = scan_runtime(os.path.join(root, 'pack.log')) | ||
d['place time (sec)'] = scan_runtime( | ||
os.path.join(root, 'place.log') | ||
) | ||
d['route time (sec)'] = scan_runtime( | ||
os.path.join(root, 'route.log') | ||
) | ||
d['Fmax (MHz)'], d['t_crit (ns)'] = scan_critical( | ||
os.path.join(root, 'route.log') | ||
) | ||
|
||
w.writerow(d) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |