AnsweredAssumed Answered

Finding minimum of square of difference between two arrays

Question asked by shunyo on Mar 30, 2014
Latest reply on Apr 4, 2014 by sudarshan


I have been trying to execute a simple kernel but it returns garbage values and I am unable to figure why. I want to find the closest set of planes from a given plane set using the angles between the planes. So, the criteria is to find the minimum of the square of the difference of the corresponding angles. In this case, the correct answer should be given as the planes which have near similar orientation. I am getting the desirable answer in CPU. But when I am sending it to kernel, it sends out a different answer not consistent with my calculations.


__kernel void getTransformation( __global uint* permut1, __global float2* dot1,__global int4* combo1, __global float2* dot2,__global int4* combo2, , int size1, int size2, __global float4* trans)
  int gid = get_global_id(0);
  float2 temp_dot;
  float min_dot = FLT_MAX;
  int ind = 0;
  for(int i=0;i<size2;i++)
  temp_dot = (dot2[i].x - dot1[permut1[gid]].x,dot2[i].y - dot1[permut1[gid]].y);
  if((temp_dot.x*temp_dot.x + temp_dot.y*temp_dot.y) < min_dot)
  min_dot = temp_dot.x*temp_dot.x + temp_dot.y*temp_dot.y;
  ind = i;
  float4 num_pl2 = combo2[ind];
  trans[gid] = convert_float4_rtp(num_pl2);