use pointer in kernel code

hi, i would like to optimize the code of my algorithm trying to use pointers.
in my code i have a cycle within which the calculation always an expression.


__kernel void cicle(__global uchar * in, __global float * out, int w, int h)
{

int x = get_global_id(0);
float pix = 0;

...

for (int i = 0; i< h; i++)
{
...
     pix = in[x+i*w];
...
}

...

}

how can I use pointers to not always calculate the expression in the for cycle?

Thank you

Have you considered using a 2D range instead of a 1D range? From the little source code you have shown it looks like you are operating on an image.

All you have to do is specify two dimensions when you call clEnqueueNDRangeKernel.

grazie per avermi risposto. Sto elaborando una immagine, però invece di utilizzare un 2d, sto utilizzo 1d.

I would not expect that computing that expression is your bottleneck. Modern processors have cycles to spare and are usually bandwidth bound instead. I would suggest focusing on making your loading/storing to memory more efficient before you worry about saving a few math operations.