   thrust::device_ptr<long long> keys(pkeys);
   thrust::device_ptr<unsigned int> vals(pvals);
   thrust::sort_by_key(keys, keys + N, vals);
+  cudaDeviceSynchronize();
   cudaError_t err = cudaGetLastError();
   return err;
 }

  storage.d_from_alt_storage = bflags;

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

  storage.d_from_alt_storage = bflags;

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