Skip to content

Commit 64d15e2

Browse files
authored
Merge pull request #1564 from antmicro/add-symbiflow-test
Add symbiflow tests
2 parents 0b7e606 + cf68a3a commit 64d15e2

File tree

14 files changed

+349
-7
lines changed

14 files changed

+349
-7
lines changed

.github/kokoro/continuous/nightly.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ env_vars {
5555

5656
env_vars {
5757
key: "NUM_CORES"
58-
value: "5"
58+
value: "3"
5959
}

.github/kokoro/presubmit/nightly.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ env_vars {
5555

5656
env_vars {
5757
key: "NUM_CORES"
58-
value: "5"
58+
value: "3"
5959
}

.github/kokoro/steps/vtr-full-setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
make get_titan_benchmarks
44
make get_ispd_benchmarks
5+
make get_symbiflow_benchmarks
56

67
dev/upgrade_vtr_archs.sh

.github/kokoro/steps/vtr-test.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,26 @@ echo "========================================"
4747
export VPR_NUM_WORKERS=1
4848
./run_reg_test.py $VTR_TEST $VTR_TEST_OPTIONS -j$NUM_CORES
4949
kill $MONITOR
50+
51+
echo "========================================"
52+
echo "Cleaning benchmarks files"
53+
echo "========================================"
54+
# Removing Symbiflow archs and benchmarks
55+
find vtr_flow/arch/symbiflow/ -type f -not -name 'README.*' -delete
56+
find vtr_flow/benchmarks/symbiflow/ -type f -not -name 'README.*' -delete
57+
58+
# Removing ISPD benchmarks
59+
find vtr_flow/benchmarks/ispd_blif/ -type f -not -name 'README.*' -delete
60+
61+
# Removing Titan benchmarks
62+
find vtr_flow/benchmarks/titan_blif/ -type f -not -name 'README.*' -delete
63+
64+
# Removing ISPD, Titan and Symbiflow tarballs
65+
find . -type f -regex ".*\.tar\.\(gz\|xz\)" -delete
66+
67+
# Make sure working directory doesn't exceed disk space limit!
68+
echo "Working directory size: $(du -sh)"
69+
if [[ $(du -s | cut -d $'\t' -f 1) -gt $(expr 1024 \* 1024 \* 90) ]]; then
70+
echo "Working directory too large!"
71+
exit 1
72+
fi

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ vtr_flow/benchmarks/titan_other_blif/*.sdc
4646
ispd_benchmarks_vtr*.tar.gz
4747
vtr_flow/benchmarks/ispd_blif/*.blif
4848

49+
#
50+
# SymbiFlow benchmarks
51+
#
52+
# We ignore the SymbiFlow netlists and architectures because of thier large size.
53+
#
54+
*symbiflow*.tar.xz
55+
vtr_flow/arch/symbiflow/*.bin
56+
vtr_flow/arch/symbiflow/*.xml
57+
vtr_flow/benchmarks/symbiflow/*.eblif
58+
vtr_flow/benchmarks/symbiflow/sdc/*.sdc
59+
4960
#
5061
# Cloud9 Directory
5162
#

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,14 @@ add_custom_target(get_ispd_benchmarks
314314
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
315315
COMMENT "Downloading (~50MB) and extracting Titan benchmarks (~0.5GB) into VTR source tree.")
316316

317+
#
318+
# SymbiFlow Benchmarks
319+
#
320+
add_custom_target(get_symbiflow_benchmarks
321+
COMMAND ./vtr_flow/scripts/download_symbiflow.py --vtr_flow_dir ./vtr_flow
322+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
323+
COMMENT "Downloading (~100MB) and extracting SymbiFlow architectures (~2.7GB) into VTR source tree.")
324+
317325
#
318326
# Unit Testing
319327
#

vtr_flow/arch/symbiflow/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
SymbiFlow architectures
2+
=======================
3+
4+
This directory holds all the SymbiFlow architectures that are generated in the [SymbiFlow-arch-defs](https://github.com/SymbiFlow/symbiflow-arch-defs) repository.
5+
6+
The data files needed to successfully run VPR are:
7+
- Architecture XML definition
8+
- RR Graph
9+
- Router Lookahead
10+
- Place delay matrix lookup
11+
12+
All the data files can be downloaded with the `make get_symbiflow_benchmarks` target in the root directory.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
SymbiFlow benchmarks
2+
====================
3+
4+
This directory holds all the SymbiFlow benchmarks that are generated in the [SymbiFlow-arch-defs](https://github.com/SymbiFlow/symbiflow-arch-defs) repository.
5+
6+
The circuits come along with the SDC constraints file, if present, and have been produced with yosys.
7+
They are compatible with the symbiflow architectures produced in the same Symbiflow-arch-defs build.
8+
9+
Some of the circuites require also the place constraint files to correctly place some IOs and clock tiles
10+
in the correct location, so not to incur in routability issues.
11+
12+
All the data files can be downloaded with the `make get_symbiflow_benchmarks` target in the root directory.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Place constraints
2+
=================
3+
4+
This directory contains the Place constraints files corresponding to the homonym circuit file.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SDC constraints
2+
===============
3+
4+
This directory contains the SDC constraints files corresponding to the homonym circuit file.
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Script to download the SymbiFlow Series-7 architectures
4+
"""
5+
6+
import sys
7+
import os
8+
import argparse
9+
import math
10+
import textwrap
11+
import fnmatch
12+
import tempfile
13+
import shutil
14+
import subprocess
15+
from urllib import request
16+
17+
GCS_URL = {
18+
"architectures":
19+
"https://storage.googleapis.com/symbiflow-arch-defs-gha/symbiflow-xc7a50t_test-latest",
20+
"benchmarks":
21+
"https://storage.googleapis.com/symbiflow-arch-defs-gha/symbiflow-benchmarks-latest"
22+
}
23+
24+
SYMBIFLOW_URL_MIRRORS = {"google": GCS_URL}
25+
26+
27+
class ExtractionError(Exception):
28+
"""
29+
Extraction error exception class
30+
"""
31+
32+
33+
def parse_args():
34+
"""
35+
Parses and returns script's arguments
36+
"""
37+
38+
description = textwrap.dedent(
39+
"""
40+
Download and extract a symbiflow benchmark release into a
41+
VTR-style directory structure.
42+
43+
If a previous matching symbiflow release tar.gz file is found
44+
does nothing (unless --force is specified).
45+
"""
46+
)
47+
parser = argparse.ArgumentParser(
48+
formatter_class=argparse.ArgumentDefaultsHelpFormatter, description=description
49+
)
50+
51+
parser.add_argument(
52+
"--vtr_flow_dir",
53+
required=True,
54+
help="The 'vtr_flow' directory under the VTR tree. "
55+
"If specified this will extract the symbiflow release, "
56+
"placing benchmarks under vtr_flow/benchmarks/symbiflow ",
57+
)
58+
parser.add_argument(
59+
"--force",
60+
default=False,
61+
action="store_true",
62+
help="Run extraction step even if directores etc. already exist",
63+
)
64+
65+
parser.add_argument("--mirror", default="google", choices=["google"], help="Download mirror")
66+
67+
parser.add_argument(
68+
"--upgrade_archs",
69+
action="store_true",
70+
default=True,
71+
help="Try to upgrade included architecture files (using the upgrade_archs.py)",
72+
)
73+
74+
return parser.parse_args()
75+
76+
77+
def main():
78+
"""
79+
Main function
80+
"""
81+
82+
args = parse_args()
83+
84+
try:
85+
urls = SYMBIFLOW_URL_MIRRORS[args.mirror]
86+
archs_tar_xz_url = urls["architectures"]
87+
benchmarks_tar_xz_url = urls["benchmarks"]
88+
89+
archs_tar_xz_filename = "archs_symbiflow.tar.xz"
90+
benchmarks_tar_xz_filename = "benchmarks_symbiflow.tar.xz"
91+
92+
print("Downloading architectures {}".format(archs_tar_xz_url))
93+
download_url(archs_tar_xz_filename, archs_tar_xz_url)
94+
95+
print("Extracting architectures {}".format(archs_tar_xz_filename))
96+
symbiflow_data_dir = "share/symbiflow/arch/xc7a50t_test"
97+
extract_to_vtr_flow_dir(args, archs_tar_xz_filename, "arch", symbiflow_data_dir)
98+
99+
print("Downloading benchmarks {}".format(benchmarks_tar_xz_url))
100+
download_url(benchmarks_tar_xz_filename, benchmarks_tar_xz_url)
101+
102+
print("Extracting benchmarks {}".format(benchmarks_tar_xz_filename))
103+
extract_to_vtr_flow_dir(args, benchmarks_tar_xz_filename, "benchmarks")
104+
105+
except ExtractionError as error:
106+
print("Failed to extract data: ", error)
107+
sys.exit(1)
108+
109+
sys.exit(0)
110+
111+
112+
def download_url(filename, url):
113+
"""
114+
Downloads the symbiflow release
115+
"""
116+
latest_package_url = request.urlopen(url).read().decode("utf-8")
117+
print("Downloading latest package:\n{}".format(latest_package_url))
118+
request.urlretrieve(latest_package_url, filename, reporthook=download_progress_callback)
119+
120+
121+
def download_progress_callback(block_num, block_size, expected_size):
122+
"""
123+
Callback for urllib.urlretrieve which prints a dot for every percent of a file downloaded
124+
"""
125+
total_blocks = int(math.ceil(expected_size / block_size))
126+
progress_increment = int(math.ceil(total_blocks / 100))
127+
128+
if block_num % progress_increment == 0:
129+
sys.stdout.write(".")
130+
sys.stdout.flush()
131+
if block_num * block_size >= expected_size:
132+
print("")
133+
134+
135+
def extract_to_vtr_flow_dir(args, tar_xz_filename, destination, extract_path=""):
136+
"""
137+
Extracts the 'benchmarks' directory of the symbiflow release
138+
into its corresponding vtr directory
139+
"""
140+
141+
# Reference directories
142+
dest_dir = os.path.join(args.vtr_flow_dir, destination)
143+
symbiflow_extract_dir = os.path.join(dest_dir, "symbiflow")
144+
145+
if not args.force:
146+
# Check that all expected directories exist
147+
expected_dirs = [
148+
args.vtr_flow_dir,
149+
symbiflow_extract_dir,
150+
]
151+
for directory in expected_dirs:
152+
if not os.path.isdir(directory):
153+
raise ExtractionError("{} should be a directory".format(directory))
154+
155+
# Create a temporary working directory
156+
tmpdir = tempfile.mkdtemp(suffix="download_symbiflow", dir=".")
157+
158+
# Extract matching files into the temporary directory
159+
subprocess.call(
160+
"tar -C {} -xf {} {}".format(tmpdir, tar_xz_filename, extract_path),
161+
shell=True,
162+
)
163+
164+
# Move the extracted files to the relevant directories, SDC files first (since we
165+
# need to look up the BLIF name to make it match)
166+
for dirpath, _, filenames in os.walk(tmpdir):
167+
for filename in filenames:
168+
src_file_path = os.path.join(dirpath, filename)
169+
dst_file_path = None
170+
171+
if fnmatch.fnmatch(src_file_path, "*/xc7a50t_test/arch.timing.xml"):
172+
dst_file_path = os.path.join(symbiflow_extract_dir, "arch.timing.xml")
173+
174+
elif fnmatch.fnmatch(src_file_path, "*/xc7a50t_test/*.bin"):
175+
dst_file_path = os.path.join(symbiflow_extract_dir, filename)
176+
177+
elif fnmatch.fnmatch(src_file_path, "**/*.eblif"):
178+
dst_file_path = os.path.join(symbiflow_extract_dir, filename)
179+
180+
elif fnmatch.fnmatch(src_file_path, "**/*.sdc"):
181+
dst_file_path = os.path.join(symbiflow_extract_dir, "sdc", filename)
182+
183+
elif fnmatch.fnmatch(src_file_path, "**/*.place"):
184+
dst_file_path = os.path.join(symbiflow_extract_dir, "place_constr", filename)
185+
186+
if dst_file_path:
187+
shutil.move(src_file_path, dst_file_path)
188+
189+
shutil.rmtree(tmpdir)
190+
191+
print("Done")
192+
193+
194+
if __name__ == "__main__":
195+
main()

0 commit comments

Comments
 (0)