Skip to content

Commit e951a81

Browse files
authored
XRT Flow Fix & Patch enablement (#474)
* XRT Flow fixes & patch enablement Jenkins SDAccel runtime test updates for XRT. * Document fixes & code indentation fix * fixed license issues in ddr4_rank.sv file alternate method for xocl driver removal and dependencies * Adding code to cover Non-DevAmi runtime instances * * Using modprobe instead of insmod * Using modprobe -r instead of rmmod * Removed calls to load_msix_workaround * Not loading cl_dram_dma afi before driver tests * Clearing AFI's before running driver tests * * Clear images before removing all drivers * Use modprobe instead of insmod/rmmod * In edma/xdma test teardown, clear AFI before removing all drivers * adding patch flow for 2018.2 SDX AR71715 patch. * removing MYVIVADO modification after patch installation * reverting to insmod & rmmod since modprobe give fatal error which cannot be overridden. * updating xrt version check to hash adding xrt patch upgrade into jenkins flow adding runtime check script into jenkins flow for runtime tests. * fixing aws-fpga-ami s3 path for patch download. fixing xocl_driver install/removal code in jenkins flow for runtime tests. * improving code cosmetics and error messaging * reverting updates to ddr4 rank
1 parent 5e49cfd commit e951a81

File tree

13 files changed

+359
-44
lines changed

13 files changed

+359
-44
lines changed

SDAccel/README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,11 @@ Here are the steps:
209209
* Ensure the host application can find and load the \*.awsxclbin AWS FPGA binary file.
210210

211211
* Source the Runtime Environment & Execute your Host Application
212-
* Xilinx SDx 2017.4:
213212
```
214213
$ sudo sh
215-
# source /opt/Xilinx/SDx/2017.4.rte.dyn/setup.sh # Other runtime env settings needed by the host app should be setup after this step
214+
# source $AWS_FPGA_REPO_DIR/sdaccel_runtime_setup.sh # Other runtime env settings needed by the host app should be setup after this step
216215
# ./helloworld
217216
```
218-
219-
* Xilinx SDx 2018.2:
220-
```
221-
$ sudo sh
222-
# source /opt/xilinx/xrt/setup.sh # Other runtime env settings needed by the host app should be setup after this step
223-
# ./helloworld
224-
```
225-
226217

227218
<a name="read"></a>
228219
# Additional SDAccel Information (2017.4)

SDAccel/docs/Debug_RTL_Kernel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Please note, the angle bracket directories need to be replaced according to the
149149

150150
```
151151
$ sudo sh
152-
# source /opt/Xilinx/SDx/2017.4.rte.dyn/setup.sh
152+
# source $AWS_FPGA_REPO_DIR/sdaccel_runtime_setup.sh
153153
# ./host
154154
```
155155
This produces the following output:

SDAccel/examples/aws/helloworld_ocl_runtime/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Command sequence
3636
```
3737
sudo fpga-clear-local-image -S 0
3838
>>$sudo sh
39-
sh-4.2# source /opt/Xilinx/SDx/2017.4.rte.dyn/setup.sh
39+
sh-4.2# source $AWS_FPGA_REPO_DIR/sdaccel_runtime_setup.sh
4040
sh-4.2# ./helloworld
4141
4242
```

SDAccel/sdaccel_xrt_version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
343186f76f59edd01bc48d84cf67fe22a0a3f338

SDAccel/tests/test_run_sdaccel_example.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,19 @@ def teardown_method(self, test_method):
7272
aws_fpga_test_utils.remove_all_drivers()
7373

7474
def test_run_sdaccel_example(self, examplePath, rteName, xilinxVersion):
75-
75+
aws_fpga_test_utils.install_xocl_driver()
7676
os.chdir(self.get_sdaccel_example_fullpath(examplePath))
7777

7878
(rc, stdout_lines, stderr_lines) = self.run_cmd("make exe")
7979
assert rc == 0
8080

8181
em_run_cmd = self.get_sdaccel_example_run_cmd(examplePath)
82+
check_runtime_script = os.path.join(AwsFpgaTestBase.WORKSPACE,'sdaccel_runtime_setup.sh')
8283

8384
self.get_sdaccel_aws_xclbin_file(examplePath, rteName, xilinxVersion)
84-
85-
run_cmd = "sudo -E /bin/bash -l -c \"source /opt/Xilinx/SDx/{}.rte.{}/setup.sh && {} \"".format(xilinxVersion, rteName, em_run_cmd)
85+
86+
run_cmd = "sudo -E /bin/bash -l -c \"source {} && {} \"".format(check_runtime_script, em_run_cmd)
8687

87-
if xilinxVersion == "2018.2":
88-
run_cmd = "sudo -E /bin/bash -l -c \"source /opt/xilinx/xrt/setup.sh && {} \"".format(em_run_cmd)
89-
9088
logger.info("Running cmd={}".format(run_cmd))
9189
(rc, stdout_lines, stderr_lines) = self.run_cmd(run_cmd)
9290
assert rc == 0

sdaccel_runtime_setup.sh

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
# Amazon FPGA Hardware Development Kit
2+
#
3+
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Amazon Software License (the "License"). You may not use
6+
# this file except in compliance with the License. A copy of the License is
7+
# located at
8+
#
9+
# http://aws.amazon.com/asl/
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed on
12+
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or
13+
# implied. See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Script must be sourced from a bash shell or it will not work
17+
# When being sourced $0 will be the interactive shell and $BASH_SOURCE_ will contain the script being sourced
18+
# When being run $0 and $_ will be the same.
19+
script=${BASH_SOURCE[0]}
20+
if [ $script == $0 ]; then
21+
echo "ERROR: You must source this script"
22+
exit 2
23+
fi
24+
25+
full_script=$(readlink -f $script)
26+
script_name=$(basename $full_script)
27+
script_dir=$(dirname $full_script)
28+
current_dir=$(pwd)
29+
30+
source $script_dir/shared/bin/set_common_functions.sh
31+
source $script_dir/shared/bin/set_common_env_vars.sh
32+
33+
# Source sdk_setup.sh
34+
info_msg "Sourcing sdk_setup.sh"
35+
if ! source $AWS_FPGA_REPO_DIR/sdk_setup.sh; then
36+
return 1
37+
fi
38+
39+
if [ -z "$SDK_DIR" ]; then
40+
err_msg "SDK_DIR environment variable is not set. Please use 'source sdk_setup.sh' from the aws-fpga directory."
41+
return 1
42+
fi
43+
44+
debug=0
45+
override=0
46+
function usage {
47+
echo -e "USAGE: source [\$AWS_FPGA_REPO_DIR/]$script_name [-d|-debug] [-h|-help] [-o|-override]"
48+
}
49+
50+
function help {
51+
info_msg "$script_name"
52+
info_msg " "
53+
info_msg "Checks & Sets up the runtime environment for AWS FPGA SDAccel Application usage."
54+
info_msg " "
55+
info_msg "sdaccel_runtime_check.sh script will:"
56+
info_msg " (1) install FPGA Management Tools,"
57+
info_msg " (2) check if Xilinx Runtime (XRT) is installed"
58+
info_msg " (3) check if correct version of Xilinx Runtime (XRT) is installed,"
59+
info_msg " (4) check if the required XOCL driver is running "
60+
info_msg " (5) source runtime setup script "
61+
echo " "
62+
usage
63+
}
64+
65+
function xrt_install_instructions_2018_2 {
66+
err_msg "AWS recommended XRT version release: https://github.com/Xilinx/XRT/releases/tag/2018.2_XDF.RC4"
67+
err_msg "refer to following link for instructions to install XRT"
68+
err_msg "https://www.xilinx.com/html_docs/xilinx2018_2_xdf/sdaccel_doc/ejy1538090924727.html"
69+
err_msg "use following command to download and install latest validated XRT rpms for centos distributions"
70+
err_msg "curl -s https://s3.amazonaws.com/aws-fpga-developer-ami/1.5.0/Patches/xrt_201802.2.1.0_7.5.1804-xrt.rpm -o xrt_201802.2.1.0_7.5.1804-xrt.rpm"
71+
err_msg "curl -s https://s3.amazonaws.com/aws-fpga-developer-ami/1.5.0/Patches/xrt_201802.2.1.0_7.5.1804-aws.rpm -o xrt_201802.2.1.0_7.5.1804-aws.rpm"
72+
err_msg "sudo yum reinstall -y xrt_*-xrt.rpm"
73+
err_msg "sudo yum reinstall -y xrt_*-aws.rpm"
74+
}
75+
76+
function check_xdma_driver {
77+
78+
if lsmod | grep -q 'xdma' ; then
79+
err_msg "Found XDMA Driver running. Please remove xdma driver using below command"
80+
err_msg " rmmod xdma"
81+
return 1
82+
fi
83+
}
84+
85+
function check_edma_driver {
86+
87+
if lsmod | grep -q 'edma' ; then
88+
err_msg "Found EDMA Driver running. Please remove edma driver using below command"
89+
err_msg " rmmod edma"
90+
return 1
91+
fi
92+
}
93+
94+
function check_xocl_driver {
95+
if lsmod | grep -q 'xocl' ; then
96+
info_msg "Found 'xocl Driver is installed and running. ' "
97+
else
98+
err_msg " XOCL Driver not installed. Please install xocl driver using below instructions"
99+
err_msg " If using 2017.4 Vivado toolset please source $AWS_FPGA_REPO_DIR/sdaccel_setup.sh "
100+
err_msg " if using 2018.2 Vivado toolset please reinstall rpm using instructions below "
101+
xrt_install_instructions_2018_2
102+
return 1
103+
fi
104+
}
105+
106+
# Process command line args
107+
args=( "$@" )
108+
for (( i = 0; i < ${#args[@]}; i++ )); do
109+
arg=${args[$i]}
110+
case $arg in
111+
-d|-debug)
112+
debug=1
113+
;;
114+
-h|-help)
115+
help
116+
return 0
117+
;;
118+
-o|-override)
119+
override=1
120+
;;
121+
*)
122+
err_msg "Invalid option: $arg\n"
123+
usage
124+
return 1
125+
esac
126+
done
127+
128+
129+
if ! is_vivado_available; then
130+
if [[ -z "${VIVADO_TOOL_VERSION}" ]]; then
131+
err_msg " You are not using FPGA Developer AMI and VIVADO_TOOL_VERSION ENV variable is Empty. "
132+
err_msg " ENV Variable VIVADO_TOOL_VERSION is required to be set for runtime "
133+
err_msg " If AFI was generated using V2018.2 tools use the command : export VIVADO_TOOL_VERSION=2018.2 "
134+
err_msg " If AFI was generated using V2017.4 tools use the command : export VIVADO_TOOL_VERSION=2017.4 "
135+
err_msg " If you are using the FPGA Developer AMI then please request support on AWS FPGA Developers Forum."
136+
return 1
137+
else
138+
info_msg " VIVADO tools not found. Reading VIVADO_TOOL_VERSION ENV variable to determine runtime version... "
139+
VIVADO_TOOL_VERSION="${VIVADO_TOOL_VERSION}"
140+
export VIVADO_TOOL_VERSION=${VIVADO_TOOL_VERSION:0:6}
141+
fi
142+
else
143+
info_msg "You are using instance with installed vivado tools. determining VIVADO version for runtime setup..."
144+
VIVADO_TOOL_VERSION=`vivado -version | grep Vivado | head -1 | sed 's:Vivado *::' | sed 's: .*$::' | sed 's:v::'`
145+
export VIVADO_TOOL_VERSION=${VIVADO_TOOL_VERSION:0:6}
146+
fi
147+
info_msg "VIVADO_TOOL_VERSION is $VIVADO_TOOL_VERSION"
148+
149+
150+
151+
check_xdma_driver
152+
check_edma_driver
153+
154+
if [[ "$VIVADO_TOOL_VERSION" =~ .*2018\.2.* ]]; then
155+
info_msg "Xilinx Vivado version is 2018.2"
156+
157+
if override; then
158+
info_msg "XRT check overide selected."
159+
source /opt/xilinx/xrt/setup.sh
160+
return 0
161+
fi
162+
163+
if [ -f "/opt/xilinx/xrt/include/version.h" ]; then
164+
info_msg "XRT installed. proceeding to check version compatibility"
165+
xrt_build_ver=$(grep 'xrt_build_version_hash\[\]' /opt/xilinx/xrt/include/version.h | sed 's/";//' | sed 's/^.*"//')
166+
info_msg "Installed XRT version : $xrt_build_ver"
167+
if grep -Fxq "$xrt_build_ver" $AWS_FPGA_REPO_DIR/SDAccel/sdaccel_xrt_version.txt
168+
then
169+
info_msg "XRT version $xrt_build_ver is supported."
170+
info_msg " Now checking XOCL driver..."
171+
check_xocl_driver
172+
if [ -f "/opt/xilinx/xrt/setup.sh" ]; then
173+
source /opt/xilinx/xrt/setup.sh
174+
else
175+
err_msg " Cannot find /opt/xilinx/xrt/setup.sh "
176+
err_msg " Please check XRT is installed correctly "
177+
return 1
178+
fi
179+
info_msg " XRT Runtime setup Done "
180+
else
181+
err_msg "$xrt_build_ver does not match recommended version"
182+
cat $AWS_FPGA_REPO_DIR/SDAccel/sdaccel_xrt_version.txt
183+
xrt_install_instructions_2018_2
184+
return 1
185+
fi
186+
else
187+
err_msg "XRT not installed. Please install XRT"
188+
xrt_install_instructions_2018_2
189+
return 1
190+
fi
191+
else
192+
info_msg "Xilinx Vivado version is $VIVADO_TOOL_VERSION "
193+
#info_msg " checking for file: /opt/Xilinx/SDx/${VIVADO_TOOL_VERSION}.rte.dyn/setup.sh"
194+
info_msg " Now checking XOCL driver..."
195+
check_xocl_driver
196+
if [ -f "/opt/Xilinx/SDx/${VIVADO_TOOL_VERSION}.rte.dyn/setup.sh" ]; then
197+
info_msg " Sourcing /opt/Xilinx/SDx/${VIVADO_TOOL_VERSION}.rte.dyn/setup.sh"
198+
source /opt/Xilinx/SDx/${VIVADO_TOOL_VERSION}.rte.dyn/setup.sh
199+
info_msg "$VIVADO_TOOL_VERSION Runtime setup Done"
200+
else
201+
err_msg " /opt/Xilinx/SDx/${VIVADO_TOOL_VERSION}.rte.dyn/setup.sh Not found. "
202+
err_msg "$VIVADO_TOOL_VERSION runtime environment not installed. Please source $AWS_FPGA_REPO_DIR/sdaccel_setup.sh"
203+
return 1
204+
fi
205+
fi
206+
207+
info_msg "SDAccel runtime check PASSED"

sdaccel_setup.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,17 @@ for (( i = 0; i < ${#args[@]}; i++ )); do
157157
esac
158158
done
159159

160-
# Install patches as required.
161-
setup_patches
162-
163160
# Check XILINX_SDX is set
164161
if ! check_set_xilinx_sdx; then
165162
return 1
166163
fi
167164

165+
info_msg " XILINX_SDX is set to $XILINX_SDX"
166+
# Install patches as required.
167+
info_msg " Checking & installing required patches"
168+
setup_patches
169+
170+
168171
# Update Xilinx SDAccel Examples from GitHub
169172
info_msg "Using SDx $RELEASE_VER"
170173
if [[ $RELEASE_VER =~ .*2017\.4.* || $RELEASE_VER =~ .*2018\.2.* ]]; then

sdk/tests/test_edma.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,23 @@ def setup_class(cls):
5959
return
6060

6161
def setup_method(self, test_method):
62+
63+
for slot in range(AwsFpgaTestBase.num_slots):
64+
AwsFpgaTestBase.fpga_clear_local_image(slot)
65+
6266
aws_fpga_test_utils.remove_all_drivers()
6367

6468
for slot in range(AwsFpgaTestBase.num_slots):
6569
self.fpga_load_local_image(self.cl_dram_dma_agfi, slot)
6670
assert AwsFpgaTestBase.check_fpga_afi_loaded(self.cl_dram_dma_agfi, slot), "{} not loaded in slot {}".format(self.cl_dram_dma_agfi, slot)
6771

6872
def teardown_method(self, test_method):
69-
aws_fpga_test_utils.remove_all_drivers()
7073

7174
for slot in range(AwsFpgaTestBase.num_slots):
7275
AwsFpgaTestBase.fpga_clear_local_image(slot)
7376

77+
aws_fpga_test_utils.remove_all_drivers()
78+
7479
@pytest.fixture(params=['poll','interrupt'])
7580
def driver_mode(self, request):
7681
return request.param

sdk/tests/test_xdma.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,24 @@ def setup_class(cls):
6666
return
6767

6868
def setup_method(self, test_method):
69+
70+
for slot in range(AwsFpgaTestBase.num_slots):
71+
AwsFpgaTestBase.fpga_clear_local_image(slot)
72+
6973
aws_fpga_test_utils.remove_all_drivers()
7074

7175
for slot in range(AwsFpgaTestBase.num_slots):
7276
self.fpga_load_local_image(self.cl_dram_dma_agfi, slot)
7377
assert AwsFpgaTestBase.check_fpga_afi_loaded(self.cl_dram_dma_agfi, slot), "{} not loaded in slot {}".format(self.cl_dram_dma_agfi, slot)
7478

79+
7580
def teardown_method(self, test_method):
76-
aws_fpga_test_utils.remove_all_drivers()
7781

7882
for slot in range(AwsFpgaTestBase.num_slots):
7983
AwsFpgaTestBase.fpga_clear_local_image(slot)
8084

85+
aws_fpga_test_utils.remove_all_drivers()
86+
8187
@pytest.fixture(params=['poll','interrupt'])
8288
def driver_mode(self, request):
8389
return request.param

0 commit comments

Comments
 (0)