Results 1 to 8 of 8

Thread: Image Support and clCreateImage2d

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    5

    Image Support and clCreateImage2d

    Hi All,

    I have an application in mind, that would make really good use of OpenCL image processing. I assume that a GPU is going to be best placed to do this, and I was surprised to find that CL_DEVICE_IMAGE_SUPPORT evaluated to false, when I had my clGetDeviceIDs flag set to CL_DEVICE_TYPE_GPU. I have a ATI Radeon HD 4850. Isn't a lack of image support a big hole?

    Anyway, supposing I set the flag to CL_DEVICE_TYPE_CPU, where there is image support, what exactly is it that I'm to supply to host_ptr in clCreateImage2D? In Cocoa speak, I have tried to send it "im", where im is created by:

    unsigned char *im = (unsigned char*) malloc(height*pitch);
    memcpy(im, [bmImage bitmapData], height*[bmImage bytesPerRow]);

    basically exactly as the Apple example code does. I'd follow the way the example code does it, but I can't find any examples that actually use the method that has the clCreateImage2D call in it. When I do this, I get a CL_INVALID_HOST_PTR error. Any help would be much appreciated.

    Thank you,

    Ian.

  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    5

    Re: Image Support and clCreateImage2d

    Never mind. I figured it out. The image I was passing was fine. I just had other arguments in clCreateImage2D set wrong.

  3. #3
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: Image Support and clCreateImage2d

    Note that image processing on the CPU is not going to be nearly as fast as on the GPU. GPUs have special hardware for interpolation and format conversion, which speeds those up. You will probably be better off using buffers on the CPU. (If you need to do interpolation between pixels the Apple CPU implementation is highly optimized, but still much slower than a GPU hardware implementation.)

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    5

    Re: Image Support and clCreateImage2d

    Well, indeed. As I'm only just recently starting to look at OpenCL, it comes a surprise, that presumably, image support is the exception rather than the rule, for most of the GPUs out there (based on the fact that my computer is new and doesn't have image support). I've already created an implementation of my algorithm that uses multiple cores, so I don't know if there's any point in pursuing the OpenCL route for the CPU. However, I only need one channel value from the image (e.g. I can just take red), so I can try creating a 2D array of values to mimic the image, and go from there. The output would need three channels though, so I guess I'd have to output as a 3D array, or perhaps I can have a struct that the application and the kernel can both read?

  5. #5
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: Image Support and clCreateImage2d

    Image support should be expected on GPUs, but the problem is that OpenCL is much more stringent about the precision of image support than a bunch of GPUs' hardware. (Notably the AMD 4000 series are a bit tricky.) Of course AMD doesn't even support the 4000 series at all, so that says something about how good they are for OpenCL, unfortunately.

    For your output of three channels you should just do either an RGB output or an RRRR...GGGG...BBBB... type output depending on what final format you need for the images.

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Posts
    5

    Re: Image Support and clCreateImage2d

    Thanks very much. It's useful to know the lie of the land. A bit disappointing that my card is perhaps sub-standard, but I have only just started looking at OpenCL, so I don't know the significance of not having the image support.

    Anyway, the RRRR..., GGGG..., BBBB... output would work well in my situation. Thank you for that. But I see that "a buffer object stores a one-dimensional collection of elements". Does that mean I have to turn my image into one long 1D array?

    Ian.

  7. #7
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: Image Support and clCreateImage2d

    Effectively yes. You would access it as:

    red = data[y*row_width+x+red_offset];
    green = data[y*row_width+x+green_offset];

    etc.

  8. #8
    Junior Member
    Join Date
    Feb 2010
    Posts
    5

    Re: Image Support and clCreateImage2d

    Thank you, that is what I have done.

    Ian.

Similar Threads

  1. Error when create image with clCreateImage2D
    By YOYOSENIOR in forum OpenCL
    Replies: 4
    Last Post: 05-03-2011, 05:15 PM
  2. Images without Image support?
    By wscrosswy in forum OpenCL
    Replies: 5
    Last Post: 03-09-2011, 05:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •