Results 1 to 6 of 6

Thread: 2 dimensions' array

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    14

    2 dimensions' array

    I'm still new to opencl and not used to the programming yet.
    I'm just wondering that is it possible to use a 2 dimensions' array in Opencl...??
    i tried to search in google but found nothing.
    Ex:
    Like we do in C " int array[][];"

    help me out please.

  2. #2
    Member
    Join Date
    Nov 2009
    Location
    Scotland
    Posts
    72

    Re: 2 dimensions' array

    You can create 2-dimensional private or local arrays inside a kernel.
    However, you cannot create 2-dimensional global arrays unless you want to use images. Buffers created with clCreateBuffer are always linear, but you can use macros to access them like 2-dimensional arrays, e.g.:

    Code :
    #define A(x,y) a[x*width + y]

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    3

    Re: 2 dimensions' array

    Is it stated in the standard that a kernel argument cannot be a 2-dimensional array ?

    A kernel with a "float arg[10][10]" argument works with Nvidia implementation but not with AMD one.

    I only find in the 1.1 standard that a buffer should be linear (A 2-dimensional array is a bunch of linear memory AFAIK), and that VLA array aren't supported.

  4. #4
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: 2 dimensions' array

    Is it stated in the standard that a kernel argument cannot be a 2-dimensional array?
    Section 5.7.2. says that

    "If the argument is declared to be a pointer of a built-in scalar or vector type, or a user defined structure type in the global or constant address space, the memory object specified as argument value must be a buffer object (or NULL)"
    ...but it doesn't say anything about arrays. I'll ask the Working Group for a clarification.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  5. #5
    Junior Member
    Join Date
    Oct 2011
    Posts
    3

    Re: 2 dimensions' array

    Do you mean you'll ask for a clarification for a further release or will we get it for 1.1 ?

  6. #6
    Junior Member
    Join Date
    Oct 2011
    Posts
    3

    Re: 2 dimensions' array

    Seems that 1.2 clarified the situation in 3.5 :

    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.

Similar Threads

  1. input and output having different dimensions
    By acolubri in forum OpenCL
    Replies: 2
    Last Post: 07-09-2009, 02:42 PM

Posting Permissions

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