Skip to content
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

Prototype VCS CI running on AWS #2236

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Github CI Regressions
# GitHub CI Regressions
The directory **_typically_** contains YAML files that specify the functional regressions for core-v-verif projects.
We are currently transitioning to a new CI flow and so for now this directory is empty.

Expand Down Expand Up @@ -86,5 +86,5 @@ on:
```

-->
####end
#### end

28 changes: 28 additions & 0 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: aws
on: push

# on:
# push:
# branches:
# - 'dev'
Comment on lines +4 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to change that, depending on when to trigger the job. Most l likely on PRs to dev I guess?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct. I will be discussing the details of this with @rickoco (to understand our legal constraints) and the Members (to understand their expectations) and will update the trigger accordingly.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it relates to the process which had been setup for cv32e40p: https://github.com/openhwgroup/cv32e40p#contributing


jobs:
aws:
name: AWS Pipeline (private)
if: github.actor == 'davideschiavone' || github.actor == 'MikeOpenHWGroup' || github.actor == 'zarubaf'
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: eu-west-1
- name: Run AWS Pipeline
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: core-v-verif
hide-cloudwatch-logs: true
27 changes: 17 additions & 10 deletions bin/ci_check
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ if (sys.version_info < (3,0,0)):
# Globals....
name_of_ci_check_regression = '<core>_ci_check_dev' # must match the name of one regression list in .metrics.json
core_tests = ['misalign', 'illegal', 'dhrystone', 'fibonacci', 'riscv_ebreak_test_0']
return_code = 1 # signal failure by default
try:
default_core = os.environ['CV_CORE']
except KeyError:
Expand All @@ -73,6 +74,7 @@ print('ci_check: topdir : {}'.format(topdir))
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--simulator", help="SystemVerilog simulator", choices=['dsim', 'xrun', 'vsim', 'vcs', 'riviera'])
parser.add_argument("--core", help="Set the core to test (default: {})".format(default_core), default=default_core)
parser.add_argument("-b", "--batch", help="Run in batch mode (won't prompt for user input)", action="store_true")
parser.add_argument("-d", "--debug", help="Display debug messages", action="store_true")
parser.add_argument("-p", "--print_command", help="Print commands to stdout, do not run", action="store_true")
parser.add_argument("-c", "--check_only", help="Check previosu results (do not run)", action="store_true")
Expand Down Expand Up @@ -120,6 +122,7 @@ def check_uvm_results(check_only=0):
fail_count = 0
expct_fail = 0
pass_count = 0
global return_code

if os.path.exists(sim_results_dir):
fails = subprocess.Popen('grep "SIMULATION FAILED" `find {} -name "*.log" -print`'.format(sim_results_dir),
Expand Down Expand Up @@ -153,16 +156,19 @@ def check_uvm_results(check_only=0):
elif ((fail_count == 0) and (pass_count >=3)):
print ('\nCI Check PASSED with no failures.')
print ('OK to issue a pull-request.\n')
return_code = 0
elif (fail_count == expct_fail):
print ('\nCI Check PASSED with KNOWN failure(s).')
print ('OK to issue a pull-request.\n')
return_code = 0
else:
print ('\nCI Check FAILED with unknown failures.')
print ('Please fix before issuing a pull-request.\n')
else:
print ('\nCI Check FAILED with non-existent sim directory: {}'.format(sim_results_dir))
print ('Please fix before issuing a pull-request.\n')

exit(return_code)

def check_core_results(run_count):
core_runs = subprocess.Popen('grep "EXIT SUCCESS" -R -I ../{}/sim/core/simulation_results'.format(args.core.lower()),
Expand All @@ -187,9 +193,10 @@ def check_core_results(run_count):

# This script may do some unexpected things, so give the user an escape hatch.
def ask_user():
txt = input("Is this what you want [Y/N]? ")
if not ((txt == 'Y') or (txt == 'y')):
exit(1)
if (not args.batch):
txt = input("Is this what you want [Y/N]? ")
if not ((txt == 'Y') or (txt == 'y')):
exit(1)

# Load regression YAML
def load_regress_yaml(regression):
Expand Down Expand Up @@ -233,7 +240,7 @@ if (args.check_only):
check_core_results(len(core_tests)+1) # +1 because 'make' runs hello-world
if not (args.no_uvm):
check_uvm_results(args.check_only)
exit(0)
exit(return_code)

if (args.no_uvm):
uvm = 0
Expand All @@ -242,10 +249,10 @@ if (args.verilator):
veril = 1
elif (args.simulator == None):
print ('Must specify a simulator. Type `ci_check -h` to see how')
exit(0)
exit(1)
elif (not(shutil.which(args.simulator))):
print ('ERROR: simulator='+args.simulator+' but executable not found')
exit(0)
exit(1)
else:
svtool = args.simulator

Expand All @@ -254,16 +261,16 @@ print('ci_check: core : {}'.format(args.core))
print('ci_check: name_of_ci_check_regression : {}'.format(name_of_ci_check_regression))
os.environ['CV_CORE'] = args.core.upper()

# --print_command is set: do not actually _do_ anything
# if --print_command is set: do not actually _do_ anything
if not (prcmd):
if (args.keep):
print ('Keeping previously cloned version of the RTL plus any previously generated files')
ask_user()
else:
print ('This will delete your previously cloned RTL repo plus all previously generated files')
print ('Deleting your previously cloned RTL repo plus all previously generated files')
ask_user()
os.chdir(os.path.abspath(os.path.join(topdir, args.core.lower(), 'sim/uvmt')))
os.system('make clean_all')
os.system('make clean_all SIMULATOR={}'.format(args.simulator))
os.chdir(os.path.join(topdir, '{}/sim/core'.format(args.core.lower())))
os.system('make clean_all')
os.chdir(os.path.join(topdir, 'bin'))
Expand Down Expand Up @@ -319,7 +326,7 @@ if (uvm):
os.chdir(topdir) # cmd in .metrics.json assumes all cmds start from here
else:
print ('ERROR: cannot find build command in .metrics.json')
exit(0)
exit(1)

# Get the simulation command(s)
for key in metrics_dict:
Expand Down
37 changes: 37 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2023, OpenHW Group
# SPDX-License-Identifier:Apache-2.0 WITH SHL-2.0
#
# Build-specification for the aws.yml workflow.

version: 0.2

phases:

build:
commands:
- chown -R florian:florian .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not fully comprehend everything here, but are these scripts tied to a specific users account? should/could this be generalized?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question. The CI runs on a AWS VM instance that only OpenHW staff have access to. It could be any of us, but it cannot be "just anyone". It probably makes sense to create a generic "openhw-ci-runner" account that has its access privileges tuned to the CI requirements (and no more).

# - su florian -c "source /synopsys/scripts/env.sh; echo $PATH"
# VCS environment
- yum -y install gcc gcc-c++ make
- export VCS_HOME=/synopsys/vcs/S-2021.09-SP1
- export PATH=$VCS_HOME/bin:$PATH
- vcs -id
# - export LM_LICENSE_FILE=29000@ip-172-31-46-244
- export SNPSLMD_LICENSE_FILE=27020@ip-172-31-46-244.eu-west-1.compute.internal
# Questasim (vsim) environment
# - export QUESTAROOT=/onespin/questasim
# - export LM_LICENSE_FILE=29000@ip-172-31-46-244
# - export PATH=${QUESTAROOT}/bin:${PATH}
# - export MTI_VCO_MODE=64
# - wget https://buildbot.embecosm.com/job/corev-gcc-centos7/19/artifact/corev-openhw-gcc-centos7-20230905.tar.gz
Comment on lines +21 to +26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove the commented lines?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the commented lines will be removed before the Draft status of this PR is dropped. These were left in place to show you what I did to get Questasim (vsim) to run. It did not work. Perhaps the value of LM_LICENSE_FILE needs to be set to the same value as we are using for SNPSLMD_LICENSE_FILE? Any thoughts on this?

- curl -O https://buildbot.embecosm.com/job/corev-gcc-centos7/19/artifact/corev-openhw-gcc-centos7-20230905.tar.gz
- tar xf corev-openhw-gcc-centos7-20230905.tar.gz
- export HERE=`pwd`
- export CV_SW_TOOLCHAIN=$HERE/corev-openhw-gcc-centos7-20230905
- export CV_SW_PREFIX=riscv32-corev-elf-
- export CV_SW_MARCH=rv32imc_zicsr_zifencei
- corev-openhw-gcc-centos7-20230905/bin/riscv32-corev-elf-gcc --version
# - cd cv32e40p/sim/uvmt
# - make test USE_ISS=0 SIMULATOR=vcs TEST=hello-world
- cd bin
- ./ci_check --batch --iss 0 --simulator vcs --core cv32e40p
3 changes: 3 additions & 0 deletions mk/uvmt/vcs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ VCS_COMP_FLAGS ?= -lca -sverilog \
$(SV_CMP_FLAGS) $(VCS_UVM_ARGS) $(VCS_TIMESCALE) \
-assert svaext -race=all -ignore unique_checks -full64

# TODO: make this optional
VCS_COMP_FLAGS += -suppress

VCS_GUI ?=
VCS_RUN_COV = -cm line+cond+tgl+fsm+branch+assert -cm_dir $(MAKECMDGOALS).vdb

Expand Down