cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

riza_guntur
Journeyman III

Scatter kernel producing wrong result

I think those two kernel would producing same result but it is not

I wonder why?

kernel void calc_vec_ref_next( int row, float a, float kappa, float4 winner[][], float4 input_fuzzy_numbers[][], float4 vec_ref[][], out float4 vec_ref_next<>) { float4 temp0 = winner[1][1]; float4 fuzz1 = input_fuzzy_numbers[row][instance().x]; float4 fuzz2 = vec_ref[instance().y][instance().x]; if(temp0.z != fuzz2.w) { vec_ref_next = fuzz2; } else { float lRange = fuzz2.x - fuzz2.z; float rRange = fuzz2.y - fuzz2.x; vec_ref_next.w = fuzz2.w; if(temp0.x == 0.0f) { vec_ref_next.x = fuzz2.x; vec_ref_next.z = fuzz2.x - 1.1f * lRange; vec_ref_next.y = fuzz2.x + 1.1f * rRange; } else { float diff_mean = (1.0f - temp0.x)*(fuzz1.x - fuzz2.x)*a; if(fuzz1.w != fuzz2.w) { vec_ref_next.x = fuzz2.x - diff_mean; fuzz2.z = fuzz2.z - diff_mean; fuzz2.y = fuzz2.y - diff_mean; vec_ref_next.z = fuzz2.z + ( 1.0f - temp0.x )*( 1.0f - kappa )*lRange ; vec_ref_next.y = fuzz2.y - ( 1.0f - temp0.x )*( 1.0f - kappa )*rRange; } else { vec_ref_next.x = fuzz2.x + diff_mean; fuzz2.z = fuzz2.z + diff_mean; fuzz2.y = fuzz2.y + diff_mean; vec_ref_next.z = fuzz2.z - ( 1.0f - temp0.x )*( 1.0f - kappa )*lRange ; vec_ref_next.y = fuzz2.y + ( 1.0f - temp0.x )*( 1.0f - kappa )*rRange; } } } } kernel void calc_vec_ref_nexta( int row, float a, float kappa, float4 winner[][], float4 input_fuzzy_numbers[][], float4 vec_ref[][], out float4 vec_ref_next[][]) { float4 temp0 = winner[1][1]; float4 fuzz1 = input_fuzzy_numbers[row][instance().x]; int y = (int) temp0.z; float4 fuzz2 = vec_ref[instance().x]; float lRange = fuzz2.x - fuzz2.z; float rRange = fuzz2.y - fuzz2.x; vec_ref_next[instance().x].w = fuzz2.w; if(temp0.x == 0.0f) { vec_ref_next[instance().x].x = fuzz2.x; vec_ref_next[instance().x].z = fuzz2.x - 1.1f * lRange; vec_ref_next[instance().x].y = fuzz2.x + 1.1f * rRange; } else { float diff_mean = (1.0f - temp0.x)*(fuzz1.x - fuzz2.x)*a; if(fuzz1.w != fuzz2.w) { vec_ref_next[instance().x].x = fuzz2.x - diff_mean; fuzz2.z = fuzz2.z - diff_mean; fuzz2.y = fuzz2.y - diff_mean; vec_ref_next[instance().x].z = fuzz2.z + ( 1.0f - temp0.x )*( 1.0f - kappa )*lRange ; vec_ref_next[instance().x].y = fuzz2.y - ( 1.0f - temp0.x )*( 1.0f - kappa )*rRange; } else { vec_ref_next[instance().x].x = fuzz2.x + diff_mean; fuzz2.z = fuzz2.z + diff_mean; fuzz2.y = fuzz2.y + diff_mean; vec_ref_next[instance().x].z = fuzz2.z - ( 1.0f - temp0.x )*( 1.0f - kappa )*lRange ; vec_ref_next[instance().x].y = fuzz2.y + ( 1.0f - temp0.x )*( 1.0f - kappa )*rRange; } } }

0 Likes
3 Replies
gaurav_garg
Adept I

The first kernel is similar to second if

instance().y ==  winner[1][1]

Is that true?

The best way to find out these problems is to check with CPU beckend (set BRT_RUNTIME=cpu)

0 Likes

I found the answer. I haven't initialize vec_ref_next. At first it should be filled with vec_ref.

0 Likes

I'm wrong

It only update the first row

0 Likes