Goal Run an OpenCL program on Xilinx FPGA
Approach Using SDAccel to compile and NIMBIX Cloud to run the program
Benefits Understand the design flow in Xilinx SDAccel and NIMBIX cloud
Credit This work has been done under the ENPOWER project (funded by EPSRC) at University of Bristol .

Compiling and running an OpenCL application on the Xilinx FPGA consists of four steps.

Step 1: Describing the application

The OpenCL standard can be used to describe an application for the Xilinx FPGA. However, Xilinx specific pragmas and coding styles should be used for optimising the application for the Xilinx FPGAs. A brief explanation of these techniques is described in the SDAccel documents ‎[1]‎[2].

Example:  Let’s consider the vector addition as an example. The kernel corresponding to this example is as follows:

Describing the kernel:

The complete code including the host code can be found at here.

[code language=”c”]
__kernel void __attribute__ ((reqd_work_group_size(2048, 1, 1)))
vector_addition(__global float* arrayA, __global float* arrayB, __global float* arrayC) {
int globalIndex = get_global_id(0);
arrayC[globalIndex] = arrayA[globalIndex] + arrayB[globalIndex];

Step 2: Writing the tcl file

The next step is providing a tcl scaript file for compiling the OpenCL code.

This is an example of this file:

[code language=”c”]
create_solution -name mx_ad_solution -force
add_device -vbnv "xilinx:adm-pcie-7v3:1ddr:2.1"
set_property -name host_cflags -value {-Wall -D FPGA_DEVICE} -objects [ current_solution ]

add_files vector_addition.cpp vector_addition.h xcl.c xcl.h
create_opencl_binary vector_add
set_property region "OCL_REGION_0" [ get_opencl_binary vector_add ]

create_kernel "vector_addition" -type "clc"
add_files -kernel [ get_kernels vector_addition ] vector_addition.cl

create_compute_unit -opencl_binary [ get_opencl_binary vector_add ] -kernel [ get_kernels "vector_addition" ] -name "k1_1"


Step 3: Compile the program running sdaccel run.tcl command

Step 4: Transfer pkg directory to the NIMBIX data folder using sftp (look at the help in https://www.nimbix.net/jarvice-quick-start-guide/)

Note, in case of using Windows sftp clients the transfer exe files may not be executable. To solve this right clock on the exe file and select “File Permission” and make that executable

Step 4: Go to the NIMBOX site the run the “Xilinx Runtime” app


  • Choose the proper FPGA board and your executable file and add its argument and submit your command


  • After a few second the output would be available



[1] Xilinx, “SDAccel Development Environment User Guide, Features and Development Flows” UG1023 (2015.4) February 16, 2016.

[2] Xilinx, “SDAccel Development Environment Methodology Guide Performance Optimization,” UG1207 (v2.0) August 31, 2016.

Leave a Reply