Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rand_soc_synth
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoeders committed Nov 29, 2023
2 parents be64db5 + f41e0c5 commit eb83588
Show file tree
Hide file tree
Showing 51 changed files with 45 additions and 37 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:


jobs:
# First list all the files in experiments/tests, and generate a JSON string of all the files
# First list all the files in tests/ci, and generate a JSON string of all the files
collect-experiments:
runs-on: ubuntu-latest
outputs:
Expand All @@ -23,12 +23,12 @@ jobs:
- uses: actions/checkout@v3
- id: set-matrix
run: |
echo "matrix=$(ls experiments/tests/*.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
echo "matrix=$(ls tests/ci/*.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
# - id: set-matrix-wip
# run: echo "matrix-wip=$(ls experiments/wip/*.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
# run: echo "matrix-wip=$(ls tests/wip/*.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT

# Build a matrix run of all experiments generated in previous job
run-experiments:
run-test:
needs: collect-experiments
runs-on: [self-hosted, linux]
strategy:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/weeklytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
submodules: 'recursive'
- id: set-matrix
run: |
echo "matrix=$(ls experiments/weekly_tests/*.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
echo "matrix=$(ls tests/weekly_tests/*.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
run-tests:
needs: collect-tests
Expand All @@ -40,6 +40,7 @@ jobs:
ls -la ./
- uses: actions/checkout@v3
with:
token: ${{ secrets.GMT_TOOLS_PAT }}
submodules: 'recursive'
- uses: ./.github/actions/setup_env
- name: tests
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"python": "${workspaceFolder}/.venv/bin/python",
"program": "scripts/run_experiment.py",
"args": [
"experiments/phys_netlist.yaml",
"tests/phys_netlist.yaml",
"-j1"
],
"env": {
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ Currently supported flows:
* `vivado_ooc`
* `vivado_and_reversed`
* `vivado_phys_netlist`
* `vivado_phys_netlist_xrev`
* `vivado_phys_netlist_cmp`
* `vivado_structural_error_injection`
* `vivado_conformal`
Expand Down
15 changes: 13 additions & 2 deletions bfasst/ninja_flows/vivado_phys_netlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@
from bfasst.ninja_tools.synth.vivado_synth import VivadoSynth


# pylint: disable=duplicate-code
class VivadoPhysNetlist(Flow):
"""Creates a Vivado netlist that has only physical primitives."""

def __init__(self, design, synth_options=""):
super().__init__(design)
self.vivado_synth_tool = VivadoSynth(self, design, synth_options=synth_options)

self.synth_options = VivadoPhysNetlist.add_required_synth_options(synth_options)

self.vivado_synth_tool = VivadoSynth(self, design, synth_options=self.synth_options)
self.vivado_impl_tool = VivadoImpl(self, design)
self.phys_netlist_tool = PhysNetlist(self, design)

def create_build_snippets(self):
# pylint: disable=duplicate-code
self.vivado_synth_tool.create_build_snippets()
self.vivado_impl_tool.create_build_snippets()
self.phys_netlist_tool.create_build_snippets(
Expand All @@ -28,3 +31,11 @@ def create_build_snippets(self):

def get_top_level_flow_path(self):
return NINJA_FLOWS_PATH / "vivado_phys_netlist.py"

@staticmethod
def add_required_synth_options(options):
if "-flatten_hierarchy" not in options:
options += " -flatten_hierarchy full"
if "-max_dsp" not in options:
options += " -max_dsp 0"
return options
6 changes: 5 additions & 1 deletion bfasst/ninja_flows/vivado_phys_netlist_cmp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Structural Comparison of physical netlist and reversed netlist"""

from bfasst.ninja_flows.flow import Flow
from bfasst.ninja_flows.vivado_phys_netlist import VivadoPhysNetlist
from bfasst.ninja_tools.impl.vivado_impl import VivadoImpl
from bfasst.ninja_tools.compare.structural.structural import Structural
from bfasst.ninja_tools.rev_bit.xray import Xray
Expand All @@ -15,7 +16,10 @@ class VivadoPhysNetlistCmp(Flow):

def __init__(self, design, synth_options=""):
super().__init__(design)
self.vivado_synth_tool = VivadoSynth(self, design, synth_options=synth_options)

self.synth_options = VivadoPhysNetlist.add_required_synth_options(synth_options)

self.vivado_synth_tool = VivadoSynth(self, design, synth_options=self.synth_options)
self.vivado_impl_tool = VivadoImpl(self, design)
self.phys_netlist_tool = PhysNetlist(self, design)
self.xray_tool = Xray(self, design)
Expand Down
11 changes: 7 additions & 4 deletions bfasst/ninja_flows/vivado_structural_error_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import random

from bfasst.ninja_flows.flow import Flow
from bfasst.ninja_flows.vivado_phys_netlist import VivadoPhysNetlist
from bfasst.ninja_tools.impl.vivado_impl import VivadoImpl
from bfasst.ninja_tools.compare.structural.structural import Structural
from bfasst.ninja_tools.rev_bit.xray import Xray
Expand All @@ -24,7 +25,9 @@ def __init__(self, design, num_runs=100, seed=None, synth_options=""):
if self.seed is not None:
random.seed(self.seed)

self.vivado_synth_tool = VivadoSynth(self, design, synth_options=synth_options)
self.synth_options = VivadoPhysNetlist.add_required_synth_options(synth_options)

self.vivado_synth_tool = VivadoSynth(self, design, synth_options=self.synth_options)
self.vivado_impl_tool = VivadoImpl(self, design)
self.phys_netlist_tool = PhysNetlist(self, design)
self.xrev_tool = Xray(self, design)
Expand Down Expand Up @@ -74,12 +77,12 @@ def post_execute(self):
continue
with open(file, "r") as f:
# SUCCESS means the compare tool did not detect an actual error
if "FAIL" not in f.read():
print(f"Error injection failed on {file.name.split('_cmp.log')[0]}")
else:
if "SUCCESS: Structural comparison found mismatch as expected" in f.read():
err_log_name = file.name.split("_cmp.log")[0] + ".log"
err_log = error_dir / err_log_name
err_netlist = err_log.with_suffix(".v")
file.unlink()
err_log.unlink()
err_netlist.unlink()
else:
print(f"Error injection failed on {file.name.split('_cmp.log')[0]}")
2 changes: 1 addition & 1 deletion bfasst/ninja_tools/common/vivado_rules.ninja.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rule vivado
command = export tempjou=$$(mktemp); export templog=$$(mktemp); cd $cwd && {{ vivado_path }} -mode batch -journal $$tempjou -log $$templog -source $in >&- && mv $$tempjou $journal && mv $$templog $log
command = export tempjou=$$(mktemp); export templog=$$(mktemp); cd $cwd && bfasst/ninja_utils/retry.sh {{ vivado_path }} -mode batch -journal $$tempjou -log $$templog -source $in >&- && mv $$tempjou $journal && mv $$templog $log
description = vivado $in

{{#in_context}}
Expand Down
1 change: 1 addition & 0 deletions bfasst/ninja_utils/retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"$@"||"$@"||"$@"
2 changes: 1 addition & 1 deletion bfasst/ninja_utils/structural.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def add_net_mapping(self, net1, net2):
assert net1.name not in self.gnd_mappings
self.vcc_mappings.add(net1.name)
else:
raise AssertionError(
raise StructuralCompareError(
f"{net2.name} in net_mapping.inverse already. net1: {net1.name}"
)
return
Expand Down
2 changes: 1 addition & 1 deletion bfasst/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

DESIGNS_PATH = ROOT_PATH / "designs"
BFASST_PATH = ROOT_PATH / "bfasst"
EXPERIMENTS_PATH = ROOT_PATH / "experiments"
TESTS_PATH = ROOT_PATH / "tests"
RESOURCES_PATH = ROOT_PATH / "resources"
SCRIPTS_PATH = ROOT_PATH / "scripts"
ERROR_FLOW_PATH = ROOT_PATH / "error_flows"
Expand Down
2 changes: 1 addition & 1 deletion html_table_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To run an experiment of flows and update the table, source the following two bas

`run_flows.sh`

* If you want to create a new custom flow for testing, ensure the proper code is located in `scripts/bfasst/flows.py` along with an associated `.yaml` file in the `experiments` directory.
* If you want to create a new custom flow for testing, ensure the proper code is located in `scripts/bfasst/flows.py` along with an associated `.yaml` file in the `tests` directory.
* Add your new flow to the `flows_list` variable within the main function of `scripts/run_experiment.py` (this will add a new column to the table).
* Modify the script to add the commands for running the new experiment in `run_flows.sh` before sourcing.

Expand Down
2 changes: 1 addition & 1 deletion scripts/run_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def main():

error_flows = []
for dir_item in paths.ERROR_FLOW_PATH.iterdir():
if (paths.EXPERIMENTS_PATH / dir_item).is_file() and dir_item.suffix == ".yaml":
if (paths.TESTS_PATH / dir_item).is_file() and dir_item.suffix == ".yaml":
error_flows.append(dir_item.stem)
parser.add_argument(
"--error_flow",
Expand Down
7 changes: 0 additions & 7 deletions test/scripts/test_ninja_flow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from bfasst.ninja_flows.vivado import Vivado
from bfasst.ninja_flows.vivado_bit_analysis import VivadoBitAnalysis
from bfasst.ninja_flows.vivado_phys_netlist import VivadoPhysNetlist
from bfasst.ninja_flows.vivado_phys_netlist_xrev import VivadoPhysNetlistXrev
from bfasst.ninja_flows.vivado_phys_netlist_cmp import VivadoPhysNetlistCmp
from bfasst.ninja_flows.vivado_structural_error_injection import VivadoStructuralErrorInjection
from bfasst.ninja_flows.vivado_conformal import VivadoConformal
Expand Down Expand Up @@ -57,9 +56,6 @@ def test_create_vivado_reversed_flow(self):
def test_create_vivado_phys_netlist_flow(self):
self.__check_flow_creation(VivadoPhysNetlist, "vivado_phys_netlist")

def test_create_phys_reversed_flow(self):
self.__check_flow_creation(VivadoPhysNetlistXrev, "vivado_phys_netlist_xrev")

def test_create_phys_compare_flow(self):
self.__check_flow_creation(VivadoPhysNetlistCmp, "vivado_phys_netlist_cmp")

Expand Down Expand Up @@ -103,9 +99,6 @@ def test_run_vivado_reversed_flow(self):
def test_run_vivado_phys_netlist_flow(self):
self.__check_flow_run("vivado_phys_netlist", 9)

def test_run_phys_reversed_flow(self):
self.__check_flow_run("vivado_phys_netlist_xrev", 11)

def test_run_phys_compare_flow(self):
self.__check_flow_run("vivado_phys_netlist_cmp", 13)

Expand Down
14 changes: 5 additions & 9 deletions test/scripts/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest
import io
from contextlib import redirect_stderr
from bfasst.paths import EXPERIMENTS_PATH, ROOT_PATH
from bfasst.paths import TESTS_PATH, ROOT_PATH

from scripts.run import parse_args

Expand Down Expand Up @@ -51,10 +51,6 @@ def test_run_vivado_phys_netlist_flow(self):
"""Test that the runner runs the vivado_phys_netlist flow without errors"""
self.__run_flow("vivado_phys_netlist")

def test_run_vivado_phys_netlist_xrev_flow(self):
"""Test that the runner runs the vivado_phys_netlist_xrev flow without errors"""
self.__run_flow("vivado_phys_netlist_xrev")

def test_run_vivado_phys_netlist_cmp_flow(self):
"""Test that the runner runs the vivado_phys_netlist_cmp flow without errors"""
self.__run_flow("vivado_phys_netlist_cmp")
Expand All @@ -67,7 +63,7 @@ def __try_check_args_for_success(self, args):

def test_check_args_succeeds_on_yaml(self):
"""Test that the check_args function accepts only a yaml or a design/flow"""
args = [EXPERIMENTS_PATH / "tests/vivado_bit_analysis.yaml"]
args = [TESTS_PATH / "ci/vivado_bit_analysis.yaml"]
self.__try_check_args_for_success(args)

def test_check_args_succeeds_on_flow_and_design(self):
Expand All @@ -86,17 +82,17 @@ def __produce_check_args_failure(self, args):
parse_args(args)

def test_check_args_fails_on_yaml_and_design_and_flow(self):
args = ["--yaml", "experiments/tests/test.yaml", "--design", "byu/alu", "--flow", "vivado"]
args = ["--yaml", "tests/ci/test.yaml", "--design", "byu/alu", "--flow", "vivado"]
self.__produce_check_args_failure(args)

def test_check_args_fails_on_no_args(self):
args = []
self.__produce_check_args_failure(args)

def test_check_args_fails_on_yaml_and_design(self):
args = ["--yaml", "experiments/tests/test.yaml", "--design", "byu/alu"]
args = ["--yaml", "tests/ci/test.yaml", "--design", "byu/alu"]
self.__produce_check_args_failure(args)

def test_check_args_fails_on_yaml_and_flow(self):
args = ["--yaml", "experiments/tests/test.yaml", "--flow", "vivado"]
args = ["--yaml", "tests/ci/test.yaml", "--flow", "vivado"]
self.__produce_check_args_failure(args)
File renamed without changes.
2 changes: 1 addition & 1 deletion experiments/Makefile.common → tests/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
BFASST_PATH := $(realpath $(LEVEL)/..)
RESOURCES = $(BFASST_PATH)/resources
SCRIPTS = $(BFASST_PATH)/scripts
EXPERIMENTS = $(BFASST_PATH)/experiments
TESTS = $(BFASST_PATH)/tests
EXAMPLES = $(BFASST_PATH)/examples

include $(RESOURCES)/Makefile_colors.inc
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ...ments/tests/vivado_phys_netlist_xrev.yaml → tests/ci/vivado_phys_netlist.yaml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ designs:
- byu/UpDownButtonCount


flow: vivado_phys_netlist_xrev
flow: vivado_phys_netlist

synth_options: -flatten_hierarchy full -max_dsp 0
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit eb83588

Please sign in to comment.