 	{
 		printf("m:%d, n:%d, k:%d\n", m, n, k);
 
+//		cudaMalloc((void **)&d_m, sizeof(int));
+//		cudaMalloc((void **)&d_n, sizeof(int));
+//		cudaMalloc((void **)&d_k, sizeof(int));
+//
+//		cudaMemcpy(d_m, &m, sizeof(int), cudaMemcpyHostToDevice);
+//		cudaMemcpy(d_n, &n, sizeof(int), cudaMemcpyHostToDevice);
+//		cudaMemcpy(d_k, &k, sizeof(int), cudaMemcpyHostToDevice);
+
 		V = (int *) malloc(m*n*sizeof(int));
 		out = (int *) malloc(m*k*sizeof(int));
+
+		cudaMalloc((void **)&d_V, m*n*sizeof(int));
+		cudaMalloc((void **)&d_out, m*k*sizeof(int));
+
 		for(i=0; i<m*n; i++)
 		{
 			fscanf(fp, "%d", &V[i]);
 		}
-		knn(m, n, k, V, out);
+		
+		cudaMemcpy(d_V, V, m*n*sizeof(int), cudaMemcpyHostToDevice);
+
+		knn<<<1,1>>>(m, n, k, d_V, d_out);
+
+		cudaMemcpy(out, d_out, m*k*sizeof(int), cudaMemcpyDeviceToHost);
+
 		for(i=0; i<m; i++)
 		{
 				for(j=0; j<k; j++)

	int sum;
	int count;
	int last_idx;
	for(i=0; i<m; i++)
	{
		temp = INIT_MAX;

			}
		}
	}
//	showResult(m, k, out);
}

//__host__ __device__ void showResult(int m, int k, int *out)
void showResult(int m, int k, int *out)
{
	int i,j;
	for(i=0; i<m; i++)
	{
		for(j=0; j<k; j++)
		{
				printf("%d", out[i*k+j]);
				if(j == k-1)
				{
						printf("\n");
				}
				else
				{
						printf(" ");
				}
		}
	} 
} 
int main(int argc, char *argv[]) 
{ 
	int m,n,k;
//	int *d_m, *d_n, *d_k;
	int i,j;
	int *V, *out;					//host copies
	int *d_V, *d_out;			//device copies
	FILE *fp;
	if(argc != 2)
	{
