 __global__ void bitonicSort(const T *pts, T *newpts) {
   int scale = blockIdx.x;
 
-  __shared__ struct sortstruct_t shm[8 * BitonicSortThreads];
+  __shared__ struct sortstruct_t shm[8192];
 
   int first = scale == 0 ? 0 : d_ExtremaIdx[scale - 1];
   int last = d_ExtremaIdx[scale];

  }
}

#define FindNeighborsThreads 512
__global__ void FindNeighbors(cv::KeyPoint *pts, short *kptindices, int width) {
  __shared__ int gidx[1];

  // which scale?
  int scale = pts[blockIdx.x].class_id;

  int cmpIdx = scale < 2 ? 0 : d_ExtremaIdx[scale - 2];

  float size = pts[blockIdx.x].size;



  for (int i = 0; i < desc_query.rows; ++i) {
    std::vector<cv::DMatch> tdmatch;
    //std::cout << dmatches_h[2*i].trainIdx << " - " << dmatches_h[2*i].queryIdx << std::endl;
    tdmatch.push_back(dmatches_h[2 * i]);
    tdmatch.push_back(dmatches_h[2 * i + 1]);
    dmatches.push_back(tdmatch);
