Hi, All.
I am programming kernel which moves like gatherOP/scatterOP.
but, scatter kernel doesn't move well.
example program:
kernel void sub(float a<>, out float b<>{
b = a - 100;
}
kernel void gather(float test_index<>, float input1D[], out float gather_data<>{
gather_data = input1D[test_index];
}
kernel void scatter(float test_index<>, float gather_data<>, out float4 outpu1D[]){
output1D[test_index] = gather_data;
}
......
for(i=0;i<4;i++){
int index = i * Width;
test_index = index;
}
......
float stream_index<4>;
float gather<4>;
float temp<4>;
float input1D<Length>;
streamRead(input1D, input_data);
streamRead(stream_index, test_index);
gather(stream_index, input1D, gather);
sub(gather, temp);
scatter(stream_index,temp,input1D);
streamWrite(input1D, input_data
The result which executed this program is the next.
./test -x 4 -y 4
input1D:
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00
test_index:
0 4 8 12
gather:
0.00 4.00 8.00 12.00
temp:
-100.00 -96.00 -92.00 -88.00
input_data:
-100.00 -100.00 -100.00 -100.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00
Movement of scatter kernel is strange.
I expect the following result.
input_data:
-100.00 1.00 2.00 3.00 -96.00 5.00 6.00 7.00 -92.00 9.00 10.00 11.00 -88.00 13.00 14.00 15.00
But I don't knowthe cause of this problem.
Do you know what this problem is?
sorry, me poor english.
thank you.
Hi Ceq, I'm sorry that a res is late.
Thank you very much for your advice!
it moved program by your advice.
but, when the value of index is less than 4, and
when the number of index is less than 4, that didn't move well.
so, I settled this problem by the next program.
kernel void scatter(float index<>, float input<>, out float4 out[]){
float m = index%4.0f;
float d = index/4.0f;
if(m==0 || d==0) out
else if(m==1 || d==0.25) out
else if(m==2 || d==0.5) out
else if(m==3 || d==0.75) out
}
but, when the value of index is 0, that didn't move well.
example:
./test -x 8 -y 8
input1D:
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00
test_index:
0.00 1.00 2.00 3.00 4.00
gather_data:
0.00 1.00 .2.00 3.00 4.00 -2.00
temp:
-100.0 -101.0 -102.0 -103.0 -104.0 -2.00
input_data:
-2.00 -101.0 -102.0 -103.0 -104.0 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00
this problems cant't be settled.
Do you know what this problem is?
Thank you.