 		cudaFree(d_V);
 		cudaFree(d_out);
 
+//		cudaFree(D);
+		cudaFree(dim_D);
+
 		free(V);
 		free(out);
 	}

		cudaMalloc((void **)&d_out, m*k*sizeof(int));

//		cudaMalloc((void **)&D, m*m*sizeof(int));

		for(i=0; i<m*n; i++)
		{

		
		cudaMemcpy(d_V, V, m*n*sizeof(int), cudaMemcpyHostToDevice);

		dim3 blk(m, m, n);
		knn<<<1, blk, m*m*sizeof(int)>>>(m, n, k, d_V, d_out, dim_D);

		cudaMemcpy(out, d_out, m*k*sizeof(int), cudaMemcpyDeviceToHost);

