Loop error

I have an strange error.

I want to fill one array, but only a piece of it. If I do the loop with constant variables works correctly but with a value in a parameter doesn’t work.

This code works:

for(int day=0; day<5; day++){

	if(single){

             for(int p=0; p<PAX; p++)

		matriz[p][d].value = value;

        }else

             matriz[0][d].value = value;

}

But this fails:

for(int day=0; day<numDays; day++){

	if(single){

             for(int p=0; p<PAX; p++)

		matriz[p][d].value = value;

        }else

             matriz[0][d].value = value;

}

numDays is an input parameter from kernel, matriz an internal 2D buffer, value is a float, and single is a simplification from a more complicate operation.

I running on nvidia gts 450.

I’m getting crazy with this issue.

Edited: I tried the same code on CPU and the output was correct

I have an strange error.

I want to fill one array, but only a piece of it. If I do the loop with constant variables works correctly but with a value in a parameter doesn’t work.

This code works:

for(int day=0; day<5; day++){

	if(single){

             for(int p=0; p<PAX; p++)

		matriz[p][d].value = value;

        }else

             matriz[0][d].value = value;

}

But this fails:

for(int day=0; day<numDays; day++){

	if(single){

             for(int p=0; p<PAX; p++)

		matriz[p][d].value = value;

        }else

             matriz[0][d].value = value;

}

numDays is an input parameter from kernel, matriz an internal 2D buffer, value is a float, and single is a simplification from a more complicate operation.

I running on nvidia gts 450.

I’m getting crazy with this issue.

Edited: I tried the same code on CPU and the output was correct

I understand the situation you are in :–)

Looking at you code, I noticed the only difference is the numDays variable for the loop. What is the data-type of this? I assume int. Try some knee-jerk solutions like casting it to int, or writing it’s value to a “point” on your matriz array which you can fetch later. Then confirm from the CPU side whether numDays is the real value you intended it to be. If it is not int, you can check out the rounding options in opencl specification.