OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.

Example shows CL_DEVICE_NOT_FOUND

lolxdfly
Novice
4,051 Views

Hello,

I started with this guide: https://software.intel.com/en-us/articles/sdk-for-opencl-2019-gsg-windows-os

However, executing the template program results in "clGetDeviceIDs() returned CL_DEVICE_NOT_FOUND". What did I do wrong? I could find my CPU and GPU at the Platform Info like the guide showed it. I have the i5-4670K with Intel HD Graphics 4600. I tried already repairing the installation. That does not help. Is there something wrong with my runtime installation or is just my cpu too old? :(

0 Kudos
6 Replies
Michael_C_Intel1
Moderator
4,051 Views

Hi MarcelLD,

Thanks for the feedback.

If platform info dialogs can enumerate and give back OpenCL platform and device info the system setup is likely correct.

Can you provide some system information:

  • What Intel graphics driver are you using? Try Device Manager and getting the version string from "Display Adapters->Intel(R) [ hd , iris, iris pro ], Graphics ###", Driver Tab, Driver Version?
  • Which program are you executing? Is it one of the programs from a MSVS template? Which template?
  • How is it being executed? From the command line or from the IDE?
  • Which version of the SDK or OpenCL tools is in use... Which version of MSVS?

Can you show a screen shot or full console output of the error?

 

Thanks,

-MichaelC

 

0 Kudos
Michael_C_Intel1
Moderator
4,051 Views

Hi MarcelLD,

A model number for the system if applicable can also be useful.

Thanks,

-MichaelC

0 Kudos
lolxdfly
Novice
4,051 Views

Hello,

the device manager shows "Intel (R) HD Graphics 4600" with Driver Version "20.19.15.4531".

I use the GPUOpenCLProject-Template from MSVS. Since I use Win10 I had to change the Windows SDK Version from 8.1 to 10.0.14393.0. I also tried different Platfrom Targets (Win32/x64), but executing the Programm always results in CL_DEVICE_NOT_FOUND:

I tried to start it from IDE with the Local Windows Debugger, with double clicking the .exe-file or with CLI. It's always this error.

I use VS2017 Enterprise with the tools from Intel Studio 2019.3.063 and the Intel Graphics Driver Verison 15.40.42.5063.

Best Regards,

Marcel

0 Kudos
Michael_C_Intel1
Moderator
4,054 Views

Hi MarcelLD,

Thanks for the details... What are the two platforms and devices per the platform info dialog... Can you expose the drop downs? Example:

sdk2019-infotree.png

Do you have any other accelerators on the system?

At the risk of making an erroneous prediction: I'm thinking it's more likely the article and sample template are stale and your system is fine. Per the source code, the program looks for the first platform that has a GPU device type. On the example system in the article, it finds a GPU device in the first platform interrogated so no issues are observed. On yours you may have newer or different platforms that are interrogated in a different order. It looks like the OpenCL-C kernel is still executing successfully and that the error emitted from the host API could have been programmed more clearly.

I recommend adding some cout << or printf(...) debugging and emitting detected parameters in the template program in particular if you are new to OpenCL... or breakpoint pausing and inspecting interrogation variables with the GUI debugger... hopefully it will make the picture clear quickly.

-MichaelC

0 Kudos
lolxdfly
Novice
4,054 Views

Hello,

this is my platform info:

I have a Nvidia Graphics card too. But I have not installed OpenCL drivers for this card.

To check if the kernel is executed sucessfully I moved to a different test code:

#include <iostream>
#include <fstream>
#include <string>
#include <memory>
#include <vector>
#include <stdlib.h>

#define __CL_ENABLE_EXCEPTIONS
#include <CL/cl.hpp>

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

    const int N_ELEMENTS=1024*1024;
    unsigned int platform_id=0, device_id=0;

    try{
        std::unique_ptr<int[]> A(new int[N_ELEMENTS]);
        std::unique_ptr<int[]> B(new int[N_ELEMENTS]);
        std::unique_ptr<int[]> C(new int[N_ELEMENTS]);

        for( int i = 0; i < N_ELEMENTS; ++i ) {
            A = i;
            B = i;
        }

        // Query for platforms
        std::vector<cl::Platform> platforms;
        cl::Platform::get(&platforms);

        // Get a list of devices on this platform
        std::vector<cl::Device> devices;
        platforms[platform_id].getDevices(CL_DEVICE_TYPE_GPU, &devices); // Select the platform.

        // Create a context
        cl::Context context(devices);

        // Create a command queue
        cl::CommandQueue queue = cl::CommandQueue( context, devices[device_id] );   // Select the device.

        // Create the memory buffers
        cl::Buffer bufferA=cl::Buffer(context, CL_MEM_READ_ONLY, N_ELEMENTS * sizeof(int));
        cl::Buffer bufferB=cl::Buffer(context, CL_MEM_READ_ONLY, N_ELEMENTS * sizeof(int));
        cl::Buffer bufferC=cl::Buffer(context, CL_MEM_WRITE_ONLY, N_ELEMENTS * sizeof(int));

        // Copy the input data to the input buffers using the command queue.
        queue.enqueueWriteBuffer( bufferA, CL_FALSE, 0, N_ELEMENTS * sizeof(int), A.get() );
        queue.enqueueWriteBuffer( bufferB, CL_FALSE, 0, N_ELEMENTS * sizeof(int), B.get() );

        // Read the program source
        std::ifstream sourceFile("vector_add_kernel.cl");
        std::string sourceCode( std::istreambuf_iterator<char>(sourceFile), (std::istreambuf_iterator<char>()));
        cl::Program::Sources source(1, std::make_pair(sourceCode.c_str(), sourceCode.length()));

        // Make program from the source code
        cl::Program program=cl::Program(context, source);

        // Build the program for the devices
        program.build(devices);

        // Make kernel
        cl::Kernel vecadd_kernel(program, "vecadd");

        // Set the kernel arguments
        vecadd_kernel.setArg( 0, bufferA );
        vecadd_kernel.setArg( 1, bufferB );
        vecadd_kernel.setArg( 2, bufferC );

        // Execute the kernel
        cl::NDRange global( N_ELEMENTS );
        cl::NDRange local( 256 );
        queue.enqueueNDRangeKernel( vecadd_kernel, cl::NullRange, global, local );

        // Copy the output data back to the host
        queue.enqueueReadBuffer( bufferC, CL_TRUE, 0, N_ELEMENTS * sizeof(int), C.get() );

        // Verify the result
        bool result=true;
        for (int i=0; i<N_ELEMENTS; i ++)
            if (C !=A+B) {
                result=false;
                break;
            }
        if (result)
            std::cout<< "Success!\n";
        else
            std::cout<< "Failed!\n";

    }
    catch(cl::Error err) {
        std::cout << "Error: " << err.what() << "(" << err.err() << ")" << std::endl;
        return( EXIT_FAILURE );
    }

    std::cout << "Done.\n";
    return( EXIT_SUCCESS );
}

This code prints "Error clGetDeviceIDs(-1)". That the same issue. If I add "CL_DEVICE_TYPE_CPU" to "platforms[platform_id].getDevices()" this code runs perfect... but on the CPU and not on the GPU.

Best regards,

Marcel

0 Kudos
Michael_C_Intel1
Moderator
4,054 Views

Hi MarcelLD,

Thanks for the clear example... A long winded comment may help newer users observing forums:

  • The system screen shot has two OpenCL platforms exposed...
    • The first is offered by Intel® CPU Runtime for OpenCL™ Applications. This platform is associated with a runtime intended to enable Windows OS based Intel platforms without Intel Graphics.
    • The second platform is offered by the Intel Graphics Driver package for Windows OS. It contains a CPU and Intel Graphics implementations for OpenCL.
  • Typically, most systems would not see both platforms installed on Windows OS.
    • A. If the system is an Intel Graphics capable platform, Windows OS will have the graphics driver preinstalled... so there may not be the need to have the separate CPU runtime. Of course, there may be graphics driver updates.
    • B. If they have an Intel system without Intel graphics, the system administrator looks to download the CPU runtime. The graphics runtime doesn't apply because the system doesn't have the hardware.
    • Note: we are actively exploring making deployment of each of these simpler for users and developers alike.
  • When the C++ wrapper asks a platform for a device of a type that doesn't exist with
    cl::Platform::getDevice(  cl_device_type type, vector< Device > * devices )
    it will return an error per the specification:
  • I'll add this explanation to the article you visited, and ask the dev team to update the sample to be more clear about platforms being interrogated.

Thanks for the feedback.

-MichaelC

0 Kudos
Reply