Skip to content

Commit 0828e75

Browse files
authored
Further macOS OpenMP tweaks (#497)
* Plugin uses "$(SHLIB_OPENMP_CFLAGS)" on macOS too, simplifies opnemp * Silence whining on windows and limit it to legacy * Generalize OpenMP setup under macos as suggested by @coatless * Refinements from code review * Reword one DEFINE as discussed
1 parent 34bb9a9 commit 0828e75

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2025-11-13 Dirk Eddelbuettel <edd@debian.org>
2+
3+
* R/inline.R (inlineCxxPlugin): No longer special-case macOS for
4+
OpenMP but rely on "$(SHLIB_OPENMP_CFLAGS)" as everywhere else
5+
6+
* inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in:
7+
Refine macOS OpenMP detection, respect RCPPARMADILLO_MACOS_DISABLE_OPENMP
8+
9+
* inst/include/RcppArmadillo/config/RcppArmadilloConfig.h:
10+
ARMA_CRIPPLED_LAPACK is only defined if 'LEGACY' Armadillo selected
11+
112
2025-11-04 Dirk Eddelbuettel <edd@debian.org>
213

314
* README.md: Minor edits

R/inline.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Copyright (C) 2010 - 2024 Dirk Eddelbuettel, Romain Francois and Douglas Bates
1+
## Copyright (C) 2010 - 2025 Dirk Eddelbuettel, Romain Francois and Douglas Bates
22
##
33
## This file is part of RcppArmadillo.
44
##
@@ -16,8 +16,7 @@
1616
## along with RcppArmadillo. If not, see <http://www.gnu.org/licenses/>.
1717

1818
inlineCxxPlugin <- function(...) {
19-
ismacos <- Sys.info()[["sysname"]] == "Darwin"
20-
openmpflag <- if (ismacos) "" else "$(SHLIB_OPENMP_CFLAGS)"
19+
openmpflag <- "$(SHLIB_OPENMP_CFLAGS)"
2120
plugin <- Rcpp::Rcpp.plugin.maker(include.before = "#include <RcppArmadillo.h>",
2221
libs = paste(openmpflag, "$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)"),
2322
package = "RcppArmadillo")

inst/include/RcppArmadillo/config/RcppArmadilloConfig.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
// RcppArmadilloConfig.h: Rcpp/Armadillo glue
33
//
4-
// Copyright (C) 2010 - 2022 Dirk Eddelbuettel, Romain Francois and Douglas Bates
5-
// Copyright (C) 2016 - 2022 George G. Vega Yon
6-
// Copyright (C) 2017 - 2022 Serguei Sokol
4+
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel, Romain Francois and Douglas Bates
5+
// Copyright (C) 2016 - 2025 George G. Vega Yon
6+
// Copyright (C) 2017 - 2025 Serguei Sokol
77
//
88
// This file is part of RcppArmadillo.
99
//
@@ -99,7 +99,12 @@
9999
// R can be built with its own Rlapack library, or use an external
100100
// one. Only the latter has zgesdd, a complex-valued SVD using divide-and-conquer
101101
// on Windows we do not assume ZGESDD
102-
#define ARMA_CRIPPLED_LAPACK 1
102+
//
103+
// Update 2025-Nov: R now generally has good enough LAPACK/BLAS, and newer Arma
104+
// versions whine so protecting this now for use with Armadillo older than 15.*
105+
#if defined(ARMA_SELECTED_LEGACY_VERSION)
106+
#define ARMA_CRIPPLED_LAPACK 1
107+
#endif
103108
// on Windows we can now assume OpenMP with Rtools / gcc 4.9.3
104109
// note that performance is said to still be poor
105110
// cf https://cran.r-project.org/doc/manuals/r-devel/R-admin.html#The-MinGW_002dw64-toolchain

inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

2-
// RcppArmadilloGenerated.h: Autoconf-updated file for LAPACK and OpenMP choices
2+
// RcppArmadilloConfigGenerated.h: Autoconf-updated file for LAPACK and OpenMP choices
33
//
4-
// Copyright (C) 2013 - 2021 Dirk Eddelbuettel
4+
// Copyright (C) 2013 - 2025 Dirk Eddelbuettel
5+
// 2025 James J. Balamuta
56
//
67
// This file is part of RcppArmadillo.
78
//
@@ -21,9 +22,19 @@
2122
#ifndef RcppArmadillo__RcppArmadilloConfigGenerated__h
2223
#define RcppArmadillo__RcppArmadilloConfigGenerated__h
2324

24-
#ifndef ARMA_USE_OPENMP
25-
// from configure test for OpenMP based on how R is configured, and whether g++ new enough
26-
@ARMA_HAVE_OPENMP@
25+
// macOS special case as discussed in https://github.com/RcppCore/RcppArmadillo/issues/493
26+
#if !defined(ARMA_USE_OPENMP)
27+
#if defined(__APPLE__) && defined(_OPENMP)
28+
// User has OpenMP available, but check if they want it disabled
29+
#ifndef RCPPARMADILLO_MACOS_DISABLE_OPENMP
30+
#define ARMA_USE_OPENMP 1
31+
#else
32+
#define ARMA_DONT_USE_OPENMP 1
33+
#endif
34+
#else
35+
// from configure test for OpenMP based on how R is configured
36+
@ARMA_HAVE_OPENMP@
37+
#endif
2738
#endif
2839

2940
#endif

0 commit comments

Comments
 (0)