|
8 | 8 | #' the OpenMP runtime library based on the installed Xcode version. These functions |
9 | 9 | #' mirror the logic described on the [macOS R Project OpenMP page](https://mac.r-project.org/openmp/) |
10 | 10 | #' and should be used by advanced users who wish to compile R packages |
11 | | -#' that use OpenMP for parallel processing. They are not required for most users.#' |
| 11 | +#' that use OpenMP for parallel processing. They are not required for most users. |
12 | 12 | #' |
13 | 13 | #' OpenMP runtime is downloaded from the R-project repository for macOS and installed to: |
14 | 14 | #' |
15 | 15 | #' - Library: `/usr/local/lib/libomp.dylib` |
16 | 16 | #' - Headers: |
17 | 17 | #' - `/usr/local/include/omp.h`; |
18 | | -#' - `/usr/local/include/ompt.h`; and, |
19 | | -#' - `/usr/local/include/omp-tools.h` |
| 18 | +#' - `/usr/local/include/ompt.h`; |
| 19 | +#' - `/usr/local/include/omp-tools.h`; and, |
| 20 | +#' - `/usr/local/include/ompx.h` (added in LLVM 19.1.0). |
20 | 21 | #' |
21 | 22 | #' **Note:** Apple has explicitly disabled OpenMP support in Xcode compilers, but the |
22 | 23 | #' runtime library can be installed separately and used with `-Xclang -fopenmp` |
@@ -70,31 +71,29 @@ openmp_version <- function() { |
70 | 71 | #' downloads the corresponding OpenMP runtime from the R-project repository: |
71 | 72 | #' |
72 | 73 | #' ```sh |
| 74 | +#' VERSION="19.1.0" |
| 75 | +#' |
73 | 76 | #' # Download the appropriate version |
74 | | -#' curl -O https://mac.r-project.org/openmp/openmp-VERSION-darwin20-Release.tar.gz |
| 77 | +#' curl -O https://mac.r-project.org/openmp/openmp-${VERSION}-darwin20-Release.tar.gz |
75 | 78 | #' |
76 | 79 | #' # Install to system directories |
77 | | -#' sudo tar fvxz openmp-VERSION-darwin20-Release.tar.gz -C / |
| 80 | +#' sudo tar fvxz openmp-${VERSION}-darwin20-Release.tar.gz -C / |
78 | 81 | #' ``` |
79 | 82 | #' |
80 | | -#' The installation includes: |
81 | | -#' |
82 | | -#' - `/usr/local/lib/libomp.dylib` - Main OpenMP runtime library |
83 | | -#' - `/usr/local/include/omp.h` - OpenMP API header |
84 | | -#' - `/usr/local/include/ompt.h` - OpenMP Tools interface header |
85 | | -#' - `/usr/local/include/omp-tools.h` - OpenMP Tools header |
86 | | -#' |
87 | 83 | #' ### Using OpenMP in R Packages |
88 | 84 | #' |
89 | | -#' After installation, you can enable OpenMP support in R packages by adding |
90 | | -#' the following to your `~/.R/Makevars` file: |
| 85 | +#' During installation, we will automatically configure your `~/.R/Makevars` |
| 86 | +#' file to include the necessary compiler flags for OpenMP support. |
91 | 87 | #' |
92 | 88 | #' ```sh |
| 89 | +#' # macrtools - OpenMP: start |
93 | 90 | #' CPPFLAGS += -Xclang -fopenmp |
94 | 91 | #' LDFLAGS += -lomp |
| 92 | +#' # macrtools - OpenMP: end |
95 | 93 | #' ``` |
96 | 94 | #' |
97 | | -#' Or install packages with: |
| 95 | +#' Alternatively, you can manually add the lines to your `~/.R/Makevars` file. |
| 96 | +#' Or, install packages from command line with: |
98 | 97 | #' |
99 | 98 | #' ```sh |
100 | 99 | #' PKG_CPPFLAGS='-Xclang -fopenmp' PKG_LIBS=-lomp R CMD INSTALL myPackage |
@@ -225,7 +224,7 @@ openmp_install <- function(password = base::getOption("macrtools.password"), ver |
225 | 224 | #' sudo rm -f /usr/local/include/ompx.h |
226 | 225 | #' ``` |
227 | 226 | #' |
228 | | -#' Note that `ompx.h` was included in LLVM 19.1.0 and |
| 227 | +#' **Note:** `ompx.h` was included in LLVM 19.1.0 and |
229 | 228 | #' may not exist in older OpenMP versions. |
230 | 229 | #' |
231 | 230 | #' @export |
|
0 commit comments