[Rcpp-devel] Parallel ANN search with openMPI

Xiaojie Qiu xqiu at uw.edu
Wed Jun 7 00:22:10 CEST 2017


Hi Rcpp friends,

I have a question regarding to parallel my rcpp code for KNN querying. I
used ANN c++ package and the following is a test code related to the code
for the querying. I can run through the code when I don' use the openMP.
But I get error like the following when I use it :

 *** caught illegal operation ***
address 0x1128e667d, cause 'illegal opcode'

I have a few questions, 1. what are the potential errors I made in the
following code?  2. do we need to require the annkSearch function
be thread-safe in order to use openMP here? 3. If  we cannot use openMP
here because annkSearch is not thread-safe, can we use RcppParallel here?

Thanks a lot,

*ANNpoint pq;*
*  pq = annAllocPt(d);*
*  int i, j;*
*  nn_idx    = new ANNidx[k];    // Allocate near neigh indices*
*  dists    = new ANNdist[k];   // Allocate near neighbor dists*
*  omp_set_num_threads(3);*
*  for(j = 0; j < d; j++)*
*  {*
*    pq[j]=data[ d_ptr[j]++ ];*
*  }*

*  // ------------ test kdtree search loop:   ------------ *
*  Rcout << "before search 1" << std::endl;*
*  #pragma omp parallel for shared(the_tree, k, error_bound) private(i, pq,
nn_idx, dists)*
*  for(i = 0; i < 3; i ++)*
*  { *
*    if(i == 2){*
*      the_tree->annkSearch( // search*
*          pq, // query point*
*          k,    // number of near neighbors*
*          nn_idx,   // nearest neighbors (returned)*
*          dists,    // distance (returned)*
*          error_bound); // error bound*
*    }*
*  }*
*  Rcout << "end search 1" << std::endl;*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170606/b83ce795/attachment.html>


More information about the Rcpp-devel mailing list