Results 1 to 3 of 3

Thread: 2D Arrays in local functions

  1. #1
    Junior Member
    Join Date
    Feb 2013

    2D Arrays in local functions

    Hello all,
    I'm fairly new to OpenCL, and am just now trying to figure out all the semantics but I think I can do some pretty neat stuff with it. I have managed so far to pass an array to a kernel function, make a local copy of it, and pass my local copy to a local (perhaps that's not the correct term) function for processing.

    Now I would like to be able to create a local 2d array inside that local function, but it seems I can't do that? Or perhaps I haven't found the syntax that is preferred yet. Here are a few different things I've tried:

    Code :
    uint * func1 (uint x[], uint y[]) {
        // Doesn't like this
        uint ** z [5][5];
        // This works...
        uint ** z [5];
        // until this line.
        z[0] = uint[5];
        // This doesn't work either, but I'm not sold there is a "new" keyword
        uint ** z[5];
        z[0] = new uint[5];
        // In a similar fashion this doesn't work either
        uint ** z[5];
        z[0] = &uint[5];

    I'm running out of ideas, can anyone help out?

  2. #2

    Re: 2D Arrays in local functions

    There is no new keyword in OpenCL. So the syntax will always be int oneDArray[100] for a 1D array, int twoDArray[5][5] for a 2D array, etc. Hence you would want to use uint z[5][5][5] I think. You cannot change this at run time.

  3. #3
    Junior Member
    Join Date
    Feb 2013

    Re: 2D Arrays in local functions

    Thanks, turns out I did something dumb in my host program, so that my opencl code was never correct when trying that.... Thanks again.

Similar Threads

  1. Replies: 0
    Last Post: 02-18-2013, 05:44 AM
  2. Atomic functions for ushort arrays
    By nachovall in forum OpenCL
    Replies: 0
    Last Post: 03-16-2011, 04:02 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
Proudly hosted by Digital Ocean