PDA

View Full Version : strange array problem



katerpillar801
07-19-2011, 08:33 AM
I have this method:

kernel void myKern(global int* paiOut) // real function has more parameters

inside of the method, I have this:


int aiTravel[11514];
aiTravel[0] = 0;
int iTravels = 1;

I have a while-loop to fill the "aiTravel"-array with numbers.. it doesn't return error, but the while-loop's "break"-function is supposed to go off depending on the number from "aiTravel[x]". it doesn't ever break, and it loops forever.

anyway, I think the problem is that aiTravel[x] is returning wrong numbers, I did this test:


paiOut[0] = iTravels;
paiOut[1] = aiTravel[iTravels];
paiOut[2] = aiTravel[2];
break;

then I print these values from c#:
paiOut[0] = 2
paiOut[1] = 2
paiOut[2] = -1


why is paiOut[1] different compared to paiOut[2] ?


I can try to make a complete, simpler kernel to try to reproduce the problem and post full code if you don't understand it. The kernel I am currently using is very big

Maxim Milakov
07-19-2011, 08:55 AM
Did I get you right? You are allocating aiTravel[11514] array as private variable?

katerpillar801
07-19-2011, 09:19 AM
Did I get you right? You are allocating aiTravel[11514] array as private variable?

yes

Maxim Milakov
07-19-2011, 10:41 AM
Did I get you right? You are allocating aiTravel[11514] array as private variable?

yes

Well, I cannot say anything on the issue you initially specified but allocating 44KB private memory buffer is just not workable for GPUs. Register resources are scarse in these devices. Compiler might spill excessive register allocations to global memory (with dramatic reduction in kernel execution speed), but only up to some limit. 44KB is just overkill.