0% found this document useful (0 votes)
101 views31 pages

DE10 Standard OpenCL 18.0

de10 fpga

Uploaded by

Hadji Mhamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views31 pages

DE10 Standard OpenCL 18.0

de10 fpga

Uploaded by

Hadji Mhamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

DE10-Standard OpenCL 1 www.terasic.

com
July 3, 2018
CONTENTS

CHAPTER 1 INTRODUCTION ................................................................................................................................. 3

1.1 DE10-STANDARD OPENCL BSP ............................................................................................................................... 3


1.2 SYSTEM REQUIREMENTS ........................................................................................................................................... 4
1.3 OPENCL ARCHITECTURE .......................................................................................................................................... 5
1.4 EXECUTE OPENCL DEMO ON DE10-STANDARD ....................................................................................................... 6

CHAPTER 2 OPENCL ON WINDOWS ................................................................................................................. 12

2.1 SOFTWARE INSTALLATION ....................................................................................................................................... 12


2.2 LICENSE INSTALLATION .......................................................................................................................................... 13
2.3 OPENCL ENVIRONMENT CONFIGURATION .............................................................................................................. 14
2.4 OPENCL ENVIRONMENT VERIFICATION .................................................................................................................. 16
2.5 COMPILE AND EXECUTE OPENCL PROJECT............................................................................................................. 17

CHAPTER 3 OPENCL ON LINUX ..................................................................................................................... 22

3.1 SOFTWARE INSTALLATION ....................................................................................................................................... 22


3.2 OPENCL LICENSE INSTALLATION ............................................................................................................................ 24
3.3 CONFIGURATION OF ENVIRONMENT VARIABLES ..................................................................................................... 25
3.4 VERIFICATION OF OPENCL ENVIRONMENT ............................................................................................................. 25
3.5 BUILD AND EXECUTE OPENCL PROJECT ................................................................................................................. 27

REVISION HISTORY ............................................................................................................................................... 31

COPYRIGHT STATEMENT ................................................................................................................................... 31

DE10-Standard OpenCL 2 www.terasic.com


July 3, 2018
Chapter 1
Introduction

DE10-Standard is a robust hardware design platform built with Intel System-on-Chip (SoC) FPGA.
It is designed for Intel University Program. This document gives introduction on how to setup
OpenCL development environment, compile, and execute example projects for DE10-Standard.
Users can refer to Intel SDK for OpenCL Programming Guide for more details about OpenCL
coding instruction.

http://www.altera.com/literature/hb/opencl-sdk/aocl_programming_guide.pdf

1.1 DE10-Standard OpenCL BSP

The DE10-Standard OpenCL Board Support Package (BSP) contains required resources for users to
develop OpenCL project based on DE10-Standard Board. The BSP is available from the website:

http://de10-standard.terasic.com/cd

For Windows Host, please download DE10-Standard_OpenCL_BSP.zip. For Linux, please


download the DE10-Standard_OpenCL_BSP.tar.gz. The CentOS 7.2 Linux distribution is
recommended for the OpenCL application. These two compressed files are different in the
compression type only and their contents are the same. Figure 1-1 shows the contents of OpenCL
BSP for DE10-Standard.

DE10-Standard OpenCL 3 www.terasic.com


July 3, 2018
Figure 1-1 Contents of OpenCL BSP for DE10-Standard

1.2 System Requirements

The following items are required to setup OpenCL for DE10-Standard board:

⚫ Terasic DE10-Standard board


⚫ microSD card with at least 4GB capacity
⚫ microSD card reader
⚫ USB cable (type A to mini-B)
⚫ Ethernet cable or USB-Storage
⚫ Host PC with
◼ USB host port
◼ 32GB memory is recommended
◼ 64-bit Windows 7/10 or Linux
◼ Win32 Disk Imager
◼ PuTTY or Minicom(Linux) utility
◼ Intel Quartus Prime Standard Edition 18.0.0.614 installed with valid license
◼ Intel FPGA SDK for OpenCL Prime Edition 18.0.0.614 installed without license
◼ Intel SoC EDS 18.0.0.614 installed

DE10-Standard OpenCL 4 www.terasic.com


July 3, 2018
1.3 OpenCL Architecture

An OpenCL project consists of OpenCL Kernel and Host Program, as shown in Figure 1-2. The
Kernel is realized on the FPGA part of SoC FPGA. The Host Program is not the ARM part of the
SoC FPGA. It is cross-compiled by Intel SoC EDS installed on Windows or Linux. The Kernel is
developed in Quartus and OpenCL SDK is installed on Windows or Linux.

Figure 1-2 Intel SoC FPGA OpenCL architecture

DE10-Standard OpenCL 5 www.terasic.com


July 3, 2018
1.4 Execute OpenCL Demo on DE10-Standard

This section describes how to execute OpenCL demo on DE10-Standard from the Linux image file
included in DE10-Standard Board Support Package (BSP). Windows or Linux Host is required to
setup the demo.

◼ Using Windows Host PC

The following software should be installed on the Windows host PC to complete the setup.

⚫ Disk Imager - available from http://sourceforge.net/projects/win32diskimager


⚫ PuTTY- available from https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe
The procedures to execute the hello_world and vector_add demos are:
1. Download DE10-Standard BSP from http://de10-standard.terasic.com/cd and extract the
Linux image file de10_standard_opencl.img from de10_standard_opencl.zip
2. Write the Linux image file de10_standard_opencl.img into a microSD card with Disk
Imager Utility.
3. Insert the microSD card into the microSD card socket(J11).
4. Make sure the DIP switch (SW10) MSEL[4:0] = 01010.
5. Connect your host PC to the UART-to-USB port (J4) on DE10-Standard via an USB cable.
Users need to install the UART-to-USB device driver as described in the DE10-Standard
Getting Started Guide.
6. Launch PuTTY utility on your host PC. Make sure the baud rate is set to 115200.
7. Power on DE10-Standard to boot Linux. Login Linux with username ‘root’ (password is
not required).
8. Type “source ./init_opencl.sh” to load the OpenCL Linux kernel driver and setup
environment variable for OpenCL Run-Time library, which is already installed on the
microSD card.
9. Launch hello_world demo:
⚫ Type “cd terasic/hello_world/” to go to the hello_world folder.
⚫ Type “ls” to see the files in this folder.
⚫ Type “./host” to launch the hello_world host application, as shown in Figure 1-3.
10. Launch vector_add demo:
⚫ Type “cd ../vector_add/” to go to the vector_add folder.
⚫ Type “ls” to see the files in this folder.

DE10-Standard OpenCL 6 www.terasic.com


July 3, 2018
⚫ Type “./host” to launch the vector_add host application, as shown in Figure 1-4 .

Figure 1-3 Hello World Demo

DE10-Standard OpenCL 7 www.terasic.com


July 3, 2018
Figure 1-4 Vector Add Demo

◼ Using Linux Host PC with Root Privilege

The following software should be installed on the Linux host PC to complete the setup.
NOTE: Minicom – a terminal which can be installed via command “yum install minicom” or
“apt-get install minicom”
1. Download DE10-Standard BSP from http://de10-standard.terasic.com/cd and extract the
linux image file de10_standard_opencl.img from de10_standard_opencl.zip.
2. Write the Linux image file de10_standard_opencl.img into the microSD card with Disk
Imager.
⚫ Insert the microSD card into a card reader and connect it to the host PC. If the
microSD card already contains an image, existing partitions will be mounted
automatically. Please unmounts all the partitions.
⚫ Type dmesg|tail command to check which device name is assigned to the microSD
card. It’s likely to be /dev/sdb (change /dev/sdb to the device name found in the
previous step).
⚫ Run “sudo dd if=de10_standard_opencl.img of=/dev/sdb bs=1M”
⚫ Run “sync”
3. Insert the microSD card into the microSD card slot (J11) of DE10-Standard.
4. The DIP switch (SW10) on DE10-Standard for MSEL[4:0] must be set to 01010.
5. Connect the host PC to the UART-to-USB port (J4) on DE10-Standard with an USB cable.
Users should install the UART-to-USB device Linux driver as described in the FTDI driver

DE10-Standard OpenCL 8 www.terasic.com


July 3, 2018
download web page http://www.ftdichip.com/Drivers/VCP.html.
6. Launch Minicom utility (“minicom -s” for the configuration when it’s launched the first time)
on the host PC. The Serial Device should be set to /dev/ttyUSB0, Hardware Flow Control
set as NO. Modify the Modem and dialing: Set Init string, Reset string, Hang-up string to
blank. And baud rate should be set to 115200. Shutdown the hardware flow control.
7. Power on DE10-Standard to boot Linux and log in as root. There’s no password required.
8. Type “source ./init_opencl.sh” to load the OpenCL Linux kernel driver and setup environment
variables for OpenCL Run-Time Environment that is already installed on the microSD card.
9. Launch hello_world demo:
⚫ Type “cd terasic/hello_world/” to change the current directory to the hello_world
folder.
⚫ Type “ls” to see the files in this folder.
⚫ Type “./host” to launch the hello_world host application, as shown in Figure 1-5.
10. Launch vector_add demo:
⚫ Type “cd ../vector_add/” to change the directory to the vector_add folder.
⚫ Type “ls” to see the files in this folder.
⚫ Type “./host” to launch the vector_add host application, as shown in Figure 1-6.

DE10-Standard OpenCL 9 www.terasic.com


July 3, 2018
Figure 1-5 Hello World Demo

DE10-Standard OpenCL 10 www.terasic.com


July 3, 2018
Figure 1-6 Vector Add Demo

DE10-Standard OpenCL 11 www.terasic.com


July 3, 2018
Chapter 2
OpenCL on Windows

This chapter describes how to setup DE10-Standard OpenCL development environment in


Windows 64-bit and then build and execute OpenCL project on DE10-Standard. For more details
about getting started with Intel OpenCL for Cyclone V SoC, please refer to:

http://www.altera.com/literature/hb/opencl-sdk/aocl_c5soc_getting_started.pdf

2.1 Software Installation

This section describes how to install the software required for developing OpenCL project on
DE10-Standard.

◼ Install Intel Quartus Prime and OpenCL SDK

Intel Quartus Prime and OpenCL SDK are available from the website:

http:/fpgasoftware.intel.com/18.0/?edition=standard&platform=windows&download_manager=dlm
3

For Quartus Prime installation, please make sure the Cyclone V device package is selected.

◼ Install Intel SoC EDS

Intel SoC EDS tool is required to cross-compile the Host Program for ARM processor. The software
is available from the website:

http://fpgasoftware.intel.com/soceds/18.0/?edition=standard&platform=windows&download_mana
ger=dlm3

Please make sure the DS-5 is installed during the installation of SoC EDS.

DE10-Standard OpenCL 12 www.terasic.com


July 3, 2018
◼ Install DE10-Standard OpenCL Board Support Package (BSP)

After Quartus Prime and OpenCL SDK are installed, please create a new folder “terasic” under the
folder “G:\software\intelFPGA\18.0\hld\board”, assuming Intel Quartus Prime is installed under the
folder “G:\software\intelFPGA\18.0”. Please download the DE10-Standard BSP file
DE10-Standard_OpenCL_BSP.zip from

http://de10-standard.terasic.com/cd

Please uncompress the zip file and copy the “de10_standard” folder to the “terasic” folder created
previously, as shown in Figure 2-1.

Figure 2-1 Location of “G:\intelFPGA\18.0\hld\board\terasic” folder

2.2 License Installation

An Quartus license is required to compile OpenCL project. Users can purchase the license from
Intel. A file named “license.dat” will be given upon purchasing Quartus license. For license
installation, please place the file “license.dat” in the local disk drive “c:\” and create a Windows
environment variable LM_LICENSE_FILE with value “c:\license.dat”. The value of this
environment variable needs to match the actual location of “license.dat” file.

The procedures below show how to create the LM_LICENSE_FILE environment variable in
Windows 10:
1. Right click on Computer. Select Properties.
2. Select Advanced system settings.

DE10-Standard OpenCL 13 www.terasic.com


July 3, 2018
3. Select Environment Variables from the Advanced tab.
4. Select New.
5. In the New User Variable dialog shown in Figure 2-2, type “LM_LICENSE_FILE” in
the Variable name field. Then if you use a license file type “c:\license.dat” in the
Variable value field, else a floating license on a license server type “port number
@server IP address”.

Figure 2-2 Setup LM_LICENSE_FILE environment variable

2.3 OpenCL Environment Configuration

Please add the following paths into the User environment variables:

◼ OpenCL Configuration

For the operating system to find the OpenCL utilities correctly, users need to create a new
environment variable named INTELFPGAOCLSDKROOT and add the following paths into the
PATH environment variable:

1. %INTELFPGAOCLSDKROOT%\bin
2. %INTELFPGAOCLSDKROOT%\host\windows64\bin

Here are the procedures about how to do those on Windows 10:


1. Right click on Start Menu and select File Explorer.

DE10-Standard OpenCL 14 www.terasic.com


July 3, 2018
2. Right click on This PC and select Properties.
3. Select Advanced system settings.
4. Select Environment Variables from the Advanced tab.
5. Select New to New a User variable.
6. In the New User Variable dialog. Type INTELFPGAOCLSDKROOT in the Variable
name filed and type the path where your software installed in the Variable value filed, as
shown in Figure 2-3 . (If there is a variable named ALTERAOCLSDKROOT, please
delete it)

Figure 2-3 Add INTELFPGAOCLSDKROOT Environment Variable

7. Select PATH item in the Variable list and click the Edit button.
8. In the Edit User Variable dialog shown in Figure 2-4, add the following two strings into
the Value edit box. The strings should be separated by the symbol “;”.
⚫ %INTELFPGAOCLSDKROOT%\bin
⚫ %INTELFPGAOCLSDKROOT%\host\windows64\bin

Figure 2-4 Modify PATH Environment Variable

◼ DE10-Standard BSP Configuration

For Intel OpenCL SDK to find the kit location of DE10-Standard correctly, Users need to create an
environment variable AOCL_BOARD_PACKAGE_ROOT and set

DE10-Standard OpenCL 15 www.terasic.com


July 3, 2018
its value as:

“%INTELFPGAOCLSDKROOT%\board\terasic\de10_standard”

The procedures to create the required AOCL_BOARD_PACKAGE_ROOT environment variable


in Windows 10 are:
1. Right click on Start Menu and select File Explorer.
2. Right click on This PC and select Properties.
3. Select Advanced system settings.
4. Select Environment Variables from the Advanced tab.
5. Select New.
6. In the New User Variable dialog shown in Figure 2-5, type
“AOCL_BOARD_PACKAGE_ROOT” in the Variable name field and type
“%INTELFPGAOCLSDKROOT%\board\terasic\de10_standard” in the Variable
value field.

Figure 2-5 Setup AOCL_BOARD_PACKAGE_ROOT environment variable

2.4 OpenCL Environment Verification

This section shows how to confirm the OpenCL environment is setup correctly. Please open
Command Prompt window by clicking Windows Start button and click All Programs. Click
Accessories and then click Command Prompt.

◼ Verify Utility

Type “aocl version” command in the command prompt window and see if the version displayed
matches the number shown in Figure 2-6. If the ‘aocl’ command cannot be found, please check if
the “%INTELFPGAOCLSDKROOT%\bin” path is added to the PATH environment variable
correctly.
DE10-Standard OpenCL 16 www.terasic.com
July 3, 2018
Figure 2-6 Aocl version of Intel FPGA SDK for OpenCL in the command prompt

◼ Verify Target Board

Type “aoc -list-boards” command in the command prompt window and make sure
“de10_standard_sharedonly” is listed in the Board list, as shown in Figure 2-7. If “de10_standard
_sharedonly” is not listed, please check if the AOCL_BOARD_PACKAGE_ROOT environment
variable is assigned correctly.

Figure 2-7 ‘de10_standard_sharedonly’ is listed in the Board list

◼ How to Check Environment Variables

The value of environment variables can be retrieved by typing ‘echo’ in the command prompt
window. For example, type “echo %AOCL_BOARD_PACKAGE_ROOT%” can retrieve the value
of environment variable AOCL_BOARD_PACKAGE_ROOT, as shown in Figure 2-8.

Figure 2-8 The value of AOCL_BOARD_PACKAGE_ROOT environment variable

2.5 Compile and Execute OpenCL Project

This section shows how to compile and execute OpenCL kernel and OpenCL Host Program
provided in the DE10-Standard BSP. Users can follow the same procedures to compile and execute

DE10-Standard OpenCL 17 www.terasic.com


July 3, 2018
other OpenCL examples for DE10-Standard.

◼ Compile OpenCL Kernel

The utility aoc (Intel SDK for OpenCL Kernel Compiler) is used to compile OpenCL kernel. Type
“cd G:\intelFPGA\18.0\hld\board\terasic\de10_standard\test\boardtest” in the command prompt
window to change the current directory to the folder boardtest and then type:

“aoc boardtest.cl -o bin\boardtest.aocx -board=de10_standard_sharedonly -v -report”

to compile the OpenCL kernel. It will take approximately half an hour to complete the compilation.
When the compilation process is complete, an OpenCL image file boardtest.aocx is generated
under the bin folder. Figure 2-9 shows the OpenCL kernel is compiling. For more details about the
usage of aoc, please refer to the Intel SDK for OpenCL Programming Guide:
http://www.altera.com/literature/hb/opencl-sdk/aocl_programming_guide.pdf

Figure 2-9 Screenshot of OpenCL kernel is compiling

DE10-Standard OpenCL 18 www.terasic.com


July 3, 2018
◼ Compile Host Program

The Host Program is compiled in Intel SoC EDS. Please launch embedded command shell by
executing the “Embedded_Command_Shell.bat”, as shown in Figure 2-10, under the folder
“G:\intelFPGA\18.0\embedded”, assuming Intel SoC EDS is installed under the directory
“G:\intelFPGA\18.0”

Figure 2-10 Location of Embedded_Command_Shell.bat

Type the following in the command shell:

“cd /cygdrive/G/intelFPGA/18.0/hld/board/terasic/de10_standard/test/boardtest/”

to change the current directory to the folder where the boardtest project is located. Type “make” to
build the host project shown in Figure 2-11. If the compilation is successful, a binary file
boardtest_host will be generated under the boardtest folder.

DE10-Standard OpenCL 19 www.terasic.com


July 3, 2018
Figure 2-11 Type ‘make’ to build the boardtest host project

◼ Execute BoardTest Project

Please boot DE10-Standard with the Linux image generated from Chapter 1.4 for DE10-Standard
OpenCL. Users need to copy both the kernel file boardtest.aocx and host file boardtest_host
generated from the previous section from the host PC to Linux running on DE10-Standard. Users
can copy the file by typing Linux “scp” command through Ethernet or USB storage.

After these two files are copied to Linux running on DE10-Standard, please go to the terminal and
type “source ./init_opencl.sh” to setup OpneCL environment. Type “chmod +x boardtest_host” to
add execution attribute to the host file. Type “./boardtest_host” to launch the host application, as
shown in Figure 2-12.

DE10-Standard OpenCL 20 www.terasic.com


July 3, 2018
Figure 2-12 BoardTest host is executed successfully

DE10-Standard OpenCL 21 www.terasic.com


July 3, 2018
Chapter 3
OpenCL on Linux

This chapter describes how to setup the environment for the development of OpenCL on Linux,
build OpenCL project including kernel and host application, followed by execution and verification
of OpenCL project.

For more details about OpenCL on Linux, please refer to the Getting Started Guild of Intel OpenCL
Cyclone V SoC:

http://www.altera.com/literature/hb/opencl-sdk/aocl_c5soc_getting_started.pdf

3.1 Software Installation

This section describes where to download and how to install the software required for OpenCL on
DE10-Standard.

◼ Download Intel Quartus Prime and OpenCL SDK

Intel Quartus Prime and OpenCL SDK are available from the website of Intel PSG:

http://fpgasoftware.intel.com/opencl/18.0/?edition=standard&download_manager=dlm3

Follow the link and select Linux operation system with version 18.0, as shown in Figure 3-1.

DE10-Standard OpenCL 22 www.terasic.com


July 3, 2018
Figure 3-1 Download the Linux version of OpenCL SDK v18.0 from the website of Intel PSG

Choose Direct Download as the download method since the download manager is for Windows only.
Click the arrow to download Intel FPGA Design Software, as shown in Figure 3-2., and make sure
the Cyclone V device is included. Users can download Intel SDK for OpenCL as standalone
installer or RPM package.

Figure 3-2 Download Intel OpenCL SDK Linux version with Cyclone V device support

DE10-Standard OpenCL 23 www.terasic.com


July 3, 2018
◼ Install Intel SoC EDS

Intel SoC EDS tool is required to cross-compile the host program for ARM processor. The software
is available from the website:

http://fpgasoftware.intel.com/soceds/18.0/?edition=standard&platform=linux&download_manager=
direct

Please make sure DS-5 is installed during the installation of SoC EDS.

◼ Install DE10-Standard OpenCL Board Support Package (BSP)

After Quartus Prime and OpenCL SDK are installed, please create a new folder named as the terasic
to the Intel OpenCL SDK folder “/root/intelFPGA/18.0/hld/board/”, refer to your own path, and
uncompressing the OpenCL BSP to this folder. as shown in Figure 3-3.

Figure 3-3 Copy the terasic folder to the /root/intelFPGA/18.0/hld/bolard folder

3.2 OpenCL License Installation

A license for Quartus is required to compile OpenCL project. Users can purchase the license from
Intel. After users have obtained a license file named “license.dat”, it needs to be placed in the local
disk such as “/root/intelFPGA/18.0/hld/license.dat”. Users also need to create an environment
variable LM_LICENSE_FILE and set its value as “/root/intelFPGA/18.0/hld/license.dat”, which
corresponds to the actual location of the license file. If you use a floating license on a license server,

DE10-Standard OpenCL 24 www.terasic.com


July 3, 2018
please set its value as “port number@server IP address”

The next section will describe how to setup the license environment.

3.3 Configuration of Environment Variables

If users install the Intel FPGA development software and OpenCL SDK on a system that does not
contain any .cshrc or bash resource file (.bashrc) in the directory, the INTELFPGAOCLSDKROOT
and PATH environment variables must be set manually. Users also need to create an environment
variable AOCL_BOARD_PACKAGE_ROOT for Intel OpenCL SDK to find the kit location of
DE10-Standard correctly. The value of this environment variable needs to be set as:

“$INTELFPGAOCLSDKROOT/board/terasic/de10_standard”

Alternatively, users can edit the “/etc/profile”, and append the environment variables to it. It can be
done by typing “gedit /etc/profile” command in the terminal to open the profile file with the gedit
editor tool and append the following settings to the profile file. After the edit is complete, save the
file and type “source /etc/profile” command in the terminal to apply the settings.

export QUARTUS_ROOTDIR=/root/intelFPGA/18.0/quartus
export INTELFPGAOCLSDKROOT=/root/intelFPGA/18.0/hld
export
PATH=$PATH:$QUARTUS_ROOTDIR/bin:/root/intelFPGA/18.0/embedded/ds-5/bin:/root/intelFPGA/18.0/embedd
ed/ds-5/sw/gcc/bin:$INTELFPGAOCLSDKROOT/bin:$INTELFPGAOCLSDKROOT/arm32/bin
export LD_LIBRARY_PATH=$INTELFPGAOCLSDKROOT/arm32/lib
export AOCL_BOARD_PACKAGE_ROOT=$INTELFPGAOCLSDKROOT/board/terasic/de10_standard
export QUARTUS_64BIT=1
export LM_LICENSE_FILE=/root/intelFPGA/18.0/hld/license.dat

3.4 Verification of OpenCL Environment

This section shows how to make sure the OpenCL environment is setup correctly. Please open the
terminal window in Linux.

◼ Verify Utility

DE10-Standard OpenCL 25 www.terasic.com


July 3, 2018
Type “aocl version” command in the terminal and make sure the aocl version reported matches the
information shown in Figure 3-4. If the ‘aocl’ command cannot be found, please check if the
“$INTELFPGAOCLSDKROOT/bin” path is added to the PATH environment variable correctly.

Figure 3-4 The information about aocl version

◼ Verify Target Board

Type “aoc -list-boards” command in the terminal and make sure “de10_standard_sharedonly” is
displayed in the Board list, as shown in Figure 3-5. If “de10_standard_sharedonly” is not listed,
please check if the AOCL_BOARD_PACKAGE_ROOT environment variable is assigned
correctly.

Figure 3-5 ‘de10_standard_sharedonly’ is shown in the Board list

◼ Check Environment Variables

The values of environment variables can be retrieved by typing ‘echo’ command in the terminal.
For example, type “echo $AOCL_BOARD_PACKAGE_ROOT” can dump the value of
environment variable AOCL_BOARD_PACKAGE_ROOT, as shown in Figure 3-6.

Figure 3-6 Check the environment variable AOCL_BOARD_PACKAGE_ROOT

DE10-Standard OpenCL 26 www.terasic.com


July 3, 2018
3.5 Build and Execute OpenCL Project

This section shows how to compile and test OpenCL example project and OpenCL host program
provided in DE10-Standard BSP. Users can follow the same procedures to compile and test other
OpenCL projects for DE10-Standard.

◼ Compile OpenCL Kernel

The utility aoc (Intel SDK for OpenCL Kernel Compiler) is used to compile OpenCL kernel. Type
“cd /root/intelFPGA/18.1/hld/board/terasic/de10_standard/test/boardtest” in the terminal to change
the current directory to the boardtest project folder. Type

“aoc boardtest.cl -o bin/boardtest.aocx -board=de10_standard_sharedonly -v -report”

to compile the OpenCL kernel. The compilation process will take about one hour. When the
compilation process is complete, an OpenCL image file boardtest.aocx is generated under the bin
folder. Figure 3-7 shows the screenshot after the OpenCL kernel is compiled successfully. For more
information about the usage of aoc, please refer to the Intel SDK for OpenCL Programming
Guide:
http://www.altera.com/literature/hb/opencl-sdk/aocl_programming_guide.pdf

DE10-Standard OpenCL 27 www.terasic.com


July 3, 2018
Figure 3-7 OpenCL kernel is compiled successfully

◼ Compile Host Program

Intel SoC EDS is used to compile the host program. Please launch the embedded command shell by
executing the “Embedded_Command_Shell.sh”, as shown in Figure 3-8, under the folder
“/root/intelFPGA/18.0/embedded”, assuming Intel SoC EDS is installed under the directory
“/root/intelFPGA/18.0/”.

DE10-Standard OpenCL 28 www.terasic.com


July 3, 2018
Figure 3-8 Location of Embedded_Command_Shell.sh

In the command shell, please type:

“cd /root/intelFPGA/18.0/hld/board/terasic/de10_standard/test/boardtest”

and the current directory will be changed to the folder where the boardtest project is located. Type
“make” to build the host project, as shown in Figure 3-9. If the host project is compiled successfully,
a host binary file boardtest_host will be generated under the boardtest folder.

Figure 3-9 Type ‘make’ to build the boardtest host project

DE10-Standard OpenCL 29 www.terasic.com


July 3, 2018
◼ Test Boardtest project

Please boot DE10-Standard with the Linux image for DE10-Standard OpenCL described in Chapter
1.4. Users need to copy the generated kernel file boardtest.aocx and the host file boardtest_host
from the host PC to the Linux system running on DE10-Standard. This can be done by establishing
SSH connection via Ethernet with “scp” command or via usb-storage with “mount” command.

After these two files are copied to the Linux system running on DE10-Standard, please add
executable attribution with “chmod +x boardtest_host” command and type “source ./init_opencl.sh”
to setup OpneCL environment, then type “./boardtest_host” to launch the host application as shown
in Figure 3-10.

Figure 3-10 Test BoardTest project

DE10-Standard OpenCL 30 www.terasic.com


July 3, 2018
Revision History
Version Change Log
V2.0 Modify content for OpenCL 18.0
V1.0 Initial Version

Copyright Statement

Copyright © 2018 Terasic Inc. All Rights Reserved.

DE10-Standard OpenCL 31 www.terasic.com


July 3, 2018

You might also like