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@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel