3. Compile OmpSs@FPGA programs¶
To compile an OmpSs@FPGA program you should follow the general OmpSs compilation procedure using the Mercurium compiler. More information is provided in the OmpSs User Guide (https://pm.bsc.es/ftp/ompss/doc/user-guide/compile-programs.html). The following sections detail the specific options of Mercurium to generate the binaries, bitstream and boot files.
The entire list of Mercurium options (for the FPGA phase) and AIT arguments are available here:
3.3. Binaries¶
- There are two specific Mercurim front-ends for the FPGA devices:
fpgacxx
for C++ applications.fpgacc
for C applications.
3.4. Bitstream¶
Note
Mercurium expects the Accelerator Integration Tool (AIT, formerly autoVivado) to be available on the PATH, if not the linker will fail. Moreover, AIT expects VivadoHLS and Vivado to be available in the PATH.
Warning
Sourcing the Vivado settings.sh
file may break the
cross-compilation toolchain. Instead, just add the directory of vivado binaries
in the PATH.
To generate the bitstream, you should enable the bitstream generation in the
Mercurium compiler (using the –bitstream-generation flag) and provide it the
FPGA linker (aka AIT) flags with --Wf
option.
If the FPGA linker flags does not contain the -b
(or --board
) and -n
(or --name
) options, Mercurim will not launch AIT.
For example, to compile the dotproduct application, in debug mode, for the Zedboard, with a target frequency of 100Mhz, you can use the following command:
arm-linux-gnueabihf-fpgacc --debug --ompss --bitstream-generation \
src/dotproduct.c -o dotproduct-d \
--Wf,"--board=zedboard,--clock=100,--name=dotproduct,--hwruntime=som"
3.4.1. HW Instrumentation¶
You can use the --instrument
(or --instrumentation
) option of Merciurim to
enable the HW instrumentation generation.
The instrumentation can be generated and not used when running the application,
but if you generate the bitstream without instrumentation support you will not be
able to instrument the executions in the FPGA accelerators.
Note that the application binary also has to be compiled with the --instrument
(or --instrumentation
) option.
For example, the previous compilation command with the instrumentation available will be:
arm-linux-gnueabihf-fpgacc --instrument --ompss --bitstream-generation \
src/dotproduct.c -o dotproduct-d \
--Wf,"--board=zedboard,--clock=100,--name=dotproduct,--hwruntime=som"
3.5. Boot Files¶
Some boards do not support loading the bitstream into the FPGA after the boot, therefore the boot files should be updated and the board rebooted. This step is not needed for the z7000 family of devices as the bitstream can be loaded after boot. AIT supports the generation of boot files for some boards but the step is disabled by default and should be enabled by hand.
- First, you need to set the following environment variables:
PETALINUX_INSTALL
. Petalinux installation directory.PETALINUX_BUILD
. Petalinux project directory. See Create boot files for ultrascale to have more information about how to setup a petalinux project build.
Then you can invoke AIT with the same options provided in --Wf
and
the following new options: --from_step=boot --to_step=boot
. Also, you may
directly add the --to_step=boot
option in --Wf
during the Mercurium
launch.