Install (Intel) Altera Quartus 16.0.2 OpenCL on Ubuntu 14.04 Linux

quartusTo temporarily increase capacity we put Quartus 16.0.2 on an Ubuntu server, which did not go smooth – but at least smoother than upgrading packages to required versions on RedHat/CentOS. While the download says “Linux” and you’re expecting support for multiple Linux breeds, there is only official support for Redhat 6.5 (and CentOS).

Luckily it was very possible to have a stable installation of Quartus on Ubuntu. As information on this subject was squattered around the net and even incomplete, we decided to share our howto in this blogpost. These tips probably also work for other modern Linux-based operating systems like Fedora, Suse, Arch, etc, as most problems are due to new features and more up-to-date libraries than are provided in RedHat/CentOS.

Note1 : we did not install the FPGA on the Ubuntu-machine and neither fully researched potential problems for doing so – installing the FPGA on an Ubuntu machine is at your own risk. Have your board maker follow this tutorial to test their libraries on Ubuntu.

Note 2: we tested on Ubuntu 14.04. No guarantees if it all works on other version. Let us know in the comments if it works on other versions too.

What is Quartus?

Quartus is the compiler suite of Altera, which includes development tools, IDE, FPGA-management and more.

Here at StreamHPC we work at various devices that have OpenCL support. You’ve read most about GPUs and CPUs on our blog, even the XeonPhi. But we also work with Altera FPGAs, mostly to design software that doesn’t interact with global memory (between 0.2μs and 2μs), that are too complex for VHDL and Verilog. We have proved several times that designs in OpenCL have much lower maintenance and development costs. Especially when time-to-market is important, OpenCL is the best choice – design-times in OpenCL are a matter of weeks, where VHDL/Verilog would take months.

The latest version of Quartus is 16.0.2 and many board-makers are (soon) supporting this version. The advantages of Quartus 16 for OpenCL are faster compile times and multiple new features – enough reason to update.

Hardware requirements

The minimum memory to work well on Arria 10 projects is 45GB DDR and a minimum of 32GB virtual memory. I did not experiment myself, but I see that others claimed better results with 32+32 than with 64+0.

You need 4 (real) cores to get compilations done at full speed – extra cores have no influence at all. Spend your moneys on more and faster memory and a faster SSD. Understand compilation takes hours, so you easily notice a difference when your CPU/DDR4/SSD is faster.

Getting Quartus installed

Our server is headless and that was not the easiest way to install Quartus, as the installer from the command line has some problems. Better to use the GUI version, so make sure DISPLAY is exported correctly when logging in via ssh.

There are 6 steps: downloading, installing, initialising the environment, fixing libaries, getting the license and getting the license to work. If you follow the steps correctly (and have a fast internet connection), you can get it all done in 2 hours.

Downloads

Be prepared to download almost 30GB of software. If you have multiple instances, you can simply sync directories. There are two locations to download Quartus from: the default Quartus download and the OpenCL download. Be sure you pick the OpenCL download! There are two steps: the 16.0.0 and then the 16.0.2 update.

  • 16.0.0 is under tab “Linux” and is labelled “Altera SDK for OpenCL (includes Quartus Prime software and devices)”. This is 20.4 GB
  • 16.0.2 is two downloads: “Quartus Prime Software v16.0 Update 2” and “Altera SDK for OpenCL v16.0 Update 2”, totaling 6.6 GB.

Installing

First you need to unpack the AOCL-16.0.0.211-linux.tar. Then run the install.sh file (or the install_pro.sh for the pro version – see the remarks under ‘License’ below). Install is defaulting to ~/altera for a local installation.

Before continuing, best is to initialise first (see below) and test the installation:

aoc –version

aocl version

These commands should give give 16.0.0 among some more info and throw no errors. We need the initialisation for the update-scripts to work better.

Now update Quartus with QuartusSetup-16.0.2.222-linux.run. When using the non-GUI version (happens when ssh is not exporting the GUI), understand there are still some problems – better to use the GUI. You might need to provide the directory, so know /home/yourusername/altera/16.0 by heart.

The last step is to update the OpenCL SDK with AOCLSetup-16.0.2.222-linux.run. If you end up in a loop that the installer ask to uninstall the previous version in altera/16.0 for you, choose an empty directory. when finished copy all files over the ones in /home/yourusername/altera/16.0.

Try to get the versions again – this should be 16.0.2 now.

Now copy the 16.0.2 board files from your board to /home/yourusername/altera/16.0/hld/board/boardname. The board_env.xml should be in the root of that directory. You need to put in the directory later in FPGA_BOARD. Further instructions are provided by your board vendor.

Initialising

This is our init-script, based on Altera’s default initialisation-scripts – your board-vendor might need some extra variables.. There are no changes for Ubuntu and it should work with any board – just change the variable FPGA_BOARD.

[raw]# Make sure the script is being source'd, not executed.
# Otherwise, environment variables set here will not stick.
if [ ${BASH_SOURCE[0]} == "$0" ]; then
 echo "Proper usage: source `basename \"$0\"`"
 exit 1
fi

## Quartus version selection
export QVERSION="16.0"

## BSP selection
#export FPGA_BOARD="attila_board"
export FPGA_BOARD="Proc10A"


# do not edit below this line
###########################################################

## Environment settings
export ALTERA_ROOT_DIR="$HOME/altera/$QVERSION"
export ALTERAOCLSDKROOT="$HOME/altera/$QVERSION/hld"
export LM_LICENSE_FILE="$HOME/altera/license.dat"
export QSYS_ROOTDIR="$HOME/altera/$QVERSION/quartus/sopc_builder/bin"

export PATH="$ALTERAOCLSDKROOT/bin:$PATH"
export PATH="$ALTERA_ROOT_DIR/quartus/bin:$PATH"

## checks

if [ "$ALTERAOCLSDKROOT" == "" ]; then
 echo "Error: ALTERAOCLSDKROOT is not set!"
 return 1
fi
if [ ! -d $ALTERAOCLSDKROOT ]; then
 echo "Error: ALTERAOCLSDKROOT is set but is not a directory!"
 return 1
fi

export AOCL_BOARD_PACKAGE_ROOT="$ALTERAOCLSDKROOT/board/$FPGA_BOARD"

## OpenCL SDK

export PATH="$ALTERAOCLSDKROOT:$ALTERAOCLSDKROOT/bin:$ALTERAOCLSDKROOT/
host/linux64/bin:$ALTERAOCLSDKROOT/host/linux64/lib:$AOCL_BOARD_PACKAGE_ROOT/linux64/bin:$AOCL_BOARD_PACKAGE_ROOT/linux64/libexec:$PATH"

#export ACL_PCIE_USE_JTAG_PROGRAMMING=1
#export ACL_PCIE_USE_JTAG_PROGRAMMING=0
#export ACL_HAL_DEBUG=5
#export ACL_PCIE_DEBUG=9

#next line will prevent host program to program the FPGA (see ref platform document page 28)
#export CL_CONTEXT_COMPILER_MODE_ALTERA=3

#export ACL_QSH_COMPILE_CMD="quartus_sh -t base_compile.tcl"
export ACL_QSH_COMPILE_CMD="quartus_sh -t import_compile.tcl"
# Detect the operating environment
# The same code as in aocl
ARCH=$AOCL_ARCH_OVERRIDE
if [ -z "$ARCH" ]; then
 ARCH=`uname -m`
fi
arch_type=
case $ARCH in
 x86_64)
 arch_type=linux64
 arch_type_name="Linux x86-64"
 ;;
 armv7l)
 arch_type=arm32
 arch_type_name="Linux SoC"
 ;;
 ppc64)
 arch_type=ppc64
 arch_type_name="Linux Power"
 ;;
 ppc64le)
 arch_type=ppc64le
 arch_type_name="Linux Power Little Endian"
 ;;
 *)
 echo "The '$ARCH' environment is not supported by the Altera SDK for OpenCL"
 exit 1;
 ;;
esac

# Add to path if not already there
pathadd() {
 echo "Adding $1 to PATH"
 if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
 export PATH="$1:$PATH"
 fi
}
# Add to ld_library _path if not already there
ldpathadd() {
 echo "Adding $1 to LD_LIBRARY_PATH"
 if [ -d "$1" ]; then
 if [[ ":$LD_LIBRARY_PATH:" != *":$1:"* ]]; then
 # For non-empty, only add if not already there
 export LD_LIBRARY_PATH="$1:$LD_LIBRARY_PATH"
 fi
 fi
}

if [ "$AOCL_BOARD_PACKAGE_ROOT" != "" ]; then
 echo "AOCL_BOARD_PACKAGE_ROOT is set to $AOCL_BOARD_PACKAGE_ROOT. Using that."
else
 echo "AOCL_BOARD_PACKAGE_ROOT path is not set in environment."
 echo "Setting to default s5_ref board."
 echo "If you want to target another board, do "
 echo " export AOCL_BOARD_PACKAGE_ROOT="
 echo "and re-run this script"
 export AOCL_BOARD_PACKAGE_ROOT="$ALTERAOCLSDKROOT/board/s5_ref"
fi

pathadd "$ALTERAOCLSDKROOT/bin"
ldpathadd "$ALTERAOCLSDKROOT/host/$arch_type/lib"
ldpathadd "$AOCL_BOARD_PACKAGE_ROOT/$arch_type/lib"

[/raw]

Save it as “init_16.0_boardname.sh” and use “source init_16.0_boardname.sh” to initialise your board. By sourcing it, the exported variables will remain after the script has finished.

Fixing Library problems

There are two things needed to fix problematic warnings (and even crashes). First is to use the libraries in quartus/linux64 and second not to use all of them.

You need to put the library directoy in LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=~/altera/16.0/quartus/linux64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

By setting it in a script (and not sourcing it), it is only temporary and will not obstruct other code compilations.

Some libraries are better not to be used, and be replaced by the installed versions. The below libraries are mentioned on several forums.

mv crashreporter crashreporter_backup
mv crashreporter.dep crashreporter.dep_backup
mv libcurl.so.4 libcurl.so.4_backup
mv libccl_curl_drl.so libccl_curl_drl.so_backup
mv libssl.so.1.0.0 libssl.so.1.0.0_backup
mv libcrypto.so.1.0.0 libcrypto.so.1.0.0_backup

You then need to make sure the libraries exist on your installation:

sudo apt install libcrypto++9 libssl-dev libcurl3

If you’ve gotten warnings like “Inconsistency detected by ld.so: dl-close.c: 762: _dl_close: Assertion `map->l_init_called’ failed!” and crashes, this will solve it. If you still got problems with crashing, make sure you have enough memory.

Bonus fix: when you run the compiler from ssh, be sure to unset DISPLAY to avoid Quartus crashing when there is no X-server present.

Licenses

Assuming you work on Arria 10, you need the Standard or Pro edition, as Lite doesn’t have OpenCL support for OpenCL on Arria 10. In most cases the standard edition is what you need. For OpenCL you need a separate license.

The costs are very dependent on the FPGA you bought. Be sure to ask a quote for the FPGA with a license of Quartus with OpenCL, when ordering your FPGAs.

A license is bound to the MAC-address. Easiest is to run Quartus to find the MAC-names. Simply type “quartus” (graphical program) and choose that you manually want to select the location of the license file. At the bottom of the new window you find the MACs that – there you can also request a 30-day license. If no MACs are shown, you probably have no “eth0” or “wlan0” – read on.

quartus-license

When you receive the license file, it needs to be placed in /home/yourusername/altera/ and renamed to license.dat. It should also work with Quartus 15, so can use your current license when 15 was already installed. Run quartus again to see if it worked, and/or run aoc -v empty_file.cl to see if the OpenCL license is active.

Network interface names

License files work with MAC addresses from network interfaces that are in use – this can also be wifi! To be sure all is working the software needs standard names, such as “eth0” and “wlan0”. Since a year “Predictable Network interface Names” are used in distributions like Ubuntu and Fedora, which doesn’t work with Quartus. So we need to set it back to the old names. The below is what worked at our server, but know there are several other options – be sure to do your research when using this guide to get Quartus working on another Linux distribution.

There are two steps for Ubuntu. First we need to edit the file /etc/default/grub and change the following line:

GRUB_CMDLINE_LINUX=”net.ifnames=0 biosdevname=0″

To make sure the changes are applied, run update-grub.

Second we need to edit /etc/network/interfaces. There the bios-name is still mentioned and need to set it to eth0, so query-replace coolname by eth.

# The primary network interface
auto coolname eth0
iface coolname eth0 inet dhcp

Now reboot and you should have eth0. Be sure not to try this from ssh if not having a backup login method, as you’ll loose your connection with any small mistake.

Want (to know) more?

We’d love to help you out on your first OpenCL project on Altera FPGAs. We can get your project ported to the FPGA, so you can learn by example. Also keep an eye on SC16 and our trainings.

Related Posts

FIA_F1_Austria_2018_Nr._33_Verstappen

The Art of Benchmarking

How fast is your software? The simpler the software setup, the easier to answer this question. The more complex the software, the more the answer will ...

5yearsSC

Birthday present! Free 1-day Online GPGPU crash course: CUDA / HIP / OpenCL

...  goal is hands on. We'll provide templates for CUDA/HIP and OpenCL, where you focus on making the core compute part. The third goal ...

network-of-boxes

Problem solving tactic: making black boxes smaller

We are a problem solving company first, specialised in HPC - building software close to the processor. The more projects we finish, the more it's clea ...

stocks

Improving FinanceBench

...  QuantLib is a C++ library. Unfortunately, languages like OpenCL, CUDA, and OpenACC cannot directly operate on C++ data structures, ...