Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
Allow build from sources and check if XOCL is properly installed
Browse files Browse the repository at this point in the history
  • Loading branch information
JGoutin committed Aug 13, 2021
1 parent c6eb53a commit b336666
Show file tree
Hide file tree
Showing 14 changed files with 641 additions and 408 deletions.
3 changes: 3 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
skip_list:
- role-name
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,32 @@ CentOS 7 is recommended on AWS since AWS only provides packages for it.

## Role Variables

* **xilinx_xrt_install**: If `true` install XRT.
* **xilinx_xrt_install**: If `true`, install XRT.
Default to `true`.
* **xilinx_xrt_version**: Xilinx XRT version to install.
Default to the latest available.
* **xilinx_xrt_from_src**: If `true`, install XRT from sources instead of Xilinx provided packages.
Default to `false`.
* **xilinx_xrt_env**: XRT specific environment.
Supported values: `aws`.
Default to the classical Xilinx XRT environment.
Supported values: `aws`, `azure`.
If not specified, default to the classical Xilinx XRT environment.
* **xilinx_xrt_ensure_compatible_kernel**: If `true`, ensure the Linux kernel installed is compatible.
Default to `true`.
* **xilinx_xrt_bashrc**: If `true`, add the source of the XRT setup script to the user `~/.bashrc`.
Default to `false`.
* **xilinx_xrt_container**: Set this to `true` if running the role inside a container to avoid kernel version mismatch issues.
Default to `false`.
* **xilinx_xrt_rhel7_devtoolset**: Fallback Red Hat Developer Toolset version to use on RHEL/CentOS 7 if not installed by XRT provided dependencies install script.
No effect if *xilinx_xrt_from_src* is `false`.
Default to `9`.

### AWS FPGA

The following is only available when **xilinx_xrt_env** is set to `aws`.

AWS environment support extra variables associated to [AWS FPGA](https://github.com/aws/aws-fpga).

* **aws_fpga_install**; If `true` install AWS FPGA runtime libraries.
The following is only available when **xilinx_xrt_env** is set to `aws`.

* **aws_fpga_install**: If `true`, install AWS FPGA runtime libraries.
Default to `true`.
* **aws_fpga_src_install**: If specified, install AWS FPGA sources in the specified directory.
Default is to not install sources.
Expand All @@ -47,6 +54,7 @@ AWS environment support extra variables associated to [AWS FPGA](https://github.
Default to `false`.
No effect if *aws_fpga_allow_non_root* is `false`.
* **aws_fpga_driver**: If specified, install the specified alternate driver.
If not specified use the default XOCL driver.
This may require *xilinx_xrt_install* set to `False`.
Supported values: `xdma`.

Expand Down
7 changes: 6 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pool:

jobs:
- job: tests
timeoutInMinutes: 120
displayName: Tests
variables:
cacheDir: /tmp/.pipeline_cache
Expand Down Expand Up @@ -67,9 +68,13 @@ jobs:
displayName: Test Ansible role
condition: always()
env:
ANSIBLE_STDOUT_CALLBACK: debug
ANSIBLE_DISPLAY_SKIPPED_HOSTS: "False"
ANSIBLE_FORCE_COLOR: "True"
ANSIBLE_FORKS: "30"
ANSIBLE_NOCOLOR": "False"
ANSIBLE_PIPELINING: "True"
ANSIBLE_SSH_ARGS: "-o ControlMaster=auto -o ControlPersist=60s"
ANSIBLE_STDOUT_CALLBACK: debug

- job:
displayName: Ansible Galaxy publish
Expand Down
25 changes: 17 additions & 8 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@
# Install Xilinx XRT
xilinx_xrt_install: true

# Install Xilinx XRT from sources instead of packages
xilinx_xrt_from_src: false

# Add "source /opt/xilinx/xrt/setup.sh" to user "~/.bashrc"
xilinx_xrt_bashrc: false

# Xilinx XRT environement, default to Xilinx classical environement
xilinx_xrt_env: ''
_xilinx_xrt_env: "{{ xilinx_xrt_env | default('') }}"

# Xilinx XRT version to install (Default to latest available
xilinx_xrt_version: "{{ xilinx_xrt_env | xrt_latest(ansible_facts)}}"
xilinx_xrt_version: "{{ _xilinx_xrt_env | xrt_latest(ansible_facts) }}"

# Linux kernel version compatibles with XRT
xilinx_xrt_ensure_compatible_kernel: true

# Run inside a container
xilinx_xrt_container: false

# Red Hat Developer Toolset CentOS 7 fallback version
xilinx_xrt_rhel7_devtoolset: 9

# If true and xilinx_xrt_env is "aws", install AWS FPGA runtimes
aws_fpga_install: true

Expand All @@ -26,11 +35,11 @@ aws_fpga_sdk_override_group: false
# -------------------

xrt_package: "{{ xilinx_xrt_version |
xrt_pkg_name('xrt', xilinx_xrt_env, ansible_facts)}}"
xrt_pkg_name('xrt', _xilinx_xrt_env, ansible_facts)}}"
xrt_source: "{{ xilinx_xrt_version |
xrt_pkg_src('xrt', xilinx_xrt_env, ansible_facts)}}"
xrt_pkg_src('xrt', _xilinx_xrt_env, ansible_facts)}}"

aws_package: "{{ xilinx_xrt_version |
xrt_pkg_name('aws', xilinx_xrt_env, ansible_facts)}}"
aws_source: "{{ xilinx_xrt_version |
xrt_pkg_src('aws', xilinx_xrt_env, ansible_facts)}}"
env_package: "{{ xilinx_xrt_version |
xrt_pkg_name(_xilinx_xrt_env, _xilinx_xrt_env, ansible_facts)}}"
env_source: "{{ xilinx_xrt_version |
xrt_pkg_src(_xilinx_xrt_env, _xilinx_xrt_env, ansible_facts)}}"
62 changes: 60 additions & 2 deletions filter_plugins/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@
"2018.2": "3.10.0-957",
}
},
"Debian": {"bionic": {"2018.3": "4.18.0", "2018.2": "4.18.0"}},
"Debian": {
"bionic": {
"2018.3": "4.18.0",
"2018.2": "4.18.0",
"2019.1": "4.18.0",
"2019.2": "4.18.0",
"2020.1": "4.18.0",
}
},
}


Expand Down Expand Up @@ -277,11 +285,59 @@ def xrt_kernel(version, ansible_facts):
"""
family, dist = _os_release(ansible_facts)
try:
return _MAX_KERNEL[family][dist][version]
return _MAX_KERNEL[family][dist][str(version)]
except KeyError:
return ""


def xrt_find_package_path(packages, name):
"""
Get package path from a list of package from "ansible.builtin.find".
Args:
packages (list of dict): XRT packages list.
name (str): Package name: 'xrt' or 'aws'.
Returns:
str: Package path.
"""
filtered = tuple(
package["path"]
for package in packages
if package["path"].rsplit(".", 1)[0].endswith("-" + name)
)
try:
return filtered[0]
except IndexError:
raise ValueError(
'No package found for "%s" in %s'
% (name, ", ".join(package["path"] for package in packages))
)


def xrt_find_devtoolset(ansible_facts):
"""
Get the latest installed Red Hat Developer Toolset from installed package.
Args:
ansible_facts (dict): Ansible facts.
Returns:
str: Package path.
"""
import re

devtoolset_match = re.compile(r"^devtoolset-\d+$").match
filtered = sorted(
(package for package in ansible_facts["packages"] if devtoolset_match(package)),
key=lambda k: int(k.rsplit("-", 1)[1]),
)
try:
return filtered[-1]
except IndexError:
raise ValueError('No "devtoolset-*" package installed')


class FilterModule(object):
"""Return filter plugin"""

Expand All @@ -293,4 +349,6 @@ def filters():
"xrt_pkg_name": xrt_pkg_name,
"xrt_pkg_src": xrt_pkg_src,
"xrt_latest": xrt_latest,
"xrt_find_package_path": xrt_find_package_path,
"xrt_find_devtoolset": xrt_find_devtoolset,
}
4 changes: 2 additions & 2 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
- name: Converge
hosts: all
strategy: free
roles:
- role: ansible-role-xilinx_xrt
vars:
xilinx_xrt_ensure_compatible_kernel: false
reboot_on_kernel_update: false
xilinx_xrt_container: true
22 changes: 22 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ platforms:
groups:
- xrt_2019_2

- name: ubuntu_bionic-2019.2-src
image: ubuntu:bionic
groups:
- xrt_2019_2
- xrt_src

- name: ubuntu_bionic-2019.1
image: ubuntu:bionic
groups:
Expand Down Expand Up @@ -80,6 +86,12 @@ platforms:
groups:
- xrt_2021_1

- name: centos_7-2021.1-src
image: centos:7
groups:
- xrt_2021_1
- xrt_src

- name: centos_7-2020.1
image: centos:7
groups:
Expand Down Expand Up @@ -136,6 +148,8 @@ provisioner:
xilinx_xrt_version: 2018.3
xrt_2018_2:
xilinx_xrt_version: 2018.2
xrt_src:
xilinx_xrt_from_src: true
no_xrt:
xilinx_xrt_install: false
aws:
Expand All @@ -146,3 +160,11 @@ provisioner:

verifier:
name: testinfra

scenario:
test_sequence:
- dependency
- create
- converge
- idempotence
- verify
Loading

0 comments on commit b336666

Please sign in to comment.