Skip to content

Commit

Permalink
Merge pull request f4pga#871 from litghost/add_qor_tool
Browse files Browse the repository at this point in the history
Add QoR tool
  • Loading branch information
litghost committed Jul 3, 2019
2 parents 31732ac + 5954aca commit 840bffc
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/kokoro/continuous-docs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ action {
# File types
regex: "**/*result*.xml"
regex: "**/*sponge_log.xml"
regex: "**/pack.log"
regex: "**/place.log"
regex: "**/route.log"
regex: "**/*_qor.csv"
strip_prefix: "github/symbiflow-arch-defs-continuous-docs/"
}
}
Expand Down
4 changes: 4 additions & 0 deletions .github/kokoro/continuous-ice40.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ action {
# File types
regex: "**/*result*.xml"
regex: "**/*sponge_log.xml"
regex: "**/pack.log"
regex: "**/place.log"
regex: "**/route.log"
regex: "**/*_qor.csv"
strip_prefix: "github/symbiflow-arch-defs-continuous-ice40/"
}
}
Expand Down
4 changes: 4 additions & 0 deletions .github/kokoro/continuous-testarch.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ action {
# File types
regex: "**/*result*.xml"
regex: "**/*sponge_log.xml"
regex: "**/pack.log"
regex: "**/place.log"
regex: "**/route.log"
regex: "**/*_qor.csv"
strip_prefix: "github/symbiflow-arch-defs-continuous-testarch/"
}
}
Expand Down
4 changes: 4 additions & 0 deletions .github/kokoro/continuous-tests.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ action {
# File types
regex: "**/*result*.xml"
regex: "**/*sponge_log.xml"
regex: "**/pack.log"
regex: "**/place.log"
regex: "**/route.log"
regex: "**/*_qor.csv"
strip_prefix: "github/symbiflow-arch-defs-continuous-tests/"
}
}
Expand Down
4 changes: 4 additions & 0 deletions .github/kokoro/continuous-xc7.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ action {
# File types
regex: "**/*result*.xml"
regex: "**/*sponge_log.xml"
regex: "**/pack.log"
regex: "**/place.log"
regex: "**/route.log"
regex: "**/*_qor.csv"
strip_prefix: "github/symbiflow-arch-defs-continuous-xc7/"
}
}
Expand Down
1 change: 1 addition & 0 deletions .github/kokoro/ice40.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ echo "----------------------------------------"
export MAKE_ARGS="-j${MAX_CORES} --output-sync=target"
# Run as many tests as we can. Rerun individually on failure.
make -k ${MAKE_ARGS} all_ice40 || make all_ice40
make print_qor > ice40_qor.csv
)
echo "----------------------------------------"
4 changes: 4 additions & 0 deletions .github/kokoro/presubmit-docs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ action {
# File types
regex: "**/*result*.xml"
regex: "**/*sponge_log.xml"
regex: "**/pack.log"
regex: "**/place.log"
regex: "**/route.log"
regex: "**/*_qor.csv"
strip_prefix: "github/symbiflow-arch-defs-presubmit-docs/"
}
}
Expand Down
4 changes: 4 additions & 0 deletions .github/kokoro/presubmit-ice40.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ action {
# File types
regex: "**/*result*.xml"
regex: "**/*sponge_log.xml"
regex: "**/pack.log"
regex: "**/place.log"
regex: "**/route.log"
regex: "**/*_qor.csv"
strip_prefix: "github/symbiflow-arch-defs-presubmit-ice40/"
}
}
Expand Down
4 changes: 4 additions & 0 deletions .github/kokoro/presubmit-testarch.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ action {
# File types
regex: "**/*result*.xml"
regex: "**/*sponge_log.xml"
regex: "**/pack.log"
regex: "**/place.log"
regex: "**/route.log"
regex: "**/*_qor.csv"
strip_prefix: "github/symbiflow-arch-defs-presubmit-testarch/"
}
}
Expand Down
4 changes: 4 additions & 0 deletions .github/kokoro/presubmit-tests.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ action {
# File types
regex: "**/*result*.xml"
regex: "**/*sponge_log.xml"
regex: "**/pack.log"
regex: "**/place.log"
regex: "**/route.log"
regex: "**/*_qor.csv"
strip_prefix: "github/symbiflow-arch-defs-presubmit-tests/"
}
}
Expand Down
4 changes: 4 additions & 0 deletions .github/kokoro/presubmit-xc7.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ action {
# File types
regex: "**/*result*.xml"
regex: "**/*sponge_log.xml"
regex: "**/pack.log"
regex: "**/place.log"
regex: "**/route.log"
regex: "**/*_qor.csv"
strip_prefix: "github/symbiflow-arch-defs-presubmit-xc7/"
}
}
Expand Down
1 change: 1 addition & 0 deletions .github/kokoro/xc7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ echo "----------------------------------------"
export MAKE_ARGS="-j${MAX_CORES} --output-sync=target"
# Run as many tests as we can. Rerun individually on failure.
make -k ${MAKE_ARGS} all_xc7 || make all_xc7
make print_qor > xc7_qor.csv
)
echo "----------------------------------------"
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,8 @@ add_dependencies(all_demos
)

add_custom_target(docs)

add_custom_target(print_qor
COMMAND ${PYTHON3} ${symbiflow-arch-defs_SOURCE_DIR}/utils/print_qor.py ${symbiflow-arch-defs_BINARY_DIR}
DEPENDS ${PYTHON3_TARGET}
)
2 changes: 1 addition & 1 deletion common/cmake/env.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function(ADD_CONDA_PACKAGE)
add_custom_command(
OUTPUT ${OUTPUTS}
COMMAND ${CMAKE_COMMAND} -E echo "Taking ${CONDA_BIN}.lock"
COMMAND flock ${CONDA_BIN}.lock ${CONDA_BIN} install --force-reinstall ${PACKAGE_SPEC}
COMMAND flock ${CONDA_BIN}.lock ${CONDA_BIN} install --force ${PACKAGE_SPEC}
${TOUCH_COMMANDS}
DEPENDS conda ${CONDA_BIN}
)
Expand Down
82 changes: 82 additions & 0 deletions utils/print_qor.py
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()

0 comments on commit 840bffc

Please sign in to comment.