Discussion:
[Rcpp-devel] Parallel ANN search with openMPI
Xiaojie Qiu
2017-06-06 22:22:10 UTC
Permalink
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;*
Qiang Kou
2017-06-07 01:19:16 UTC
Permalink
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
Post by Xiaojie Qiu
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.
*** 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
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
Qiang Kou
***@umail.iu.edu
School of Informatics and Computing, Indiana University
Loading...