@@ -610,6 +610,8 @@ PACKAGE_URL=''
610610
611611ac_subst_vars=' LTLIBOBJS
612612LIBOBJS
613+ PKG_LIBS
614+ PKG_CXXFLAGS
613615OPENMP_FLAG
614616ARMA_HAVE_OPENMP
615617CXXCPP
@@ -3225,13 +3227,17 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
32253227ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
32263228
32273229
3228- # # Is R already configured to compile things using OpenMP without
3229- # # any extra hand-holding?
3230- # openmp_already_works="no"
3230+ # # Rely on Sys.info() from R for cross-compilation cases
3231+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking what system we are on" >&5
3232+ printf %s " checking what system we are on... " >&6 ; }
3233+ SYSKERNEL=$( " ${R_HOME} /bin/Rscript" --vanilla -e ' cat(Sys.info()["sysname"])' )
3234+ SYSMACHINE=$( " ${R_HOME} /bin/Rscript" --vanilla -e ' cat(Sys.info()["machine"])' )
3235+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: running ${SYSKERNEL} on ${SYSMACHINE} " >&5
3236+ printf " %s\n" " running ${SYSKERNEL} on ${SYSMACHINE} " >&6 ; }
32313237
3232- # # default to not even thinking about OpenMP as Armadillo wants a pragma
3233- # # variant available if and only if C++11 is used with g++ 5.4 or newer
3234- # can_use_openmp="no"
3238+
3239+ # # Default to not assuming OpenMP, but then test a variety of setups
3240+ can_use_openmp=" no"
32353241
32363242# # Ensure TMPDIR is set.
32373243{ printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether we have a suitable tempdir" >&5
@@ -3240,10 +3246,6 @@ TMPDIR=$("${R_HOME}/bin/R" --vanilla --slave -e "cat(dirname(tempdir()))")
32403246{ printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: ${TMPDIR} " >&5
32413247printf " %s\n" " ${TMPDIR} " >&6 ; }
32423248
3243- # # Check if R is configured to compile programs using OpenMP out-of-the-box.
3244- { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can already compile programs using OpenMP" >&5
3245- printf %s " checking whether R CMD SHLIB can already compile programs using OpenMP... " >&6 ; }
3246-
32473249# # Create private directory in TMPDIR.
32483250BUILDDIR=" ${TMPDIR} /rcpparmadillo-$$ -$RANDOM "
32493251mkdir -p " ${BUILDDIR} "
@@ -3258,72 +3260,154 @@ int main() {
32583260}
32593261EOF
32603262
3261- # # Execute R CMD SHLIB.
3262- " ${R_HOME} /bin/R" CMD SHLIB test-omp.cpp > /dev/null 2>&1
3263- if test x" $? " = x" 0" ; then
3264- { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
3263+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether on Linux" >&5
3264+ printf %s " checking whether on Linux... " >&6 ; }
3265+ if test x" ${SYSKERNEL} " = x" Linux" ; then
3266+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
3267+ printf " %s\n" " yes" >&6 ; }
3268+
3269+ # # Check if R is configured to compile OpenMP programs out-of-the-box.
3270+ if test x" ${can_use_openmp} " = x" no" ; then
3271+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can already compile OpenMP programs" >&5
3272+ printf %s " checking whether R CMD SHLIB can already compile OpenMP programs... " >&6 ; }
3273+ " ${R_HOME} /bin/R" CMD SHLIB test-omp.cpp > /dev/null 2>&1
3274+ if test x" $? " = x" 0" ; then
3275+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
32653276printf " %s\n" " yes" >&6 ; }
3266- openmp_already_works=" yes"
3267- arma_have_openmp=" #define ARMA_USE_OPENMP 1"
3268- can_use_openmp=" yes"
3277+ can_use_openmp=" yes"
3278+ else
3279+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
3280+ printf " %s\n" " no" >&6 ; }
3281+ can_use_openmp=" no"
3282+ fi
3283+ fi
3284+
3285+ # # If needed, check if R is configured to compile OpenMP programs using -fopenmp
3286+ if test x" ${can_use_openmp} " = x" no" ; then
3287+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can compile OpenMP via -fopenmp" >&5
3288+ printf %s " checking whether R CMD SHLIB can compile OpenMP via -fopenmp... " >&6 ; }
3289+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -fopenmp" PKG_LIBS=" ${PKG_LIBS} -fopenmp" " ${R_HOME} /bin/R" CMD SHLIB -fopenmp test-omp.cpp > /dev/null 2>&1
3290+ if test x" $? " = x" 0" ; then
3291+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
3292+ printf " %s\n" " yes" >&6 ; }
3293+ can_use_openmp=" yes"
3294+ # keep any entries user may have set
3295+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -fopenmp"
3296+ PKG_LIBS=" ${PKG_LIBS} -fopenmp"
3297+ else
3298+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
3299+ printf " %s\n" " no" >&6 ; }
3300+ can_use_openmp=" no"
3301+ fi
3302+ fi
32693303else
3270- { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
3304+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
32713305printf " %s\n" " no" >&6 ; }
3272- openmp_already_works=" no"
3273- arma_have_openmp=" #define ARMA_DONT_USE_OPENMP 1"
3274- can_use_openmp=" no"
3275- fi
3306+ fi # if Linux
3307+
3308+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether on macOS" >&5
3309+ printf %s " checking whether on macOS... " >&6 ; }
3310+ if test x" ${SYSKERNEL} " = x" Darwin" ; then
3311+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
3312+ printf " %s\n" " yes" >&6 ; }
3313+
3314+ # # Check if R is configured to compile OpenMP programs using -Xclang -fopenmp
3315+ if test x" ${can_use_openmp} " = x" no" ; then
3316+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can compile OpenMP programs using '-Xclang -fopenmp'" >&5
3317+ printf %s " checking whether R CMD SHLIB can compile OpenMP programs using '-Xclang -fopenmp'... " >&6 ; }
3318+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -Xclang -fopenmp" PKG_LIBS=" ${PKG_LIBS} -lomp" " ${R_HOME} /bin/R" CMD SHLIB test-omp.cpp > /dev/null 2>&1
3319+ if test x" $? " = x" 0" ; then
3320+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
3321+ printf " %s\n" " yes" >&6 ; }
3322+ can_use_openmp=" yes"
3323+ # keep any entries user may have set
3324+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -Xclang -fopenmp"
3325+ PKG_LIBS=" ${PKG_LIBS} -lomp"
3326+ else
3327+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
3328+ printf " %s\n" " no" >&6 ; }
3329+ can_use_openmp=" no"
3330+ fi
3331+ fi
3332+
3333+ # # Check if R is configured to compile OpenMP programs using -fopenmp (cf data.table #6409)
3334+ if test x" ${can_use_openmp} " = x" no" ; then
3335+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can compile OpenMP programs using '-fopenmp'" >&5
3336+ printf %s " checking whether R CMD SHLIB can compile OpenMP programs using '-fopenmp'... " >&6 ; }
3337+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -fopenmp" PKG_LIBS=" ${PKG_LIBS} -fopenmp" " ${R_HOME} /bin/R" CMD SHLIB test-omp.cpp > /dev/null 2>&1
3338+ if test x" $? " = x" 0" ; then
3339+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
3340+ printf " %s\n" " yes" >&6 ; }
3341+ can_use_openmp=" yes"
3342+ # keep any entries user may have set
3343+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -fopenmp"
3344+ PKG_LIBS=" ${PKG_LIBS} -fopenmp"
3345+ else
3346+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
3347+ printf " %s\n" " no" >&6 ; }
3348+ can_use_openmp=" no"
3349+ fi
3350+ fi
3351+
3352+ if test x" ${can_use_openmp} " = x" no" ; then
3353+ if test x" ${SYSMACHINE} " = x" arm64" ; then
3354+ HOMEBREW_PREFIX=/opt/homebrew
3355+ else
3356+ HOMEBREW_PREFIX=/usr/local
3357+ fi
3358+ if test -e " ${HOMEBREW_PREFIX} /opt/libomp" ; then
3359+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can use libomp at ${HOMEBREW_PREFIX} /opt/libomp" >&5
3360+ printf %s " checking whether R CMD SHLIB can use libomp at ${HOMEBREW_PREFIX} /opt/libomp... " >&6 ; }
3361+ LIBOMP_INCLUDE=" -I${HOMEBREW_PREFIX} /opt/libomp/include -Xclang -fopenmp"
3362+ LIBOMP_LINK=" -L${HOMEBREW_PREFIX} /opt/libomp/lib -lomp"
3363+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} ${LIBOMP_INCLUDE} " PKG_LIBS=" ${PKG_LIBS} ${LIBOMP_LINK} " " ${R_HOME} /bin/R" CMD SHLIB test-omp.cpp > /dev/null 2>&1
3364+ if test x" $? " = x" 0" ; then
3365+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
3366+ printf " %s\n" " yes" >&6 ; }
3367+ can_use_openmp=" yes"
3368+ # keep any entries user may have set
3369+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} ${LIBOMP_INCLUDE} "
3370+ PKG_LIBS=" ${PKG_LIBS} ${LIBOMP_LINK} "
3371+ else
3372+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
3373+ printf " %s\n" " no" >&6 ; }
3374+ can_use_openmp=" no"
3375+ fi
3376+ fi
3377+ fi
3378+ else
3379+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
3380+ printf " %s\n" " no" >&6 ; }
3381+ fi # if macOS
32763382
32773383# # Go back home.
32783384cd " ${owd} "
32793385rm -rf " ${BUILDDIR} "
32803386
3281- # # Additional Apple check
3282- { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking for macOS" >&5
3283- printf %s " checking for macOS... " >&6 ; }
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
3287- printf " %s\n" " found" >&6 ; }
3288- { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking for macOS Apple compiler" >&5
3289- printf %s " checking for macOS Apple compiler... " >&6 ; }
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
3293- printf " %s\n" " found" >&6 ; }
3294- { printf " %s\n" " $as_me :${as_lineno-$LINENO } : WARNING: OpenMP unavailable and turned off." >&5
3295- printf " %s\n" " $as_me : WARNING: OpenMP unavailable and turned off." >&2 ; }
3296- can_use_openmp=" no"
3297- fi
3298- else
3299- { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: not found" >&5
3300- printf " %s\n" " not found" >&6 ; }
3301- fi
3302-
3303- if test x" ${can_use_openmp} " = x" yes" ; then
3304- { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking for OpenMP" >&5
3387+ # Overall summary
3388+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking for OpenMP" >&5
33053389printf %s " checking for OpenMP... " >&6 ; }
3306- # # if R has -fopenmp we should be good
3307- allldflags=$( ${R_HOME} /bin/R CMD config --ldflags)
3308- hasOpenMP=$( echo ${allldflags} | grep -- -fopenmp)
3309- if test x" ${hasOpenMP} " = x" " ; then
3310- { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: missing" >&5
3311- printf " %s\n" " missing" >&6 ; }
3312- arma_have_openmp=" #define ARMA_DONT_USE_OPENMP 1"
3313- openmp_flag=" "
3314- else
3315- { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: found and suitable" >&5
3390+ if test x" ${can_use_openmp} " = x" yes" ; then
3391+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: found and suitable" >&5
33163392printf " %s\n" " found and suitable" >&6 ; }
3317- arma_have_openmp=" #define ARMA_USE_OPENMP 1"
3318- openmp_flag=' $(SHLIB_OPENMP_CXXFLAGS)'
3319- fi
3393+ arma_have_openmp=" #define ARMA_USE_OPENMP 1"
3394+ openmp_flag=' $(SHLIB_OPENMP_CXXFLAGS)'
3395+ else
3396+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: missing so no OpenMP acceleration" >&5
3397+ printf " %s\n" " missing so no OpenMP acceleration" >&6 ; }
3398+ arma_have_openmp=" #define ARMA_DONT_USE_OPENMP 1"
3399+ openmp_flag=" "
33203400fi
33213401
3322- # # now use all these
3402+ # # Now use all these
33233403ARMA_HAVE_OPENMP=" ${arma_have_openmp} "
33243404
33253405OPENMP_FLAG=" ${openmp_flag} "
33263406
3407+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} "
3408+
3409+ PKG_LIBS=" ${PKG_LIBS} "
3410+
33273411ac_config_files=" $ac_config_files inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h src/Makevars"
33283412
33293413cat > confcache << \_ACEOF
0 commit comments