<font color='black' size='2' face='arial'>Di<font size="2">rk,<br>
<br>
Thanks for the quick reply.<br>
<br>
Just to let you know that <br>
1. When I replace Rcout with cout, the nof function is running just fine<br>
<b>Why is Rcout messing up</b>?<br>
2. When omp_set_num_threads is explicitly declared before the void nof(int nn_thrds) function, the diagnostic warnings disappear. <br>
Why? I thought these function WERE already explicitly declared in the omp.h header file... What am I missing?<br>
<br>
Thank you in advance.<br>
<br>
Anguel<br>
</font>
<div> <br>
</div>
<div> <br>
</div>
<div> <br>
</div>
<div style="font-family:helvetica,arial;font-size:10pt;color:black">-----Original Message-----<br>
From: Dirk Eddelbuettel <edd@debian.org><br>
To: aakremena <aakremena@aol.com><br>
Cc: rcpp-devel <rcpp-devel@lists.r-forge.r-project.org><br>
Sent: Sat, Mar 19, 2016 1:45 pm<br>
Subject: Re: [Rcpp-devel] OpenMP/Rcpp Error: C stack usage is too close to the limit<br>
<br>
<br>
On 19 March 2016 at 14:11, <a href="mailto:aakremena@aol.com">aakremena@aol.com</a> wrote:<br>
| Dear Rcpp Developer List subscribers,<br>
| <br>
| I am experimenting with OpenMP on Rcpp. Here is a simple program I'm trying to<br>
| run on my (4-core MacBookPro 8,3, Intel Cor i7, 2.3 GHz) computer (clang-omp<br>
| compiler):<br>
| <br>
| #include <RcppArmadillo.h><br>
| #include <math.h><br>
| #ifdef _OPENMP<br>
| #include <omp.h><br>
| #endif<br>
| #include<map><br>
| #include<vector><br>
| #include<random><br>
| <br>
| //[[Rcpp::plugins(openmp)]]<br>
| //[[Rcpp::depends(RcppArmadillo)]]<br>
| using namespace Rcpp;<br>
| using namespace arma;<br>
| <br>
| <br>
| // [[Rcpp::export]]<br>
| void nof(int nn_thrds)<br>
| {<br>
| omp_set_num_threads(nn_thrds);<br>
| #pragma omp parallel for<br>
| for(int i = 0; i < 100; i++) {<br>
| #pragma omp critical<br>
| {<br>
| Rcout << i << std::endl;<br>
| }<br>
| }<br>
| }<br>
| <br>
| /***R<br>
| nof(2)<br>
| */<br>
| <br>
| PROBLEMS:<br>
| 1. (Minor): Diagnostics message use of undeclared identifier<br>
| omp_set_num_threads,<br>
<br>
So you don't declare OMP correct.<br>
<br>
| 2. (Major): The program terminates the R session with<br>
| R Session Aborted<br>
| R encountered a fatal error<br>
| The session was terminated<br>
| <br>
| Sometimes I receive the messages<br>
| Error C stack is too close to the limit<br>
| Error during wrapup: C stack usage is too close to the limit<br>
| Type Error: 'null' is not an object (evaluating 'c[a]')<br>
<br>
That means you are messing your calls up and the stack does not get<br>
unwound. Simplify.<br>
<br>
| I use RStudio 0.99.893<br>
<br>
Irrelevant.<br>
<br>
| QUESTIONS:<br>
| 1. What is going on?<br>
<br>
You have bugs.<br>
<br>
| 2. Is there any legible description of such error messages on the Internet?<br>
| --I mean, they seem way too cryptic to me...<br>
<br>
At least the resources are free...<br>
<br>
Dirk<br>
<br>
<br>
| Thank you in advance.<br>
| <br>
| Anguel<br>
| _______________________________________________<br>
| Rcpp-devel mailing list<br>
| <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
| <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
<br>
-- <br>
<a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
</div>
</font>