[Rcpp-devel] Parallel ANN search with openMPI

Qiang Kou qkou at umail.iu.edu
Wed Jun 7 03:19:16 CEST 2017


Hi, Xiaojie,

Please provide a reproducible example. I am afraid it is very hard to help
with just a small code snippet.

Best,

Qiang Kou

On Tue, Jun 6, 2017 at 6:22 PM, Xiaojie Qiu <xqiu at uw.edu> wrote:

> 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;*
>
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>



-- 
Qiang Kou
qkou at umail.iu.edu
School of Informatics and Computing, Indiana University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170606/d224fd89/attachment.html>


More information about the Rcpp-devel mailing list