0
votes

I am developing the OpenCL app on Windows 10 basing on Eclipse CDT (Mars) and intel_sdk_for_opencl_setup_6.1.0.1600. The devices of my computer is as follow:

OS: Windows 10 pro CPU: I7-5500U Driver:win64_15407.4279.exe

Problem: Although the code is built successfully in Eclipse CDT, it is crashing and hanging when it is running as-->local C/C++ Application in Eclipse CDT. In fact, it can be built and ran successfully in the same IDE and OS by replacing the file OpenCL.lib(which is come from intel OpenCL SDK and locates in C:\Program Files (x86)\Intel\OpenCL SDK\6.1\lib\x64\OpenCL.lib ) with the counterpoint of AMD OpenCL SDK(***\AMD APP\lib\x64\OpenCL.lib).

Besides replacing the file (C:\Program Files (x86)\Intel\OpenCL SDK\6.1\lib\x64\OpenCL.lib) with (***\AMD APP\lib\x64\OpenCL.lib), how can I run the code as follow successfully with native intel_sdk_for_opencl_setup_6.1.0.1600 and Eclipse CDT ?

#include <stdio.h>
#include <stdlib.h>
#include<CL/cl.h>

int main(int argc, char *argv[]) {
    cl_uint err;
    cl_uint num_platform;
    cl_platform_id *platform;

    err = clGetPlatformIDs(0, NULL, &num_platform);
    if (CL_SUCCESS == err)
        printf("Number of Detected OpenCL platforms: %d\n\n", num_platform);
    else
        printf("Error calling clGetPlatformIDs. Error code: %d \n", err);

    platform = (cl_platform_id *) malloc(sizeof(cl_platform_id) * num_platform);

    err = clGetPlatformIDs(num_platform, platform, NULL);
    size_t size;

    for (cl_uint i = 0; i < num_platform; i++) {

        err = clGetPlatformInfo(platform[i], CL_PLATFORM_NAME, 0, NULL, &size);
        char *PName = (char *) malloc(size);
        err = clGetPlatformInfo(platform[i], CL_PLATFORM_NAME, size, PName,NULL);
        printf("PName:%s\n", PName);

        err = clGetPlatformInfo(platform[i], CL_PLATFORM_VENDOR, 0, NULL,&size);
        char *PVendor = (char *) malloc(size);
        err = clGetPlatformInfo(platform[i], CL_PLATFORM_VENDOR, size, PVendor,NULL);
        printf("PVendor:%s\n", PVendor);

        err = clGetPlatformInfo(platform[i], CL_PLATFORM_VERSION, 0, NULL,&size);
        char *PVersion = (char *) malloc(size);
        err = clGetPlatformInfo(platform[i], CL_PLATFORM_VERSION, size,PVersion, NULL);
        printf("PVersion:%s\n", PVersion);
        printf("i=%d err=%d\n\n", i, err);
    }
    return 0;
}
1

1 Answers

0
votes

Where is it crashing? On one of the OpenCL calls? I've seen crashes in clGetPlatformIDs for various reasons (including bad vendor distributions of OpenCL.dll). On Windows, OpenCL.lib is just a static wrapper for OpenCL.dll and both are typically the same as what Khronos distributes as the OpenCL ICD (Installable Client Driver which is a trampoline to whatever vendor drivers are installed). However, some vendors change them up (for example, to do NVIDIA Nsight tracing you need NVIDIA's versions). So while I can't explain why one is crashing for you, I can confidently say that you can swap out the crashing one for a non-crashing one and be fine.