Statically allocated local variables as arguments for functions

Hi,

I’ve been working on some image analysis algorithms lately and ran into an interesting problem when I decided to clean up my code some. The image data is loaded into a statically allocated shared two-dimensional array for improved access times. However, since i’m performing multiple calculations for each thread (with varying offsets and inputs) I decided to move them to an inline function to make the code more manageable. Part of this means passing the statically allocated array as an argument to the function, however the usual C S == **S array argument conversion does not seem to apply. In fact, the compiler gives me the following interesting error:

__local uchar S_l[LOCAL_HEIGHT*2 + 2][LOCAL_WIDTH*2 + 2];

inline float calc_energy_abs_diff(uchar org_v, uchar origin_x, uchar origin_y, __local uchar ** S_l);

...

warning: incompatible pointer types passing 'uchar __attribute__((address_space(3)))[10][66]', expected 'uchar __attribute__((address_space(3)))**'

				 float energy = calc_energy_abs_diff(offset,1,0,S_l);

It cannot possibly be trying to pass the entire chunk of memory of S_l on top of the stack now can it? Using the & operator just yielded uchar attribute((address_space(3)))*[10][66] as type instead, so the size of the array and the fact that it IS an array seems to be encoded into it’s type.

Anyway, I’d love to know what might be causing this (it seems I’ve misunderstood some crucial part of the OpenCL specification) and any help is welcome.

[font=“Courier New”]uchar ** S_l[/font] is a pointer to a pointer, not a two-dimensional array. Use font=“Courier New”[LOCAL_HEIGHT2 + 2][LOCAL_WIDTH2 + 2][/font] in your function prototype instead.

[font=“Courier New”]uchar ** S_l[/font] is a pointer to a pointer, not a two-dimensional array. Use font=“Courier New”[LOCAL_HEIGHT2 + 2][LOCAL_WIDTH2 + 2][/font] in your function prototype instead.

So the pointer/array equivalence in function arguments does not hold then I take it. Oh well, thank you.

So the pointer/array equivalence in function arguments does not hold then I take it. Oh well, thank you.