         __shared__ float sdabs1[25];
         __shared__ float sdabs2[25];
 
+        calc_dx_dy(sdx, sdy, featureX, featureY, featureSize, featureDir);
+        __syncthreads();
+
         const int tid = threadIdx.y * blockDim.x + threadIdx.x;
-
-        calc_dx_dy(sdx, sdy, featureX, featureY, featureSize, featureDir, tid);
-        __syncthreads();
 
         if (sdy[tid] >= 0)
         {

    }  

    __device__ void calc_dx_dy(float s_dx_bin[25], float s_dy_bin[25], 
        const float* featureX, const float* featureY, const float* featureSize, const float* featureDir, 
        int tid)
    {
        __shared__ float s_PATCH[6][6];


                    bestx = sumx;
                    besty = sumy;
                }
            }

            if (threadIdx.x == 0)
