PDA

View Full Version : 2D Arrays in local functions



howard
02-14-2013, 04:45 PM
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:



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?

chippies
02-15-2013, 02:50 AM
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.

howard
02-15-2013, 05:51 AM
Thanks, turns out I did something dumb in my host program, so that my opencl code was never correct when trying that.... Thanks again.