 	{
         if (idx == 0) {
 		    x_new = x;
-            cudaDeviceSynchronize();
         }
         __syncthreads();
         if (idx < x_new.n)

            if (idx == 0) {
			    x_new = x;
			    g_new.clear(); //dkoes - set gradient to zero
                cudaDeviceSynchronize();
            }
            //TODO: unnecessary? are memset calls issued to the default stream?
			return 0;
		}
		else if (f1 <= f0 + ALF * alpha * slope)


        if (threadIdx.x == 0) {
		    y = g_new;
            // Update line direction
		    subtract_change(y, g, n);

		    prevf0 = f0;
		    f0 = f1;
		    x = x_new;
        }

		if (params.early_term)
