Skip to content

Commit 447c738

Browse files
authored
Improved OpenMP setup and detection (closes #493) (#495)
* Simplified configure.ac, work in progress * Enable container-based r-ci 'dev' version * Missing else message added in configure.ac * Remove commented-out code from configure.ac
1 parent 0389eca commit 447c738

File tree

7 files changed

+56
-255
lines changed

7 files changed

+56
-255
lines changed

.github/workflows/ci.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ jobs:
1414
strategy:
1515
matrix:
1616
include:
17-
#- {os: macOS-latest}
18-
- {os: ubuntu-latest}
17+
- { name: container, os: ubuntu-latest, container: rocker/r2u4ci }
18+
- { name: macos, os: macos-latest }
19+
#- { name: ubuntu, os: ubuntu-latest }
20+
1921

2022
runs-on: ${{ matrix.os }}
23+
container: ${{ matrix.container }}
2124

2225
steps:
2326
- name: Checkout
2427
uses: actions/checkout@v4
2528

2629
- name: Setup
2730
uses: eddelbuettel/github-actions/r-ci@master
31+
with:
32+
dev_version: 'TRUE'
33+
34+
- name: Configure
35+
run: ./configure; cat src/Makevars
2836

2937
- name: Dependencies
3038
run: ./run.sh install_deps

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
* inst/include/current/: Sync with Armadillo 15.2
99

10+
2025-10-18 Dirk Eddelbuettel <[email protected]>
11+
12+
* configure.ac: Simplified OpenMP setup
13+
* configure: Idem
14+
1015
2025-10-17 Dirk Eddelbuettel <[email protected]>
1116

1217
* src/RcppArmadillo.cpp (armadillo_version_typed): Added

configure

Lines changed: 21 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,11 +3227,11 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
32273227

32283228
## Is R already configured to compile things using OpenMP without
32293229
## any extra hand-holding?
3230-
openmp_already_works="no"
3230+
#openmp_already_works="no"
32313231

32323232
## default to not even thinking about OpenMP as Armadillo wants a pragma
32333233
## variant available if and only if C++11 is used with g++ 5.4 or newer
3234-
can_use_openmp="no"
3234+
#can_use_openmp="no"
32353235

32363236
## Ensure TMPDIR is set.
32373237
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we have a suitable tempdir" >&5
@@ -3264,154 +3264,40 @@ if test x"$?" = x"0"; then
32643264
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
32653265
printf "%s\n" "yes" >&6; }
32663266
openmp_already_works="yes"
3267+
arma_have_openmp="#define ARMA_USE_OPENMP 1"
3268+
can_use_openmp="yes"
32673269
else
32683270
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
32693271
printf "%s\n" "no" >&6; }
3272+
openmp_already_works="no"
3273+
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
3274+
can_use_openmp="no"
32703275
fi
32713276

32723277
## Go back home.
32733278
cd "${owd}"
32743279
rm -rf "${BUILDDIR}"
32753280

3276-
## If the above checks failed, then perform other heuristics
3277-
## based on the compiler version, etc.
3278-
if test x"${openmp_already_works}" = x"no"; then
3279-
3280-
## Check the C++ compiler using the CXX value set
3281-
3282-
## If it is g++, we have GXX set so let's examine it
3283-
if test "${GXX}" = yes; then
3284-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether g++ version is sufficient" >&5
3285-
printf %s "checking whether g++ version is sufficient... " >&6; }
3286-
gxx_version=$(${CXX} -v 2>&1 | awk '/^.*g.. version/ {print $3}')
3287-
case ${gxx_version} in
3288-
1.*|2.*|3.*|4.0.*|4.1.*|4.2.*|4.3.*|4.4.*|4.5.*|4.6.*|4.7.0|4.7.1)
3289-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
3290-
printf "%s\n" "no" >&6; }
3291-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Only g++ version 4.7.2 or greater can be used with RcppArmadillo." >&5
3292-
printf "%s\n" "$as_me: WARNING: Only g++ version 4.7.2 or greater can be used with RcppArmadillo." >&2;}
3293-
as_fn_error $? "Please use a different compiler." "$LINENO" 5
3294-
;;
3295-
4.7.*|4.8.*|4.9.*|5.0*|5.1*|5.2*|5.3*)
3296-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, but without OpenMP as version ${gxx_version} (Armadillo constraint)" >&5
3297-
printf "%s\n" "yes, but without OpenMP as version ${gxx_version} (Armadillo constraint)" >&6; }
3298-
## we know this one is bad
3299-
can_use_openmp="no"
3300-
;;
3301-
5.4*|5.5*|5.6*|5.7*|5.8*|5.9*|6.*|7.*|8.*|9.*|1?.*)
3302-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, with OpenMP as version ${gxx_version}" >&5
3303-
printf "%s\n" "yes, with OpenMP as version ${gxx_version}" >&6; }
3304-
## we know this one is good, yay
3305-
can_use_openmp="yes"
3306-
;;
3307-
*)
3308-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: almost" >&5
3309-
printf "%s\n" "almost" >&6; }
3310-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++." >&5
3311-
printf "%s\n" "$as_me: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++." >&2;}
3312-
## we know nothing, so no
3313-
can_use_openmp="no"
3314-
;;
3315-
esac
3316-
fi
3317-
3318-
## Check for Apple LLVM
3319-
3320-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for macOS" >&5
3281+
## Additional Apple check
3282+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for macOS" >&5
33213283
printf %s "checking for macOS... " >&6; }
3322-
RSysinfoName=$("${R_HOME}/bin/Rscript" --vanilla -e 'cat(Sys.info()["sysname"])')
3323-
3324-
if test x"${RSysinfoName}" = x"Darwin"; then
3325-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found" >&5
3284+
RSysinfoName=$("${R_HOME}/bin/Rscript" --vanilla -e 'cat(Sys.info()["sysname"])')
3285+
if test x"${RSysinfoName}" = x"Darwin"; then
3286+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found" >&5
33263287
printf "%s\n" "found" >&6; }
3327-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for macOS Apple compiler" >&5
3288+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for macOS Apple compiler" >&5
33283289
printf %s "checking for macOS Apple compiler... " >&6; }
3329-
3330-
apple_compiler=$($CXX --version 2>&1 | grep -i -c -e 'apple llvm')
3331-
3332-
if test x"${apple_compiler}" = x"1"; then
3333-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found" >&5
3334-
printf "%s\n" "found" >&6; }
3335-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: OpenMP unavailable and turned off." >&5
3336-
printf "%s\n" "$as_me: WARNING: OpenMP unavailable and turned off." >&2;}
3337-
can_use_openmp="no"
3338-
else
3339-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found" >&5
3340-
printf "%s\n" "not found" >&6; }
3341-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clang compiler" >&5
3342-
printf %s "checking for clang compiler... " >&6; }
3343-
clang_compiler=$($CXX --version 2>&1 | grep -i -c -e 'clang ')
3344-
3345-
if test x"${clang_compiler}" = x"1"; then
3346-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found" >&5
3290+
apple_compiler=$($CXX --version 2>&1 | grep -i -c -e 'apple llvm')
3291+
if test x"${apple_compiler}" = x"1"; then
3292+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found" >&5
33473293
printf "%s\n" "found" >&6; }
3348-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OpenMP compatible version of clang" >&5
3349-
printf %s "checking for OpenMP compatible version of clang... " >&6; }
3350-
clang_version=$(${CXX} -v 2>&1 | awk '/^.*clang version/ {print $3}')
3351-
3352-
case ${clang_version} in
3353-
4.*|5.*|6.*|7.*|8.*|9.*|10.*|11.*)
3354-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found and suitable" >&5
3355-
printf "%s\n" "found and suitable" >&6; }
3356-
can_use_openmp="yes"
3357-
;;
3358-
*)
3359-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found" >&5
3360-
printf "%s\n" "not found" >&6; }
3361-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: OpenMP unavailable and turned off." >&5
3294+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: OpenMP unavailable and turned off." >&5
33623295
printf "%s\n" "$as_me: WARNING: OpenMP unavailable and turned off." >&2;}
3363-
can_use_openmp="no"
3364-
;;
3365-
esac
3366-
else
3367-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found" >&5
3368-
printf "%s\n" "not found" >&6; }
3369-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unsupported macOS build detected; if anything breaks, you keep the pieces." >&5
3370-
printf "%s\n" "$as_me: WARNING: unsupported macOS build detected; if anything breaks, you keep the pieces." >&2;}
3371-
fi
3372-
fi
3373-
else
3374-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
3375-
printf "%s\n" "no" >&6; }
3296+
can_use_openmp="no"
33763297
fi
3377-
3378-
fi # if test x"${openmp_already_works}" = x"no"
3379-
3380-
## Check for suitable LAPACK_LIBS
3381-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking LAPACK_LIBS" >&5
3382-
printf %s "checking LAPACK_LIBS... " >&6; }
3383-
3384-
## external LAPACK has the required function
3385-
lapack=$(${R_HOME}/bin/R CMD config LAPACK_LIBS)
3386-
hasRlapack=$(echo ${lapack} | grep lRlapack)
3387-
3388-
## in what follows below we substitute both side of the define/undef
3389-
## while this may seem a little unusual we do it to fully reproduce the
3390-
## previous bash-based implementation
3391-
3392-
if test x"${hasRlapack}" = x""; then
3393-
## We are using a full Lapack and can use zgbsv -- so #undef remains
3394-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: system LAPACK found" >&5
3395-
printf "%s\n" "system LAPACK found" >&6; }
3396-
## arma_lapack="#undef ARMA_CRIPPLED_LAPACK"
33973298
else
3398-
## We are using R's subset of Lapack and CANNOT use zgbsv etc, so we mark it
3399-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: R-supplied partial LAPACK found" >&5
3400-
printf "%s\n" "R-supplied partial LAPACK found" >&6; }
3401-
## AC_MSG_WARN([Some complex-valued LAPACK functions may not be available])
3402-
## arma_lapack="#define ARMA_CRIPPLED_LAPACK 1"
3403-
fi
3404-
3405-
## Default the OpenMP flag to the empty string.
3406-
## If and only if OpenMP is found, expand to $(SHLIB_OPENMP_CXXFLAGS)
3407-
openmp_flag=""
3408-
3409-
## Set the fallback, by default it is nope
3410-
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
3411-
3412-
if test x"${openmp_already_works}" = x"yes"; then
3413-
arma_have_openmp="#define ARMA_USE_OPENMP 1"
3414-
openmp_flag='$(SHLIB_OPENMP_CXXFLAGS)'
3299+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found" >&5
3300+
printf "%s\n" "not found" >&6; }
34153301
fi
34163302

34173303
if test x"${can_use_openmp}" = x"yes"; then
@@ -3424,6 +3310,7 @@ printf %s "checking for OpenMP... " >&6; }
34243310
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: missing" >&5
34253311
printf "%s\n" "missing" >&6; }
34263312
arma_have_openmp="#define ARMA_DONT_USE_OPENMP 1"
3313+
openmp_flag=""
34273314
else
34283315
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found and suitable" >&5
34293316
printf "%s\n" "found and suitable" >&6; }
@@ -3432,9 +3319,7 @@ printf "%s\n" "found and suitable" >&6; }
34323319
fi
34333320
fi
34343321

3435-
34363322
## now use all these
3437-
## AC_SUBST([ARMA_LAPACK],["${arma_lapack}"])
34383323
ARMA_HAVE_OPENMP="${arma_have_openmp}"
34393324

34403325
OPENMP_FLAG="${openmp_flag}"

0 commit comments

Comments
 (0)