Forum Discussion

okramer's avatar
okramer
Icon for Occasional Contributor rankOccasional Contributor
6 years ago
Solved

cl::Platform::getDevice() returning error for hardware platform

My app finds the device platforms that include the a10_ref emulator and (presumably) the actual hardware. But in the host code, when the platform is queried for devices, only the emulator is returning a valid device. I get an error code returned from getDevices() using the hardware platform instance.

I also am seeing this:

$ aocl list-devices
--------------------------------------------------------------------
Warning:
No devices attached for package:
/home/okramer/intelFPGA_pro/19.3/hld/board/a10_ref
--------------------------------------------------------------------

Here is the output from the print_platform_info() host utility function:

Number of Platforms: 4
Platform Number: 0
Platform Name: Intel(R) FPGA Emulation Platform for OpenCL(TM)
Platform Profile: EMBEDDED_PROFILE
Platform Version: OpenCL 1.0 Intel(R) FPGA SDK for OpenCL(TM), Version 19.2
Platform Vendor: Intel(R) Corporation
 
Platform Number: 1
Platform Name: Intel(R) FPGA SDK for OpenCL(TM)
Platform Profile: EMBEDDED_PROFILE
Platform Version: OpenCL 1.0 Intel(R) FPGA SDK for OpenCL(TM), Version 19.3
Platform Vendor: Intel(R) Corporation
 
Platform Number: 2
Platform Name: Intel(R) CPU Runtime for OpenCL(TM) Applications
Platform Profile: FULL_PROFILE
Platform Version: OpenCL 2.1 LINUX
Platform Vendor: Intel(R) Corporation
 
Platform Number: 3
Platform Name: NVIDIA CUDA
Platform Profile: FULL_PROFILE
Platform Version: OpenCL 1.2 CUDA 10.2.95
Platform Vendor: NVIDIA Corporation

When I select platform 0 (emulator), I can successfully call platform.getDevices(). The output of print_device_info() is:

Number of Devices in Platform: 1
Device Number: 0
Device Name: Intel(R) FPGA Emulation Device
Device Vendor: Intel(R) Corporation
Is Device Available?: 1
Is Device Little Endian?: 1
Device Max Compute Units: 20
Device Max Work Item Dimensions: 3
Device Max Work Group Size: 67108864
Device Max Frequency: 3500
Device Max Mem Alloc Size: 33715263488

However, when I select platform 1, platform.getDevices() returns -1 with an empty device list. What could the problem be?

I have an Arria 10 GX dev kit plugged into the PCIe and USB of an Ubuntu 16.04 machine. Below is the host code snippet fetching platform and device:

bool getContextAndDevices(const std::string& mode,
                          cl::Platform& platform,
                          cl::Context& context,
                          std::vector<cl::Device>& DeviceList)
{
   cl_int err;
 
   // Set up map with mode-string as key and search-string as value for searching instance
   // of platform in platform listing. Not sure about "sim" but not using yet:
   std::map<std::string, std::string> platformNames;
   platformNames.insert({"emu","Emulation"});
   platformNames.insert({"sim","CPU"});
   platformNames.insert({"hw","SDK"});
 
   // Get list of available platforms:
   std::vector<cl::Platform> PlatformList;
   err = cl::Platform::get(&PlatformList);
   checkErr(err, "Get Platform List");
   checkErr(PlatformList.size()>=1 ? CL_SUCCESS : -1, "cl::Platform::get");
   print_platform_info(&PlatformList);
 
   // Look for desired platform by searching platform names using unique id string in map:
   uint current_platform_id =
      get_platform_id_with_string(&PlatformList, platformNames.find(mode)->second.c_str());
   printf("Using Platform: %d\n\n", current_platform_id);
   platform = PlatformList[current_platform_id];
 
   // Fetch devices associated with this device. Works for "emu" but fails for "hw":
   //err = platform.getDevices(CL_DEVICE_TYPE_ACCELERATOR, &DeviceList);
   err = platform.getDevices(CL_DEVICE_TYPE_ALL, &DeviceList);
   checkErr(err, "Get Devices");
   print_device_info(&DeviceList);
 
   //Create Context
   context = cl::Context(DeviceList, NULL, NULL, NULL, &err);
   checkErr(err, "Context Constructor");
   return true;
}
  • Hi okramer ,

    What's the kernel version of your Ubuntu?

    I've reproduce you issue, pls try my command line instruction (you have to use your Quartus version in commands):

    1. Check if card connected by USB: " lsusb|grep Altera "

    2. Go to .../intelFPGA_pro/18.1/quartus/bin and make "sudo killall -9 ./jtagd"

    sudo ./jtagd

    3 . /jtagconfig

    4 ./jtagconfig --setparam 1 JtagClock 6M

    5 . /jtagconfig --getparam 1 JtagClock

    6. Uncompress the following file .../intelFPGA_pro/18.1/hld/board/a10_ref/bringup/a10_ref_initialization.tgz to a temporary location

    7. In tmp folder: .../intelFPGA_pro/18.1/quartus/bin/quartus_pgm -l

    8. .../intelFPGA_pro/18.1/quartus/bin/quartus_pgm -c 1 -m JTAG -o "p;max5_150.pof@2"

    9. .../intelFPGA_pro/18.1/quartus/bin/quartus_pgm -c 1 -m JTAG -o "p;top.sof"

    10. sudo reboot (It must be soft reboot!)

    11. Do "lspci". Altera device should be in PCI list of devices.

    12. Go to .../intelFPGA_pro/18.1/hld and do "source init_opencl.sh".

    13. Go to .../intelFPGA_pro/18.1/hld/bin and do "sudo aocl install".

    14. sudo reboot. (soft reboot!) After reboot do source init_opencl.sh

    15. Check the card status via "aocl diagnose". Check the temperature of the card.

    16. Test PCI-E speed via "aocl diagnose all".

5 Replies

  • okramer's avatar
    okramer
    Icon for Occasional Contributor rankOccasional Contributor

    I found the problem was that the board installation (via "aocl install") was somehow defective. I had to uninstall and reinstall the a10_ref board and now I can see the device. Is it normal for the board installation to be corrupted somehow?

  • MEIYAN_L_Intel's avatar
    MEIYAN_L_Intel
    Icon for Frequent Contributor rankFrequent Contributor

    Hi,

    This error might be due to the reason as below:

    1. Installation not successful or
    2. The computer processing instruction interrupt the installation or
    3. The file/path to install driver is not available while install the driver.

    Thanks

  • GRN's avatar
    GRN
    Icon for Occasional Contributor rankOccasional Contributor

    Hi okramer ,

    What's the kernel version of your Ubuntu?

    I've reproduce you issue, pls try my command line instruction (you have to use your Quartus version in commands):

    1. Check if card connected by USB: " lsusb|grep Altera "

    2. Go to .../intelFPGA_pro/18.1/quartus/bin and make "sudo killall -9 ./jtagd"

    sudo ./jtagd

    3 . /jtagconfig

    4 ./jtagconfig --setparam 1 JtagClock 6M

    5 . /jtagconfig --getparam 1 JtagClock

    6. Uncompress the following file .../intelFPGA_pro/18.1/hld/board/a10_ref/bringup/a10_ref_initialization.tgz to a temporary location

    7. In tmp folder: .../intelFPGA_pro/18.1/quartus/bin/quartus_pgm -l

    8. .../intelFPGA_pro/18.1/quartus/bin/quartus_pgm -c 1 -m JTAG -o "p;max5_150.pof@2"

    9. .../intelFPGA_pro/18.1/quartus/bin/quartus_pgm -c 1 -m JTAG -o "p;top.sof"

    10. sudo reboot (It must be soft reboot!)

    11. Do "lspci". Altera device should be in PCI list of devices.

    12. Go to .../intelFPGA_pro/18.1/hld and do "source init_opencl.sh".

    13. Go to .../intelFPGA_pro/18.1/hld/bin and do "sudo aocl install".

    14. sudo reboot. (soft reboot!) After reboot do source init_opencl.sh

    15. Check the card status via "aocl diagnose". Check the temperature of the card.

    16. Test PCI-E speed via "aocl diagnose all".

  • GRN's avatar
    GRN
    Icon for Occasional Contributor rankOccasional Contributor

    You should do these steps after every hard reboot (dev kit card doesn't save drivers after power switch off)

  • okramer's avatar
    okramer
    Icon for Occasional Contributor rankOccasional Contributor

    I'm running Ubuntu 16.04. It must have been a faulty or corrupted install. It works now.