   storage.d_from_alt_storage = bflags;
 
   sorter.EnactSort(storage);
+  cudaDeviceSynchronize();
   cudaError_t err = cudaGetLastError();
   return err;
 }

  storage.d_from_alt_storage = bflags;

  sorter.EnactSort(storage);
  cudaError_t err = cudaGetLastError();
  return err;
}

    thrust::device_ptr<unsigned int> vals(pvals+i*nrows);
    thrust::sort_by_key(keys, keys + nrows, vals);
  }
  cudaDeviceSynchronize();
  cudaError_t err = cudaGetLastError();
  return err;
}
