<font color='black' size='2' face='arial'>

<div> <font size="2">Hi everyone and thank you for your advice.<br>
<br>
Seems like a possible solution for the problem on OS X Mavericks is as follows:<br>
    1. Install clang-omp,<br>
          If you use homebrew as a package management system, insert in terminal<br>
                brew install clang-omp<br>
    2. Change the content of the your_home_directory/.R/Makevar file (say, using OS X built-in nano editor) from the default content<br>
            CC=clang<br>
            CXX=clang++<br>
<br>
to<br>
<br>
        CC=clang-omp<br>
        CXX=clang-omp++<br>
        CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion<br>
        CXXFLAGS=</font><font size="2">-mtune=native -g -O2 -Wall -pedantic -Wconversion<br>
        FLIBS=lgfortran<br>
<br>
Once this is done, the OpenMP works on OS X Mavericks.<br>
<br>
Say, on my MacBook Pro 8,3 ( with 4 physical cores and 8 logical ones), Intel Core i7, 2.3 Ghz, L2 Cache (per core) 256 kB, L3 Cache 8 MB,<br>
        the simple test function function omp_test<br>
<br>
#include <RcppArmadillo.h><br>
#include <math.h><br>
#include <omp.h><br>
#include<map><br>
#include<vector><br>
#include<random><br>
<br>
//[[Rcpp::plugins(openmp)]]<br>
//[[Rcpp::depends(RcppArmadillo)]]<br>
<br>
// [[Rcpp::export]]<br>
long omp_test(int nn) {<br>
  long m = 0;<br>
  omp_set_num_threads(8);<br>
  #pragma omp parallel for schedule(auto)<br>
  for(int i = 1; i < nn; ++i) {<br>
    m = m + log(i);<br>
  }<br>
<br>
  Rcpp::Rcout << "m is: " << m << std::endl;<br>
  return(m);<br>
}<br>
<br>
     with nn = 1,000,000,000 run from R with<br>
R> ptc <- Sys.time()<br>
R> b <- ala(1000000000)<br>
R> print(Sys.time() - ptc)<br>
<br>
<br>
runs for 10.75 sec with 1 thread <br>
              3.6 sec with 4 threads </font><font size="2"><font size="2">(speadup = 3)</font>              <br>
              2.5 sec with 8 threads (speedup = 4.3)<br>
<br>
Again, thank you all for your prompt and competent advice.<br>
<br>
Anguel<br>
<br>
</font>
</div>



<div> <br>

</div>



<div> <br>

</div>



<div style="font-family:helvetica,arial;font-size:10pt;color:black">-----Original Message-----<br>

From: aakremena <aakremena@aol.com><br>

To: krthornt <krthornt@uci.edu>; rcpp-devel <rcpp-devel@r-forge.wu-wien.ac.at><br>

Sent: Mon, Mar 14, 2016 11:55 am<br>

Subject: Fwd: [Rcpp-devel] fatal error: 'omp.h' file not found<br>

<br>






<div id="AOLMsgPart_2_cb7fe3be-4c7f-4b4f-864a-05238bbd02d8">


<div class="aolReplacedBody"><font face="arial" color="black" size="2">



<div> <font size="2">Sorry,<br>


<br>


I guess James' e-mail contains some directions, albeit not for RStudio specifically.  I'll try them.<br>


<br>


Thanks.<br>


<br>


Anguel<br>


</font>
</div>







<div> <br>



</div>







<div> <br>



</div>







<div style="font-family:helvetica,arial;font-size:10pt;color:black">-----Original Message-----<br>



From: aakremena <<a href="mailto:aakremena@aol.com">aakremena@aol.com</a>><br>



To: krthornt <<a href="mailto:krthornt@uci.edu">krthornt@uci.edu</a>>; rcpp-devel <<a href="mailto:rcpp-devel@r-forge.wu-wien.ac.at">rcpp-devel@r-forge.wu-wien.ac.at</a>><br>



Sent: Mon, Mar 14, 2016 11:45 am<br>



Subject: Re: [Rcpp-devel] fatal error: 'omp.h' file not found<br>



<br>










<div id="AOLMsgPart_2_00eef198-3abd-4ba5-9737-6ad2472cefdd">




<div class="aolReplacedBody"><font face="arial" color="black" size="2">H<font size="2">i James and Kevin,<br>




<br>




Thank you very much for the advices (I'll try James' directions shortly).<br>




<br>




But I have already installed clang-omp via<br>




<br>




                    $ brew install clang-omp<br>




<br>




The compiler is available at /usr/local/Library/Formula/clang-omp.rb<br>




<br>




<br>




Can I ask you for some directions as to how to configure clang-omp with RStudio (if possible), i.e. how to make R recognize clang-omp?<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: Kevin Thornton <<a target="_blank" href="mailto:krthornt@uci.edu">krthornt@uci.edu</a>><br>





To: <a target="_blank" href="mailto:rcpp-devel@lists.r-forge.r-project.org">rcpp-devel@lists.r-forge.r-project.org</a> <<a target="_blank" href="mailto:rcpp-devel@r-forge.wu-wien.ac.at">rcpp-devel@r-forge.wu-wien.ac.at</a>><br>





Sent: Mon, Mar 14, 2016 11:33 am<br>





Subject: Re: [Rcpp-devel] fatal error: 'omp.h' file not found<br>





<br>












<div id="AOLMsgPart_1.2_41d0a9e5-f2e8-4883-8d23-6b07f72dc42f">






<div class="aolReplacedBody">





<div dir="ltr">One may also use clang-omp from Homebrew if you wish to still use clang on OS X, but have OpenMP.





<div><br>





</div>











<div>--Kevin<br>





<br>











<div class="gmail_quote">





<div dir="ltr">On Mon, Mar 14, 2016 at 9:31 AM Balamuta, James Joseph <<a target="_blank" href="mailto:balamut2@illinois.edu">balamut2@illinois.edu</a>> wrote:<br>





</div>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">











<div lang="EN-US">






<div>






<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Greetings and Salutations,<u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">OS X does not currently support OpenMP under the default compiler (clang). Hence, you are receiving an error as it relates to the header file not being found. For more details,
 see:<u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><a target="_blank" href="https://cran.r-project.org/doc/manuals/r-release/R-exts.html%23OpenMP-support">https://cran.r-project.org/doc/manuals/r-release/R-exts.html#OpenMP-support</a><u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Support for OpenMP with clang should be arriving sometime in June after WWDC as the intel funded clang-OpenMP feature has been merged into the main clang branch. (
<a target="_blank" href="http://openmp.llvm.org/">http://openmp.llvm.org/</a> , <a target="_blank" href="https://clang-omp.github.io/">
https://clang-omp.github.io/</a> )<br>






<br>






If this is just for personal use, you may wish to set the ~/.R/Makevar information for R via:<br>






<br>






<a target="_blank" href="https://cran.r-project.org/doc/manuals/r-release/R-admin.html#OS-X-packages">https://cran.r-project.org/doc/manuals/r-release/R-admin.html#OS-X-packages</a><u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><br>






VER=-4.8 <u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">CC=gcc$(VER)<u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">CXX=</span>
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif">g++$(VER)<u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion<u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion<u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">FLIBS=-lgfortran<u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Sincerely,<u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">JJB<u></u><u></u></span></div>












<div class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></div>












<div class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <a target="_blank" href="mailto:rcpp-devel-bounces@lists.r-forge.r-project.org">rcpp-devel-bounces@lists.r-forge.r-project.org</a> [mailto:<a target="_blank" href="mailto:rcpp-devel-bounces@lists.r-forge.r-project.org">rcpp-devel-bounces@lists.r-forge.r-project.org</a>]
<b>On Behalf Of </b><a target="_blank" href="mailto:aakremena@aol.com">aakremena@aol.com</a><br>






<b>Sent:</b> Monday, March 14, 2016 10:01 AM<br>






<b>To:</b> <a target="_blank" href="mailto:rcpp-devel@lists.r-forge.r-project.org">rcpp-devel@lists.r-forge.r-project.org</a><br>






<b>Subject:</b> [Rcpp-devel] fatal error: 'omp.h' file not found<u></u><u></u></span></div>





</div>





</div>











<div lang="EN-US">





<div>






<div class="MsoNormal"><u></u> <u></u></div>












<div class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:black">Dear Rcpp development list members,<br>






<br>






I am trying to use OpenMP with Rcpp.  The code (placed in omp_experiment.cpp file) is pretty basic:<br>






<br>






#include <RcppArmadillo.h><br>






#include <omp.h><br>






<br>






//[[Rcpp::plugins(openmp)]]<br>






//[[Rcpp::depends(RcppArmadillo)]]<br>






using namespace Rcpp;<br>






<br>






// [[Rcpp::export]]<br>






int timesTwo(int x) {<br>






   return x * 2;<br>






}<br>






<br>






<br>






<br>






Once I try to compile the file I get the error output<br>






<br>






clang: warning: argument unused during compilation: '-fopenmp'<br>






omp_experiment.cpp:2:10: fatal error: 'omp.h' file not found<br>






#include <omp.h><br>






         ^<br>






1 error generated.<br>






make: *** [omp_experiment.o] Error 1<br>






clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include  -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/RcppArmadillo/include"
 -I"/Users/anguelgrigorov/Documents/Business/MISO/R/Functions/Trading/Experiments"   -fopenmp  -fPIC  -Wall -mtune=core2 -g -O2  -c omp_experiment.cpp -o omp_experiment.o<br>






Error in Rcpp::sourceCpp("Documents/Business/MISO/R/Functions/Trading/Experiments/omp_experiment.cpp") :
<br>






  Error 1 occurred building shared library.<br>






<br>






<b>My QUESTION: How to configure OpenMP to work with Rcpp on my system?</b><br>






<br>






I am working with RStudio, version 0.98.945 on Mac OS X Mavericks.<br>






<br>






Every insight into this will be highly appreciated.<br>






<br>






Thank you very much in advance.<br>






<br>






Anguel<br>






<br>






<br>






P.S. I've done some reading on the Internet that advised me to check whether omp.h is even available on my laptop (MacBook Pro).  I have used OS X
<br>






        locate "omp.h" command that proved that omp.h is indeed available in 4 locations:<br>






<br>






/usr/local/Cellar/gcc/5.3.0/lib/gcc/5/gcc/x86_64-apple-darwin13.2.0/5.3.0/include/omp.h<br>






/usr/local/Cellar/gcc6/6-20160124/lib/gcc/6/gcc/x86_64-apple-darwin13.2.0/6.0.0/include/omp.h<br>






/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/include/omp.h<br>






/usr/local/lib/gcc/x86_64-apple-darwin13.1.0/4.9.0/include/omp.h</span><u></u><u></u></div>






</div>





</div>







_______________________________________________<br>






Rcpp-devel mailing list<br>






<a target="_blank" href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>






<a rel="noreferrer" target="_blank" href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></blockquote></div>





</div>





</div>






</div>






</div>






_______________________________________________<br>





Rcpp-devel mailing list<br>





<a target="_blank" href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>





<a target="_blank" href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></div>





</font></div>




</div>







</div>



</font></div>


</div>





</div>

</font>