Skip to content

Commit

Permalink
Merge pull request #1671 from firesim/sudo-once
Browse files Browse the repository at this point in the history
Isolate `sudo` usage
  • Loading branch information
abejgonzalez committed Apr 30, 2024
2 parents 9073271 + 19eeffa commit e08207f
Show file tree
Hide file tree
Showing 35 changed files with 636 additions and 243 deletions.
34 changes: 34 additions & 0 deletions .github/scripts/build-driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3

import argparse
from enum import Enum
from fabric.api import prefix, run, execute # type: ignore

from ci_variables import ci_env

class FpgaPlatform(Enum):
vitis = 'vitis'
f1 = 'f1'
xilinx_alveo_u250 = 'xilinx_alveo_u250'

def __str__(self):
return self.value

parser = argparse.ArgumentParser(description='')
parser.add_argument('--platform', type=FpgaPlatform, choices=list(FpgaPlatform), required=True)
args = parser.parse_args()

def build_driver():
"""Runs compilation of FireSim driver for the make-default tuple"""

# assumptions:
# - the firesim repo is already setup in a prior script
# - machine-launch-script requirements are already installed

with prefix(f"cd {ci_env['REMOTE_WORK_DIR']}"):
with prefix('source sourceme-manager.sh --skip-ssh-setup'):
with prefix("cd ./sim"):
run(f"make PLATFORM={args.platform} {args.platform}")

if __name__ == "__main__":
execute(build_driver, hosts=["localhost"])
20 changes: 0 additions & 20 deletions .github/scripts/build-vitis-driver.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
#!/usr/bin/env python3

import sys
import argparse
from enum import Enum
from fabric.api import prefix, run, settings, execute # type: ignore

from ci_variables import ci_env

class FpgaPlatform(Enum):
vitis = 'vitis'
xilinx_alveo_u250 = 'xilinx_alveo_u250'

def __str__(self):
return self.value

parser = argparse.ArgumentParser(description='')
parser.add_argument('--platform', type=FpgaPlatform, choices=list(FpgaPlatform), required=True)
args = parser.parse_args()

def run_docs_generated_components_check():
""" Runs checks to make sure generated components of vitis docs have been
updated. """
Expand All @@ -19,7 +31,13 @@ def run_docs_generated_components_check():
with prefix('source sourceme-manager.sh --skip-ssh-setup'):
with prefix("cd deploy"):
run("cat config_runtime.yaml")
path = "docs/Getting-Started-Guides/On-Premises-FPGA-Getting-Started/Running-Simulations/DOCS_EXAMPLE_config_runtime.yaml"
if args.platform == FpgaPlatform.vitis:
subpath = 'AWS-EC2-F1-Getting-Started'
elif args.platform == FpgaPlatform.xilinx_alveo_u250:
subpath = 'On-Premises-FPGA-Getting-Started'
else:
assert False
path = f'docs/Getting-Started-Guides/{subpath}/Running-Simulations/DOCS_EXAMPLE_config_runtime.yaml'
run(f"cat ../{path}")
run(f"diff config_runtime.yaml ../{path}")

Expand Down
22 changes: 21 additions & 1 deletion .github/scripts/check-docs-generated-components.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
#!/usr/bin/env python3

import argparse
from enum import Enum
from fabric.api import cd, prefix, run, execute # type: ignore

from common import manager_fsim_dir, set_fabric_firesim_pem

class FpgaPlatform(Enum):
vitis = 'vitis'
f1 = 'f1'
xilinx_alveo_u250 = 'xilinx_alveo_u250'

def __str__(self):
return self.value

parser = argparse.ArgumentParser(description='')
parser.add_argument('--platform', type=FpgaPlatform, choices=list(FpgaPlatform), required=True)
args = parser.parse_args()

def run_docs_generated_components_check():
""" Runs checks to make sure generated components of docs have been
updated. """

with cd(manager_fsim_dir), prefix('source sourceme-manager.sh'):
with prefix("cd deploy"):
run("cat config_runtime.yaml")
path = 'docs/Getting-Started-Guides/AWS-EC2-F1-Getting-Started/Running-Simulations/DOCS_EXAMPLE_config_runtime.yaml'
if args.platform == FpgaPlatform.f1:
subpath = 'AWS-EC2-F1-Getting-Started'
elif args.platform == FpgaPlatform.xilinx_alveo_u250 or args.platform == FpgaPlatform.f1:
subpath = 'On-Premises-FPGA-Getting-Started'
else:
assert False
path = f'docs/Getting-Started-Guides/{subpath}/Running-Simulations/DOCS_EXAMPLE_config_runtime.yaml'
run(f"cat ../{path}")
run(f"diff config_runtime.yaml ../{path}")
run("firesim --help")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,48 @@
#!/usr/bin/env python3

import sys
import argparse
from enum import Enum
from fabric.api import prefix, run, settings, execute # type: ignore

from ci_variables import ci_env
from utils import search_match_in_last_workloads_output_file

def run_linux_poweroff_vitis():
""" Runs Base Vitis Build """
# vitis not supported since it should be removed eventually
class FpgaPlatform(Enum):
xilinx_alveo_u250 = 'xilinx_alveo_u250'

def __str__(self):
return self.value

parser = argparse.ArgumentParser(description='')
parser.add_argument('--platform', type=FpgaPlatform, choices=list(FpgaPlatform), required=True)
args = parser.parse_args()

def run_linux_poweroff():
""" Runs Linux Poweroff Tests - All Single-node Tests (Single-core Rocket/BOOM, Multi-core Rocket)"""

# assumptions:
# - machine-launch-script requirements are already installed
# - XILINX_VITIS, XILINX_XRT, XILINX_VIVADO are setup (in env / LD_LIBRARY_PATH / path / etc)
# - repo is already setup fully

# repo should already be checked out

with prefix(f"cd {ci_env['REMOTE_WORK_DIR']}"):
run("./build-setup.sh --skip-validate")
with prefix('source sourceme-manager.sh --skip-ssh-setup'):
with prefix('cd sw/firesim-software'):
# build outputs.yaml (use this workload since firemarshal can guestmount)
run("./marshal -v build test/outputs.yaml")
run("./marshal -v install test/outputs.yaml")

def run_w_timeout(workload_path, workload, timeout, num_passes):
def run_w_timeout(workload_path, config_runtime, workload, timeout, num_passes):
print(f"Starting workload run {workload}.")
log_tail_length = 300
rc = 0
with settings(warn_only=True):
# avoid logging excessive amounts to prevent GH-A masking secrets (which slows down log output)
# pty=False needed to avoid issues with screen -ls stalling in fabric
rc = run(f"timeout {timeout} {workload_path}/run-workload.sh {workload_path}/config_runtime.yaml &> {workload}.log", pty=False).return_code
rc = run(f"timeout {timeout} {workload_path}/run-workload.sh {workload_path}/{config_runtime} &> {workload}.log", pty=False).return_code
print(f" Printing last {log_tail_length} lines of log. See {workload}.log for full info.")
run(f"tail -n {log_tail_length} {workload}.log")

Expand All @@ -41,7 +54,7 @@ def run_w_timeout(workload_path, workload, timeout, num_passes):
print(f"Printing last {log_tail_length} lines of all output files. See results-workload for more info.")
run(f"""cd deploy/results-workload/ && LAST_DIR=$(ls | tail -n1) && if [ -d "$LAST_DIR" ]; then tail -n{log_tail_length} $LAST_DIR/*/*; fi""")

run(f"firesim terminaterunfarm -q -c {workload_path}/config_runtime.yaml")
run(f"firesim terminaterunfarm -q -c {workload_path}/{config_runtime}")

if rc != 0:
print(f"Workload {workload} failed.")
Expand All @@ -64,7 +77,9 @@ def check(match_key, file_name = 'uartlog'):

print(f"Workload run {workload} successful.")

run_w_timeout(f"{ci_env['GITHUB_WORKSPACE']}/deploy/workloads/ci/vitis", "linux-poweroff-singlenode", "30m", 1)
run_w_timeout(f"{ci_env['GITHUB_WORKSPACE']}/deploy/workloads/ci/{args.platform}", "config_runtime_rocket_singlecore.yaml", "linux-poweroff-singlenode-rocketsinglecore", "30m", 1)
run_w_timeout(f"{ci_env['GITHUB_WORKSPACE']}/deploy/workloads/ci/{args.platform}", "config_runtime_rocket_quadcore.yaml", "linux-poweroff-singlenode-rocketquadcore", "30m", 1)
run_w_timeout(f"{ci_env['GITHUB_WORKSPACE']}/deploy/workloads/ci/{args.platform}", "config_runtime_boom_singlecore.yaml", "linux-poweroff-singlenode-boomsinglecore", "30m", 1)

if __name__ == "__main__":
execute(run_linux_poweroff_vitis, hosts=["localhost"])
execute(run_linux_poweroff, hosts=["localhost"])
22 changes: 15 additions & 7 deletions .github/scripts/run-local-buildbitstreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from github import Github
import base64
import time
import argparse

from ci_variables import ci_env

Expand Down Expand Up @@ -223,12 +222,16 @@ def replace_in_hwdb(hwdb_entry_name: str, link: str) -> None:
# priority == roughly the more powerful and available
# ipaddr, buildtool:version, use unique build dir, unique build dir path, priority (0 is highest)(unused by code but used to track which machine has most resources)
hosts = [
( "as4", "vivado:2022.1", False, "", 0),
("buildbot1@as4", "vivado:2022.1", True, "/scratch/buildbot1/FIRESIM_BUILD_DIR", 0),
("buildbot2@as4", "vivado:2022.1", True, "/scratch/buildbot2/FIRESIM_BUILD_DIR", 0),
( "localhost", "vitis:2022.1", False, "", 0),
("buildbot1@a17", "vitis:2022.1", True, "/scratch/buildbot1/FIRESIM_BUILD_DIR", 0),
( "harp", "vitis:2022.1", False, "", 2),
("buildbot2@a17", "vitis:2021.1", True, "/scratch/buildbot2/FIRESIM_BUILD_DIR", 0),
("buildbot3@a17", "vitis:2021.1", True, "/scratch/buildbot3/FIRESIM_BUILD_DIR", 0),
("buildbot4@a17", "vitis:2021.1", True, "/scratch/buildbot4/FIRESIM_BUILD_DIR", 0),
( "firesim1", "vitis:2021.1", False, "", 1),
( "harp", "vitis:2022.1", False, "", 2),
( "jktgz", "vivado:2023.1", False, "", 3),
( "jktqos", "vivado:2023.1", False, "", 3),
]
Expand Down Expand Up @@ -278,16 +281,21 @@ def do_builds(batch_hwdbs):

# hwdb_entry_name, platform_name, buildtool:version
batch_hwdbs_in = [
# hwdb's to verify FPGA builds
("vitis_firesim_rocket_singlecore_no_nic", "vitis", "vitis:2022.1"),

("nitefury_firesim_rocket_singlecore_no_nic", "rhsresearch_nitefury_ii", "vitis:2022.1"),

("alveo_u250_firesim_rocket_singlecore_no_nic", "xilinx_alveo_u250", "vitis:2021.1"),
("alveo_u250_firesim_gemmini_rocket_singlecore_no_nic", "xilinx_alveo_u250", "vitis:2021.1"),
("alveo_u200_firesim_rocket_singlecore_no_nic", "xilinx_alveo_u200", "vitis:2021.1"),
("alveo_u250_firesim_rocket_singlecore_no_nic", "xilinx_alveo_u250", "vitis:2021.1"),
("alveo_u280_firesim_rocket_singlecore_no_nic", "xilinx_alveo_u280", "vitis:2021.1"),

("xilinx_vcu118_firesim_rocket_singlecore_4GB_no_nic", "xilinx_vcu118", "vivado:2023.1"),

# extra hwdb's to run CI with
("alveo_u250_firesim_rocket_quadcore_no_nic", "xilinx_alveo_u250", "vivado:2022.1"),
("alveo_u250_firesim_boom_singlecore_no_nic", "xilinx_alveo_u250", "vivado:2022.1"),
("alveo_u250_firesim_rocket_singlecore_nic", "xilinx_alveo_u250", "vivado:2022.1"),

# extra hwdb's
("alveo_u250_firesim_gemmini_rocket_singlecore_no_nic", "xilinx_alveo_u250", "vitis:2021.1"),
]

do_builds(batch_hwdbs_in)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/firesim-aws-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Check docs components that require manual re-generation (e.g. config_runtime.yaml example, help output)
run: ./.github/scripts/check-docs-generated-components.py
run: ./.github/scripts/check-docs-generated-components.py --platform f1

build-f1-driver:
name: build-f1-driver
Expand Down Expand Up @@ -311,7 +311,7 @@ jobs:
- uses: actions/checkout@v4
- name: Run buildbitstream command and update sample AGFIs
run: .github/scripts/run-agfi-buildbitstream.py
- uses: peter-evans/create-pull-request@v5
- uses: peter-evans/create-pull-request@v6
with:
base: ${{ github.head_ref }}
add-paths: "deploy/sample-backup-configs/sample_config_hwdb.yaml"
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/firesim-non-aws-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ env:
LC_ALL: "en_US.UTF-8"
CI_LABEL_DEBUG: ${{ contains(github.event.pull_request.labels.*.name, 'ci:debug') }}
CI_LABEL_PERSIST: ${{ contains(github.event.pull_request.labels.*.name, 'ci:persist-prior-workflows') }}
REMOTE_WORK_DIR: /scratch/buildbot/fs-shared/fs-${{ github.sha }}
REMOTE_WORK_DIR: /scratch/buildbot/fs-shared/fs-${{ github.sha }}-non-aws
TERM: xterm-256-color

jobs:
Expand Down Expand Up @@ -191,20 +191,20 @@ jobs:
cd ${{ env.REMOTE_WORK_DIR }}
./build-setup.sh --skip-validate
source sourceme-manager.sh --skip-ssh-setup
firesim managerinit --platform vitis
firesim managerinit --platform xilinx_alveo_u250
cd sw/firesim-software && ./init-submodules.sh
run-vitis-check-docs-generated-components:
name: run-vitis-check-docs-generated-components
run-xilinx_alveo_u250-check-docs-generated-components:
name: run-xilinx_alveo_u250-check-docs-generated-components
needs: [setup-local-fpga-repo]
runs-on: local-fpga
steps:
- uses: actions/checkout@v4
- name: Check Vitis docs components that require manual re-generation (e.g. config_runtime.yaml example)
run: ./.github/scripts/check-vitis-docs-generated-components.py
- name: Check Xilinx Alveo U250 docs components that require manual re-generation (e.g. config_runtime.yaml example)
run: ./.github/scripts/check-docs-generated-components-local.py --platform xilinx_alveo_u250

run-parallel-vcs-metasims-and-vitis-driver:
name: run-parallel-vcs-metasims-and-vitis-driver
run-parallel-vcs-metasims-and-xilinx_alveo_u250-driver:
name: run-parallel-vcs-metasims-and-xilinx_alveo_u250-driver
needs: [setup-local-fpga-repo]
runs-on: local-fpga
steps:
Expand All @@ -217,13 +217,13 @@ jobs:
- uses: actions/checkout@v4
- name: Run parallel VCS metasims
run: .github/scripts/run-parallel-vcs-metasims.py
- name: Build Vitis driver
run: .github/scripts/build-vitis-driver.py
- name: Build Xilinx Alveo U250 driver
run: .github/scripts/build-driver.py --platform xilinx_alveo_u250

run-basic-linux-poweroff-vitis:
run-basic-linux-poweroffs-xilinx_alveo_u250:
if: contains(github.event.pull_request.labels.*.name, 'ci:fpga-deploy')
needs: [setup-local-fpga-repo]
name: run-basic-linux-poweroff-vitis
name: run-basic-linux-poweroffs-xilinx_alveo_u250
runs-on: local-fpga
steps:
# This forces a fresh clone of the repo during the `checkout` step
Expand All @@ -233,8 +233,8 @@ jobs:
rm -rf ${{ github.workspace }}/* || true
rm -rf ${{ github.workspace }}/.* || true
- uses: actions/checkout@v4
- name: Run simple linux poweroff test w/ vitis
run: .github/scripts/run-linux-poweroff-vitis.py
- name: Run non-networked single-node Linux poweroff tests (single-core Rocket/BOOM, multi-core Rocket) w/ Xilinx Alveo U250
run: .github/scripts/run-linux-poweroff-local.py --platform xilinx_alveo_u250

run-local-fpga-buildbitstream:
if: contains(github.event.pull_request.labels.*.name, 'ci:local-fpga-buildbitstream-deploy')
Expand All @@ -252,7 +252,7 @@ jobs:
- uses: actions/checkout@v4
- name: Run buildbitstream command and update sample local bitstreams
run: .github/scripts/run-local-buildbitstreams.py
- uses: peter-evans/create-pull-request@v5
- uses: peter-evans/create-pull-request@v6
with:
base: ${{ github.head_ref }}
add-paths: "deploy/sample-backup-configs/sample_config_hwdb.yaml"
Expand All @@ -263,7 +263,7 @@ jobs:

cleanup-local-fpga-repo:
name: cleanup-local-fpga-repo
needs: [run-parallel-vcs-metasims-and-vitis-driver, run-basic-linux-poweroff-vitis, run-vitis-check-docs-generated-components, run-local-fpga-buildbitstream]
needs: [run-xilinx_alveo_u250-check-docs-generated-components, run-parallel-vcs-metasims-and-xilinx_alveo_u250-driver, run-basic-linux-poweroffs-xilinx_alveo_u250, run-local-fpga-buildbitstream]
# uses a separate runner to cleanup (irrespective, of other jobs cancelled, running, etc)
runs-on: local-fpga-cleanup
if: ${{ always() }}
Expand Down

0 comments on commit e08207f

Please sign in to comment.