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:
[color="#000000"][code]
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;
}
[/code][/color]

But this fails:
[color="#000000"][code]
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;
}
[/code][/color]

[i]numDays [/i]is an input parameter from kernel, [i]matriz [/i]an internal 2D buffer, [i]value[/i] 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

#1
Posted 01/16/2012 10:33 AM   
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:
[color="#000000"][code]
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;
}
[/code][/color]

But this fails:
[color="#000000"][code]
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;
}
[/code][/color]

[i]numDays [/i]is an input parameter from kernel, [i]matriz [/i]an internal 2D buffer, [i]value[/i] 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

#2
Posted 01/16/2012 10:33 AM   
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.

[quote name='AJM88' date='16 January 2012 - 11:33 AM' timestamp='1326709982' post='1356614']
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:
[color="#000000"][code]
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;
}
[/code][/color]

But this fails:
[color="#000000"][code]
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;
}
[/code][/color]

[i]numDays [/i]is an input parameter from kernel, [i]matriz [/i]an internal 2D buffer, [i]value[/i] 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
[/quote]
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.



[quote name='AJM88' date='16 January 2012 - 11:33 AM' timestamp='1326709982' post='1356614']

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

#3
Posted 02/24/2012 12:32 AM   
Scroll To Top