   print_GPU_Mat(deviceQueries, Q*D);
 */  
 
-
-
   compute_dist<<<gridSize, blockSize>>>(deviceData,deviceQueries,
                                           deviceDist,D,N);
 


  CUDA_CHECK(cudaMemcpy(dist, deviceDist, Q*N*sizeof(double), 
                        cudaMemcpyDeviceToHost));
/*
  int i, qi;

  for(qi=0; qi<Q; qi++){
    for(i=0; i<N; i++){  
      printf("qi = %d, i = %d, dist = %f\n", qi, i, dist[qi*N + i]);
    }
  }
*/

  cudaFree(deviceData); 
  cudaFree(deviceQueries);

  // Define cuda error
  cudaError_t cudaerr;

  // Define block size
  const int block_y_dim = MAX_THREADS/DIM_THREADS;
  dim3 blockSize(DIM_THREADS,block_y_dim);
 
  // Define grid size
  int num_blocks_x, num_blocks_y;

  // if number of 'data' D-dimensiona arrays are not equally divided by 
  // the number of data points per block (block_y_dim), then grid's
  // x dimension will have a block that doesn't compute the distance
  // between block_y_dim points.
  if (N%block_y_dim == 0)
    num_blocks_x = N/block_y_dim;
  else
    num_blocks_x = N/block_y_dim + 1;  
    
  num_blocks_y = Q; //= num_blocks_x/MAX_BLOCKS + 1;

  dim3 gridSize(num_blocks_x,num_blocks_y);

/*
  printf("Block size = (%d,%d), grid size = (%d,%d), D = %d, Q = %d, N = %d\n", 
          DIM_THREADS, block_y_dim, num_blocks_x, num_blocks_y, D, Q, N);
*/

  // Define and allocate the device space that will hold the appropriate data
