We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Showing results for 
Search instead for 
Did you mean: 
Visitor ivars211
Registered: ‎11-25-2018

System run not working

Hello, I am having issues getting SDAccel 2018.3 to work. I have setup my vcu1525 successfully:

INFO: Found 1 cards

INFO: Validating card[0]: xilinx_vcu1525_xdma_201830_1
INFO: Checking PCIE link status: PASSED
INFO: Starting verify kernel test: 
INFO: verify kernel test PASSED
INFO: Starting DMA test
Host -> PCIe -> FPGA write bandwidth = 9599.25 MB/s
Host <- PCIe <- FPGA read bandwidth = 8783.1 MB/s
INFO: Starting DDR bandwidth test: ..........
Maximum throughput: 47335.406250 MB/s
INFO: DDR bandwidth test PASSED
INFO: Card[0] validated successfully.

However, when I run the vector add example project on system I get the following:

Found Platform
Platform Name: Xilinx
XCLBIN File Name: krnl_vadd

<terminated> (exit value: -1) test-Default [OpenCL] test.exe

 I can successfully software emulate it though.

Any ideas what am I doing wrong?

0 Kudos
6 Replies
Xilinx Employee
Xilinx Employee
Registered: ‎01-11-2011

Re: System run not working

Hi @ivars211, is this design from the SDx GUI example, or is this from the SDAccel GitHub examples? Also, you mentioned that sw_emu worked, does hw_emu also show a working result?

Please don’t forget to reply, kudo, and accept as solution!
Visitor ivars211
Registered: ‎11-25-2018

Re: System run not working

Thanks for your reply.

Yes, Hardware emulation also works.

I downloaded examples from within SDAccel (it's under Miscellaneous Examples - Vector Addition)


This is the host code:

#include "xcl2.hpp"
#include <vector>
#include "vadd.h"

int main(int argc, char* argv[]) {
    cl_int err;
    size_t vector_size_bytes = sizeof(int) * LENGTH;
    std::vector<int,aligned_allocator<int>> source_a   (LENGTH);
    std::vector<int,aligned_allocator<int>> source_b   (LENGTH);
    std::vector<int,aligned_allocator<int>> result_sim (LENGTH);
    std::vector<int,aligned_allocator<int>> result_krnl (LENGTH);

    /* Create the test data and run the vector addition locally */
    for(int i=0; i < LENGTH; i++){
        source_a[i] = i;
        source_b[i] = 2*i;
        result_sim[i] = source_a[i] + source_b[i];

    std::vector<cl::Device> devices = xcl::get_xil_devices();
    cl::Device device = devices[0];

    OCL_CHECK(err, cl::Context context(device, NULL, NULL, NULL, &err));
    OCL_CHECK(err, cl::CommandQueue q(context, device, CL_QUEUE_PROFILING_ENABLE, &err));
    std::string device_name = device.getInfo<CL_DEVICE_NAME>(); 

    std::string binaryFile = xcl::find_binary_file(device_name,"krnl_vadd");
    cl::Program::Binaries bins = xcl::import_binary_file(binaryFile);
    OCL_CHECK(err, cl::Program program(context, devices, bins, NULL, &err));
    OCL_CHECK(err, cl::Kernel krnl(program,"krnl_vadd", &err));

    std::vector<cl::Memory> inBufVec, outBufVec;
    OCL_CHECK(err, cl::Buffer buffer_a(context,CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY, 
            vector_size_bytes, source_a.data(), &err));
    OCL_CHECK(err, cl::Buffer buffer_b(context,CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY, 
            vector_size_bytes, source_b.data(), &err));
    OCL_CHECK(err, cl::Buffer buffer_c(context,CL_MEM_USE_HOST_PTR | CL_MEM_WRITE_ONLY, 
            vector_size_bytes, result_krnl.data(), &err));

    /* Copy input vectors to memory */
    OCL_CHECK(err, err = q.enqueueMigrateMemObjects(inBufVec,0/* 0 means from host*/));

    /* Set the kernel arguments */
    int vector_length = LENGTH;
    OCL_CHECK(err, err = krnl.setArg(0, buffer_a));
    OCL_CHECK(err, krnl.setArg(1, buffer_b));
    OCL_CHECK(err, krnl.setArg(2, buffer_c));
    OCL_CHECK(err, krnl.setArg(3, vector_length));

    /* Launch the kernel */
    OCL_CHECK(err, err = q.enqueueTask(krnl));

     /* Copy result to local buffer */
    OCL_CHECK(err, err = q.enqueueMigrateMemObjects(outBufVec,CL_MIGRATE_MEM_OBJECT_HOST));
    OCL_CHECK(err, err = q.finish());

    /* Compare the results of the kernel to the simulation */
    int krnl_match = 0;
    for(int i = 0; i < LENGTH; i++){
        if(result_sim[i] != result_krnl[i]){
            printf("Error: Result mismatch\n");
            printf("i = %d CPU result = %d Krnl Result = %d\n", i, result_sim[i], result_krnl[i]);
            krnl_match = 1;
        } else{
            printf("Result Match: i = %d CPU result = %d Krnl Result = %d\n", i, result_sim[i], result_krnl[i]);

    std::cout << "TEST " << (krnl_match ? "FAILED" : "PASSED") << std::endl; 
    return (krnl_match ? EXIT_FAILURE :  EXIT_SUCCESS);


0 Kudos
Visitor ivars211
Registered: ‎11-25-2018

Re: System run not working

After compiling multiple examples, I got one to pass the hardware run:

Hello World (OCL)  with xcl - passed

Hello World (OCL)  - failed

Hello World (HLS C/C++ Kernel) - failed

Vector Addition - Miscellaneous Examples - failed

Random nubmer generator - failed

All fail with the same error.

Is there any reason why example with the xcl.cpp & xcl.h included run successfully? 

0 Kudos
Xilinx Employee
Xilinx Employee
Registered: ‎01-11-2011

Re: System run not working

Is the XRT environment being sourced before you do the hardware runs? For example:

source /opt/xilinx/xrt/setenv.sh

On your working result, are you placing the xcl files in the same directory as the run?

Please don’t forget to reply, kudo, and accept as solution!
0 Kudos
Visitor ivars211
Registered: ‎11-25-2018

Re: System run not working

I am launching Xilinx SDx as follows:

source /tools/Xilinx/SDx/2018.3/settings64.sh && sdx

I also tried 

source /opt/xilinx/xrt/setup.sh

before launching SDx, but it did nothing.


It seems that it needs to load xclbin, otherwise none of the GUI examples work.

This is the only working example:

#include <stdlib.h>
#include <fstream>
#include <iostream>
#include "vadd.h"

//TARGET_DEVICE macro needs to be passed from gcc command line
#if defined(SDX_PLATFORM) && !defined(TARGET_DEVICE)
    #define STR_VALUE(arg)      #arg
    #define GET_STRING(name) STR_VALUE(name)

static const int DATA_SIZE = 4096;

static const std::string error_message =
    "Error: Result mismatch:\n"
    "i = %d CPU result = %d Device result = %d\n";

int main(int argc, char* argv[]) {

    //TARGET_DEVICE macro needs to be passed from gcc command line
    const char *target_device_name = TARGET_DEVICE;

    if(argc != 2) {
		std::cout << "Usage: " << argv[0] <<" <xclbin>" << std::endl;
		return EXIT_FAILURE;

    char* xclbinFilename = argv[1];
    // Compute the size of array in bytes
    size_t size_in_bytes = DATA_SIZE * sizeof(int);
    // Creates a vector of DATA_SIZE elements with an initial value of 10 and 32
    // using customized allocator for getting buffer alignment to 4k boundary
    std::vector<int,aligned_allocator<int>> source_a(DATA_SIZE, 10);
    std::vector<int,aligned_allocator<int>> source_b(DATA_SIZE, 32);
    std::vector<int,aligned_allocator<int>> source_results(DATA_SIZE);
    std::vector<cl::Device> devices;
    cl::Device device;
    std::vector<cl::Platform> platforms;
    bool found_device = false;

    //traversing all Platforms To find Xilinx Platform and targeted
    //Device in Xilinx Platform
    for(size_t i = 0; (i < platforms.size() ) & (found_device == false) ;i++){
        cl::Platform platform = platforms[i];
        std::string platformName = platform.getInfo<CL_PLATFORM_NAME>();
        if ( platformName == "Xilinx"){
            platform.getDevices(CL_DEVICE_TYPE_ACCELERATOR, &devices);

            //Traversing All Devices of Xilinx Platform
            for (size_t j = 0 ; j < devices.size() ; j++){
                device = devices[j];
                std::string deviceName = device.getInfo<CL_DEVICE_NAME>();
                if (deviceName == target_device_name){
                    found_device = true;
    if (found_device == false){
       std::cout << "Error: Unable to find Target Device " 
           << target_device_name << std::endl;
       return EXIT_FAILURE; 

    // Creating Context and Command Queue for selected device
    cl::Context context(device);
    cl::CommandQueue q(context, device, CL_QUEUE_PROFILING_ENABLE);

    // Load xclbin 
    std::cout << "Loading: '" << xclbinFilename << "'\n";
    std::ifstream bin_file(xclbinFilename, std::ifstream::binary);
    bin_file.seekg (0, bin_file.end);
    unsigned nb = bin_file.tellg();
    bin_file.seekg (0, bin_file.beg);
    char *buf = new char [nb];
    bin_file.read(buf, nb);
    // Creating Program from Binary File
    cl::Program::Binaries bins;
    cl::Program program(context, devices, bins);
    // This call will get the kernel object from program. A kernel is an 
    // OpenCL function that is executed on the FPGA. 
    cl::Kernel krnl_vector_add(program,"krnl_vadd");
    // These commands will allocate memory on the Device. The cl::Buffer objects can
    // be used to reference the memory locations on the device. 
    cl::Buffer buffer_a(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY,  
            size_in_bytes, source_a.data());
    cl::Buffer buffer_b(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY,  
            size_in_bytes, source_b.data());
    cl::Buffer buffer_result(context, CL_MEM_USE_HOST_PTR | CL_MEM_WRITE_ONLY, 
            size_in_bytes, source_results.data());
    // Data will be transferred from system memory over PCIe to the FPGA on-board
    // DDR memory.
    q.enqueueMigrateMemObjects({buffer_a,buffer_b},0/* 0 means from host*/);

    //set the kernel Arguments
    int narg=0;

    //Launch the Kernel

    // The result of the previous kernel execution will need to be retrieved in
    // order to view the results. This call will transfer the data from FPGA to
    // source_results vector

    //Verify the result
    int match = 0;
    for (int i = 0; i < DATA_SIZE; i++) {
        int host_result = source_a[i] + source_b[i];
        if (source_results[i] != host_result) {
            printf(error_message.c_str(), i, host_result, source_results[i]);
            match = 1;

    std::cout << "TEST " << (match ? "FAILED" : "PASSED") << std::endl; 
    return (match ? EXIT_FAILURE :  EXIT_SUCCESS);


Can someone please confirm that all Xilinx SDx examples supposed to work for 2018.3?

0 Kudos
Xilinx Employee
Xilinx Employee
Registered: ‎07-18-2014

Re: System run not working

Hi @ivars211,

SDx GIT Examples should work with 2018.3 release. Which OS you are running?

There is some known issue with specific OS and discussed here:


Following was suggested in last comment:

- In the "Debug" and "Run" settings (do this for all three configurations: Emu-SW, Emu-HW and System) activate the checkbox "Automatically add binary container(s) to arguments" in the second tab "Arguments".

- Host-Code: Remove the call to the xcl:find_binary_file and subsitute it with the xclbin file provided by command line argument argv[1]:


/* skipping find_binary_file, which causes issues with snprintf in line 194 of xcl2.cpp */
/* std::string binaryFile = xcl::find_binary_file(device_name,"vector_addition"); */
std::string binaryFile = argv[1]; /* simply take the command line argument  */



0 Kudos