2

I am trying to use SDAccel to build an OpenCL application; then to run it on an PCIe FPGA-based card (alpha data).

I have tried to use the examples given but no success so far. Also there was no similar thread (and no respond to my queries) in any Xilinx forum.

So I have decided to create a small OpenCL application to test exhaustively.

Here is the source code:

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <assert.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <CL/opencl.h>

int main(int argc, char** argv)
{
   int err;      // error code returned from api calls
   uint i = 0;
   uint j = 0;

   char *info;
   size_t infoSize;
   cl_uint num_platforms;
   cl_platform_id *platform_id_array;

   const char* platfAttrNames[5] = {"Name","Vendor","Version","Profile","Extensions"};
   const cl_platform_info platfAttrTypes[5] = {CL_PLATFORM_NAME, 
                                               CL_PLATFORM_VENDOR,
                                               CL_PLATFORM_VERSION, 
                                               CL_PLATFORM_PROFILE, 
                                           CL_PLATFORM_EXTENSIONS};
   const uint platfAttrCount = sizeof(platfAttrNames)/sizeof(char*);

   // Get total number of platforms
   // First arg must be 0. Otherwise compilation error
   err = clGetPlatformIDs(0, NULL, &num_platforms); 
   printf("Number of available platforms = %d\n", num_platforms);

   // Get ID of each platform
   platform_id_array = (cl_platform_id *) malloc(sizeof(cl_platform_id) * num_platforms);
   err = clGetPlatformIDs(num_platforms, platform_id_array, NULL);
   if (err != CL_SUCCESS) {
     printf("Error: clGetPlatformIDs failed!\n"); 
     return EXIT_FAILURE;
   }

   // Get characteristics for each platform
   for (i = 0; i < num_platforms; i++) 
   {
     printf("n %d. Platform \n", i+1);

     for(j = 0; j < platfAttrCount; j++) {
      // Get platform attribute value size
      err = clGetPlatformInfo(platform_id_array[i], platfAttrTypes[j], 0, NULL, &infoSize);
      info = (char*) malloc(sizeof(char) * infoSize);

      // Get platform attribute value
      err = clGetPlatformInfo(platform_id_array[i], platfAttrTypes[j], infoSize, info, NULL);
      if (err != CL_SUCCESS) {
        printf("Error: clGetPlatformInfo - %s failed!\n", platfAttrNames[j]); 
        return EXIT_FAILURE;
       }
       printf("%s = %s\n", platfAttrNames[j], info); free(info);
     }
   }

   // Get total number of devices
   // Work with the first platform (the only one available)
   cl_uint num_devices;
   err = clGetDeviceIDs(platform_id_array[0], CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices);
   if (err != CL_SUCCESS) {
     printf("Error: clGetDeviceIDs couldn't find any devices!\n"); 
   }
   printf("Number of available devices of platform[0] = %d\n", num_devices);
 free(platform_id_array);
 return 0;
}

I use a tcl script to compile and build this. The output is:

Number of available platforms = 1
n 1. Platform 
Name = Xilinx
Vendor = Xilinx
Version = OpenCL 1.0 
Profile = EMBEDDED_PROFILE
Extensions = cl_khr_icd
Error: clGetDeviceIDs couldn't find any devices!
Number of available devices of platform[0] = 0
Segmentation fault (core dumped)

The problem is that:

  • (1) clGetDeviceIDs returns CL_DEVICE_NOT_FOUND,
  • (2) there is always segmentation fault on every run, and
  • (3) running on emulation environments (cpu and hw), none of the problems above appears.

Finally, I think the drivers are correctly installed. If I run:

lspci -v 

The relevant part of the output is:

01:00.0 Memory controller: Xilinx Corporation Device 7038
Subsystem: Xilinx Corporation Device 0010
Flags: bus master, fast devsel, latency 0, IRQ 129
Memory at df000000 (32-bit, non-prefetchable) [size=4M]
Memory at df400000 (32-bit, non-prefetchable) [size=1M]
Capabilities: <access denied>
Kernel driver in use: xdma
Kernel modules: xdma

Still I am not able to get it working on the FPGA.

Do you have any suggestion that could help me?

L30nardo SV.
  • 323
  • 1
  • 3
  • 14

2 Answers2

1

Which OS do you use? Xilinx supports RedHat and CentOS, so check that!

I also had this problem with the segmentation fault! Maybe you have to update the bitstream for the board for the first time using a JTAG cable. Once you have that the board will be ready for use with SDAccel. Look in the SDAccel tutorial: it has an appendix that describes the steps to get the boards updated. Also avoid using the precompiled example! Try to compile the other examples provided by Xilinx!

Dennis
  • 11
  • 1
  • Hi Dennis. I have followed all steps written in the manual and updated the board firmware using the file generated after build, but still no success! The only thing missing is the OS since I am using Fedora. Could you confirm that the OS was also your problem? – L30nardo SV. Jan 15 '16 at 10:47
  • No, I used CentOS from the start. Can you please check what the console output is if you type "lsusb | grep Xilinx" ! Can Vivado detect your board? – Dennis Jan 28 '16 at 16:49
  • I think you meant "lspci" instead of "lsusb". Anyway my OS detects the Xilinx board: lspci -v .... 01:00.0 Memory controller: Xilinx Corporation Device 7038. Could you tell me please which version of CentOS and SDAccel are you using? – L30nardo SV. Jan 29 '16 at 18:34
  • No, I meant lsusb. Because I had problems with the cable driver! I use CentOS 6.7 (final) and SDAccel 2015.1 ! Which board do you have? Can you please check if all steps from the Tutorial worked: http://www.xilinx.com/support/documentation/sw_manuals/xilinx2015_3/ug1021-sdaccel-tutorial.pdf – Dennis Feb 05 '16 at 10:28
  • I have the alpha data (Virtex7) board and using SDAccel 2015.3. The last part of that manual didn't work for me. This version of SDAccel uses a different installation process[http://www.xilinx.com/support/documentation/sw_manuals/xilinx2015_3/sdaccel_doc/index.html]. Basically it includes a script for installing the driver. Is the cable driver the one for programming the firmware on the board? – L30nardo SV. Feb 08 '16 at 09:33
  • Yes, you need it to program the fpga with the Vivado Design Suite! Can you describe in more detail which step didn't work? What error message do you get? – Dennis Feb 22 '16 at 16:44
  • Indeed, the FPGA firmware is already loaded. The system execution didn't work ("run_system"). There was a problem with the driver files, that's why the program didn't find the device and threw a segfault. Thanks for your help! – L30nardo SV. Mar 24 '16 at 12:44
1

There is a system level command which provided by xilinx can give you an overall system information. Check out "sudo sdxsyschk". And fix any Errors displayed.

In general, run something like "hello world" to make sure driver/DSA are installed correctly. Then hard reboot the machine.

Try it again. it should work now.

xiaoyong
  • 61
  • 5