<div dir="ltr">Hi, Xiaojie,<div><br></div><div>Please provide a reproducible example. I am afraid it is very hard to help with just a small code snippet.</div><div><br></div><div>Best,</div><div><br></div><div>Qiang Kou</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 6, 2017 at 6:22 PM, Xiaojie Qiu <span dir="ltr"><<a href="mailto:xqiu@uw.edu" target="_blank">xqiu@uw.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Rcpp friends, </div><div><br></div><div>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 : </div><div><div><br></div><div> *** caught illegal operation ***</div><div>address 0x1128e667d, cause 'illegal opcode'</div></div><div><i><br></i></div><div>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? </div><div><br></div><div>Thanks a lot, </div><div><br></div><div><i>ANNpoint pq;</i></div><div><i>  pq = annAllocPt(d);</i></div><div><i>  int i, j;</i></div><div><i>  nn_idx    = new ANNidx[k];    // Allocate near neigh indices</i></div><div><i>  dists    = new ANNdist[k];   // Allocate near neighbor dists</i></div><div><i>  omp_set_num_threads(3);</i></div><div><i>  for(j = 0; j < d; j++)</i></div><div><i>  {</i></div><div><i>    pq[j]=data[ d_ptr[j]++ ];</i></div><div><i>  }</i></div><div><i><br></i></div><div><i>  // ------------ test kdtree search loop:   ------------ </i></div><div><i>  Rcout << "before search 1" << std::endl;</i></div><div><i>  #pragma omp parallel for shared(the_tree, k, error_bound) private(i, pq, nn_idx, dists)</i></div><div><i>  for(i = 0; i < 3; i ++)</i></div><div><i>  { </i></div><div><i>    if(i == 2){</i></div><div><i>      the_tree->annkSearch( // search</i></div><div><i>          pq, // query point</i></div><div><i>          k,    // number of near neighbors</i></div><div><i>          nn_idx,   // nearest neighbors (returned)</i></div><div><i>          dists,    // distance (returned)</i></div><div><i>          error_bound); // error bound</i></div><div><i>    }</i></div><div><i>  }</i></div><div><i>  Rcout << "end search 1" << std::endl;</i></div><div><br></div><div><br></div></div>
<br>______________________________<wbr>_________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-<wbr>project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-<wbr>project.org/cgi-bin/mailman/<wbr>listinfo/rcpp-devel</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Qiang Kou<div><a href="mailto:qkou@umail.iu.edu" target="_blank">qkou@umail.iu.edu</a><br><div>School of Informatics and Computing, Indiana University</div><div><br></div></div></div></div>
</div>