ryta1203

Suggestions for gather on flattened 2D array?

Discussion created by ryta1203 on Aug 22, 2008
Latest reply on Aug 29, 2008 by Ceq
I was wondering if anyone had any suggestions to go about accessing (via gather) a 1D array (that was a 2D array now flattened to 1D) that is not a direct indexof() access.

For example:

normal code:
for (i = 0 ; i < row ; i++)
for(j = 0 ; j < col ; j++)
newValue = array[i+row*j];

This can be done normally over the domain, no problems:

newValue = array[indexof(out)];

But if we want to translate this:
normal code:
for (i = 0 ; i < row ; i++)
for(j = 0 ; j < col ; j++)
i = i+x;
j = j+y;
newValue = array[i+row*j];
// newValue = array[(i+x)+row*(j+y)];

In Brook+, the indexof() is going to return some value (one value).
There are "two" dimensions here but using a flattened 2D array (1D array) it appears there are going to be problems accessing the correct index in a gather (or scatter for that matter).

For instance, in CUDA you can simply use the x and y dimensions, just like you would in a nested for loop, but with Brook+ indexof() returns only value for a 1D stream.

Outcomes