advantages of using image2d

  • mux85

    mux85 - 2010-03-31

    Hi, the project I'm going to do with opencl is about tracking movement in videos. I was wondering what would be the advantages to pass the data to the kernel in form of image2d instead of just an array. A correlated question is: is there any way to pass a multidimensional array to a kernel? thanks

  • nythrix

    nythrix - 2010-03-31

    From the OpenCL specs, section 5.2:

    Memory objects are categorized into two types: buffer objects, and image objects. A buffer
    object stores a one-dimensional collection of elements whereas an image object is used to store a
    two- or three- dimensional texture, frame-buffer or image.

    Elements of a buffer object can be a scalar data type (such as an int, float), vector data type, or a
    user-defined structure. An image object is used to represent a buffer that can be used as a texture
    or a frame-buffer. The elements of an image object are selected from a list of predefined image
    formats. The minimum number of elements in a memory object is one.

    The fundamental differences between a buffer and an image object are:

    Elements in a buffer are stored in sequential fashion and can be accessed using a pointer
    by a kernel executing on a device. Elements of an image are stored in a format that is
    opaque to the user and cannot be directly accessed using a pointer. Built-in functions are
    provided by the OpenCL C programming language to allow a kernel to read from or write
    to an image.

    For a buffer object, the data is stored in the same format as it is accessed by the kernel,
    but in the case of an image object the data format used to store the image elements may
    not be the same as the data format used inside the kernel. Image elements are always a 4-
    component vector (each component can be a float or signed/unsigned integer) in a kernel.
    The built-in function to read from an image converts image element from the format it is
    stored into a 4-component vector. Similarly, the built-in function to write to an image
    converts the image element from a 4-component vector to the appropriate image format
    specified such as 4 8-bit elements, for example.

    That said, you can access images through sampler objects inside the kernel ( I haven't used them yet but they look solid so if you don't want to reinvent the wheel and then some, go with the image object.

    is there any way to pass a multidimensional array to a kernel?
    Unfortunately, no. That goes for all pointer to pointer types.

  • mux85

    mux85 - 2010-03-31



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks