OpenCL 1.2 clCreateImage(...)

Hello maybe somebody can enlighten me on why my software is crashing.

I switched over to OpenCL 1.2 (AMD’s implementation). When I call the new clCreateImage(…) function the software hangs…then crashes. I have no idea why whatsoever. With my debugger i noticed that it calls this function then looks into the OpenCL.dll file (the one i got from AMD v1.2) and calls clCreateImage3D. I specified in the image descriptor to use image2D. I am not sure if this is the issue. The software was working before I switched over to OpenCL v1.2 and was using clCreateImage2D. I’ll post the applicable code below.

Thanks in advance for all your help,

    //image format
    cl_image_format image_format;
    image_format.image_channel_order = CL_RGBA;
    image_format.image_channel_data_type = CL_FLOAT;

    //OPENCL 1.2
    //image descriptor (for opencl v1.2)
    cl_image_desc image_desc;
    image_desc.image_type = CL_MEM_OBJECT_IMAGE2D;
    image_desc.image_width = width;
    image_desc.image_height = height;
    image_desc.image_array_size = 1;
    image_desc.image_row_pitch = 0;
    image_desc.image_slice_pitch = 0;
    image_desc.num_mip_levels = 0;
    image_desc.num_samples = 0;
    image_desc.buffer = NULL;

    //OPENCL 1.2
    mem_image = clCreateImage(context, CL_MEM_WRITE_ONLY, &image_format, &image_desc, NULL, &error);
    //--- doesn't make it past here ---
    //OPENCL 1.1 (what I used to call) mem_image = clCreateImage2D(context, CL_MEM_WRITE_ONLY, &image_format, width, height, 0, NULL, &error);

I should mention I am using an NVIDIA GPU and Intel CPU.

You didn’t set cl_image_desc.image_depth to anything.

No need; not used for 2D images…only 3D ones.

Still, poster has a good point; you should set even unused members.

Have you verified that your device supports OpenCL 1.2? Just because the SDK does doesn’t mean the device does, and new APIs won’t exist on old devices.

My thinking is that if i’m linking to the 1.2 libs and it compiles and my GPU runs all the code up to this function then it would not be an incompatibility issue. However, I am using the 460GTX, which as far as I know supports 1.1 and no information is given about it running 1.2. So you may be right. Do you know how it is possible that I could even run the software?


That’s the problem. NVIDIA doesn’t support OpenCL 1.2. If you call 1.2 APIs, you’ll crash because the ICD doesn’t have functions to jump to. You have to check the device support before using the new APIs.

The OpenCL 1.1 Image Creation APIs are supported on all current OpenCL 1.2 devices; just use them instead of the new 1.2 APIs. The compiler might whine that they are deprecated, but they will still work.