yarr

Could use some help with arrays

Discussion created by yarr on Jan 12, 2009
Latest reply on Jan 30, 2009 by genaganna
weird index behavior

Hello everyone!

Trying to get into brook+ GPU programming, I encountered a weird error with array indexes. Here's my test kernel:

kernel void testkernel(uint2 ker_in<>, uint ker_key[2], uint ker_s87[256], out uint2 ker_out<>)
{
 uint ker_n1, ker_n2, t, z, mhm;
 uint2 test;
 
 ker_n1 = (uint)ker_in.x;
 ker_n2 = (uint)ker_in.y;

 t = (ker_n1+ker_key[0]) & (uint)0xFFFFFFFF;
 mhm=t>>(uint)24 &(uint)255;
 z = ker_s87[mhm];

 test.x = z;
 test.y = mhm;
 ker_out = (uint2)test;
}

Everything works okay, except of the highlited part.
Somehow "z" just returns zero.

"mhm" itself returns proper values: from zero to 255, and also if I just manually substitute the index in the "z" expression, for example:

z = ker_s87[158];

I get proper result, with z returning the needed element.

I can't really understand what's wrong here and why doesnt it work in proper way. :(

Thanks in advance for any ideas or suggestions!

Outcomes