3 Replies Latest reply on Aug 24, 2009 7:17 AM by riza.guntur

    Scatter kernel producing wrong result

    riza.guntur

      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[y][instance().x]; float lRange = fuzz2.x - fuzz2.z; float rRange = fuzz2.y - fuzz2.x; vec_ref_next[y][instance().x].w = fuzz2.w; if(temp0.x == 0.0f) { vec_ref_next[y][instance().x].x = fuzz2.x; vec_ref_next[y][instance().x].z = fuzz2.x - 1.1f * lRange; vec_ref_next[y][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[y][instance().x].x = fuzz2.x - diff_mean; fuzz2.z = fuzz2.z - diff_mean; fuzz2.y = fuzz2.y - diff_mean; vec_ref_next[y][instance().x].z = fuzz2.z + ( 1.0f - temp0.x )*( 1.0f - kappa )*lRange ; vec_ref_next[y][instance().x].y = fuzz2.y - ( 1.0f - temp0.x )*( 1.0f - kappa )*rRange; } else { vec_ref_next[y][instance().x].x = fuzz2.x + diff_mean; fuzz2.z = fuzz2.z + diff_mean; fuzz2.y = fuzz2.y + diff_mean; vec_ref_next[y][instance().x].z = fuzz2.z - ( 1.0f - temp0.x )*( 1.0f - kappa )*lRange ; vec_ref_next[y][instance().x].y = fuzz2.y + ( 1.0f - temp0.x )*( 1.0f - kappa )*rRange; } } }