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.
1719 Discussions

CL_OUT_OF_HOST_MEMORY when creating context on CPU device

AB22
Beginner
811 Views

I can detect the CPU ("11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz") with my OpenCL application on my PC.  I can query it for parameters successfully.  However, when I try to create a context with that device I get -6 returned.  I'm sure this has worked previously - how can I diagnose what has caused it to run out of memory?  There is nothing taxing the PC when this application is running.  Example code as follows:

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

#define MAX_PLATFORMS 10
#define MAX_DEVICES_PER_PLATFORM 10
#define VALUE_SIZE 10000

int main(void)
{
    cl_int err;
    cl_platform_id platforms[MAX_PLATFORMS];
    cl_uint numPlatforms;

    err = clGetPlatformIDs(MAX_PLATFORMS, platforms, &numPlatforms);
    if (CL_SUCCESS == err)
        printf("\nDetected OpenCL platforms: %d\n", numPlatforms);
    else
        printf("\nError calling clGetPlatformIDs. Error code: %d\n", err);

    cl_device_id desired_device;
    for (size_t i = 0; i < numPlatforms; i++) {
        cl_device_id devices[MAX_DEVICES_PER_PLATFORM];
        cl_uint num_devices;
        err = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, MAX_DEVICES_PER_PLATFORM, devices, &num_devices);
        printf("%d devices on platform %d, err: %d\n", num_devices, (int)i, (int)err);

        for (size_t j = 0; j < num_devices; j++) {
            char response[VALUE_SIZE];
            cl_uint uint_response;
            size_t size_returned;
            err = clGetDeviceInfo(devices[j], CL_DEVICE_NAME, VALUE_SIZE, response, &size_returned);
            if (0 == err) {
                printf("device %d returned a value of %s\n", (int)j, response);
            }
            else {
                printf("err response %d\n", (int)err);
            }
            err = clGetDeviceInfo(devices[j], CL_DEVICE_EXTENSIONS, VALUE_SIZE, response, &size_returned);
            if (0 == err) {
                printf("device %d returned a value of %s\n", (int)j, response);
            }
            else {
                printf("err response %d\n", (int)err);
            }
            err = clGetDeviceInfo(devices[j], CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, 10, &uint_response, &size_returned);
            if (0 == err) {
                printf("device %d returned a value of %d for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE\n", (int)j, (int)uint_response);
            }
            else {
                printf("err response %d\n", (int)err);
            }

            if (i == 2) {
                printf("This is the one!\n");
                memcpy(&desired_device, &devices[j], sizeof(cl_device_id));
            }
        }
    }

    cl_context context = clCreateContext(NULL, 1, &desired_device, NULL, NULL, &err);
    printf("context created with error %d\n", (int)err);

    return 0;
}

Please forgive the slightly brittle selection of the device - this is manually picking the CPU in my PC and avoiding the GPU.  The call to `clCreateContext` is placing -6 in the `err` variable.

0 Kudos
2 Replies
cw_intel
Moderator
734 Views

Hi,

Could you let me know the version of OpenCL RT you used? And where download the OpenCL RT? Could you provide the output of the code on your machine?

BTW, you said this code could work previously, did you make any changes on your machine, for example, did update OpenCL RT, etc?


Thanks


0 Kudos
cw_intel
Moderator
668 Views

Hi,


We haven't heard back from you for a long time so we are assuming that you have found a solution on your own. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.


Thanks


0 Kudos
Reply