- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page