【问题标题】:OpenCL error executing on Xilinx FPGA在 Xilinx FPGA 上执行 OpenCL 错误
【发布时间】:2016-08-28 01:04:58
【问题描述】:

我正在尝试使用 SDAccel 构建 OpenCL 应用程序;然后在基于 PCIe FPGA 的卡上运行它(alpha 数据)。

我尝试使用给出的示例,但到目前为止没有成功。在任何 Xilinx 论坛中也没有类似的帖子(也没有回复我的问题)。

所以我决定创建一个小型 OpenCL 应用程序来进行详尽的测试。

这里是源代码:

#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;
}

我使用 tcl 脚本来编译和构建它。输出是:

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)

问题是:

  • (1) clGetDeviceIDs 返回 CL_DEVICE_NOT_FOUND,
  • (2) 每次运行总是存在分段错误,并且
  • (3) 在仿真环境(cpu 和硬件)上运行,没有 出现上述问题。

最后,我认为驱动程序已正确安装。如果我跑:

lspci -v 

输出的相关部分是:

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

我仍然无法让它在 FPGA 上运行。

你有什么建议可以帮助我吗?

【问题讨论】:

    标签: segmentation-fault opencl fpga xilinx


    【解决方案1】:

    您使用哪种操作系统? Xilinx 支持 RedHat 和 CentOS,请检查一下!

    我也遇到了分段错误的问题! 也许您必须第一次使用 JTAG 电缆更新电路板的比特流。获得该板后,即可与 SDAccel 一起使用。查看 SDAccel 教程:它有一个附录,描述了更新板的步骤。还要避免使用预编译的示例!尝试编译 Xilinx 提供的其他示例!

    【讨论】:

    • 嗨丹尼斯。我已经按照手册中写的所有步骤,并使用构建后生成的文件更新了板固件,但仍然没有成功!唯一缺少的是操作系统,因为我使用的是 Fedora。您能否确认操作系统也是您的问题?
    • 不,我从一开始就使用 CentOS。如果您键入“lsusb | grep Xilinx”,请检查控制台输出是什么! Vivado 可以检测到您的电路板吗?
    • 我认为您的意思是“lspci”而不是“lsusb”。无论如何,我的操作系统检测到 Xilinx 板:lspci -v .... 01:00.0 内存控制器:Xilinx Corporation 设备 7038。请问您使用的是哪个版本的 CentOS 和 SDAccel?
    • 不,我的意思是 lsusb。因为我的电缆驱动器有问题!我使用 CentOS 6.7(最终版)和 SDAccel 2015.1!你有哪个板子?您能否检查一下教程中的所有步骤是否有效:xilinx.com/support/documentation/sw_manuals/xilinx2015_3/…
    • 我有 alpha 数据 (Virtex7) 板并使用 SDAccel 2015.3。该手册的最后一部分对我不起作用。此版本的 SDAccel 使用不同的安装过程[xilinx.com/support/documentation/sw_manuals/xilinx2015_3/…。基本上它包括一个用于安装驱动程序的脚本。电缆驱动器是用于编程板上固件的驱动器吗?
    【解决方案2】:

    xilinx 提供的系统级命令可以为您提供整体系统信息。查看“sudo sdxsyschk”。并修复所有显示的错误。

    一般来说,运行“hello world”之类的命令以确保正确安装驱动程序/DSA。 然后硬重启机器。

    再试一次。 它现在应该可以工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-14
      • 1970-01-01
      • 1970-01-01
      • 2012-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多