Skip to content

Commit 1c81ae8

Browse files
committed
Fixed @hrbrmstr remarks, added OpenMP header inclusion example, fixed knitr chunk names
1 parent 1bfbd5c commit 1c81ae8

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

vignettes/Rcpp-FAQ.Rnw

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -444,34 +444,42 @@ To install XCode Command Line Tools, one must do the following:
444444
\item Open \texttt{Terminal} found in \texttt{/Applications/Utilities/}
445445
\item Type the following:
446446
<<osx_xcode,engine='bash', eval = F>>=
447-
xcode-select --install
447+
$ xcode-select --install
448448
@
449449
\item Press "Install" on the window that pops up.
450450
\item After the installation is complete, type the following in \texttt{Terminal} to ensure the installation was successful:
451451

452-
<<osx_xcode,engine='bash', eval = F>>=
453-
gcc --version
452+
<<osx_xcode_gcc,engine='bash', eval = F>>=
453+
$ gcc --version
454454
@
455455
\end{enumerate}
456456

457457
After major system's update, e.g. 10.11 to 10.12, you may need to accept the terms and licenses associated the the Xcode command line tools prior to being allowed to compile again.
458458

459459
To do so, open the \texttt{Terminal} found in \texttt{/Applications/Utilities/} and type:
460460

461-
<<osx_xcode,engine='bash', eval = F>>=
462-
git
461+
<<osx_xcode_git,engine='bash', eval = F>>=
462+
$ git
463463
@
464464

465465
Press spacebar to move down to the end of the file. There, you should see a prompt asking whether or not you accept the terms via either "Yes" or "No". Enter "Yes" if you agree to the terms to have the command line tools reactivated.
466466

467467
\subsubsection{Differing Mac OS X R Versions Leading to Binary Failures}
468468

469-
There are currently two distinct versions of R for OS X. The first version is a legacy version meant for Mac OS X 10.6 (Snow Leopard) - 10.8 (Mountain Lion). The second version is for more recent system Mac OS X 10.9 (Maverick), 10.10 (Yosemite), 10.11 (El Capitan). The distinction comes as a result of a change in the compilers shipped with the operating system. As a result, avoid sending package binaries if it is known that your collaborators are working on older systems as the R binaries for these two versions will not be able to mix.
469+
There are currently two distinct versions of R for OS X. The first version is a legacy version meant for Mac OS X 10.6 (Snow Leopard) - 10.8 (Mountain Lion). The second version is for more recent system Mac OS X 10.9 (Mavericks), 10.10 (Yosemite), 10.11 (El Capitan). The distinction comes as a result of a change in the compilers shipped with the operating system. As a result, avoid sending package binaries if it is known that your collaborators are working on older systems as the R binaries for these two versions will not be able to mix.
470470

471471
\subsubsection{No OpenMP Support}
472-
The OS X operating environment lacks the ability to parallelize sections of code using the \href{http://openmp.org/wp/}{OpenMP} standard. As a result, make sure to protect any parallelized sections of code with:
472+
The OS X operating environment lacks the ability to parallelize sections of code using the \href{http://openmp.org/wp/}{OpenMP} standard. As a result, make sure to protect any reference to OpenMP. In this case, protect the inclusion of headers with:
473+
474+
<<osx_openmp_header, engine="Rcpp", eval = F>>=
475+
#ifdef _OPENMP
476+
#include <omp.h>
477+
#endif
478+
@
479+
480+
And when one goes to parallelize portions of code use:
473481

474-
<<osx_openmp, engine="Rcpp", eval = F>>=
482+
<<osx_openmp_code, engine="Rcpp", eval = F>>=
475483
#ifdef _OPENMP
476484
// multithreaded OpenMP version of code
477485
#else
@@ -481,7 +489,7 @@ The OS X operating environment lacks the ability to parallelize sections of code
481489

482490
Doing so will enable the parallelization of the process on Linux and Windows. In the event that Apple enables OpenMP later on, this code will also allow for parallelization to occur.
483491

484-
The reason for the lack of OpenMP support is because the under OS X, you are not using the \texttt{gcc} compiler. Instead, all the requests are being redirected to \texttt{llvm}. As of LLVM 3.7, the \href{https://clang-omp.github.io/}{community initiative} to enable OpenMP has been merged into the \href{http://openmp.llvm.org/}{official branch}. Thus, there is hope in the next release of Xcode (around WWDC in June 2016) that OpenMP will work on OS X.
492+
The reason for the lack of OpenMP support is because under OS X, you are not using the \texttt{gcc} compiler. Instead, all the requests are being redirected to \texttt{llvm}. As of LLVM 3.7, the \href{https://clang-omp.github.io/}{community initiative} to enable OpenMP has been merged into the \href{http://openmp.llvm.org/}{official branch}. Thus, there is hope in the next release of Xcode (around WWDC in June 2016) that OpenMP will work on OS X.
485493

486494

487495
\subsubsection{Additional Information / Help}
@@ -492,7 +500,7 @@ Below are additional resources that provide information regarding compiling Rcpp
492500
\item A helpful post was provided by Brian Ripley regarding the use of compiling R code with OS X in April 2014 \href{https://stat.ethz.ch/pipermail/r-sig-mac/2014-April/010835.html}{on the \code{r-sig-mac} list}, which is generally recommended for OS X-specific questions and further consultation.
493501
\item Another helpful write-up for installation / compilation on OS X Mavericks is
494502
provided \href{http://www.bioconductor.org/developers/how-to/mavericks-howto/}{by the BioConductor project}.
495-
\item Lastly, another resource that exists for installation / compilation help is provided at \url{thecoatlessprofessor.com/programming/r-compiler-tools-for-rcpp-on-os-x/}.
503+
\item Lastly, another resource that exists for installation / compilation help is provided at \url{http://thecoatlessprofessor.com/programming/r-compiler-tools-for-rcpp-on-os-x/}.
496504
\end{enumerate}
497505

498506
\textbf{Note:} If you are running into trouble compiling code with RcppArmadillo, please also see \faq{q:OSXArma} listed below.

0 commit comments

Comments
 (0)