parallel version of doKNNSearch