@@ -3227,25 +3227,16 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
32273227ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
32283228
32293229
3230+ # # Rely on Sys.info() from R for cross-compilation cases
32303231{ printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking what system we are on" >&5
32313232printf %s " checking what system we are on... " >&6 ; }
3232- # SYSKERNEL=$(uname -s)
3233- # SYSMACHINE=$(uname -m)
3234- # SYSOS=$(uname -o)
3235- # AC_MSG_RESULT([${SYSKERNEL} ${SYSMACHINE} ${SYSOS}])
3236- # # Rely on Sys.info() from R for cross-compilation cases
32373233SYSKERNEL=$( " ${R_HOME} /bin/Rscript" --vanilla -e ' cat(Sys.info()["sysname"])' )
32383234SYSMACHINE=$( " ${R_HOME} /bin/Rscript" --vanilla -e ' cat(Sys.info()["machine"])' )
32393235{ printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: running ${SYSKERNEL} on ${SYSMACHINE} " >&5
32403236printf " %s\n" " running ${SYSKERNEL} on ${SYSMACHINE} " >&6 ; }
32413237
32423238
3243- # # Is R already configured to compile things using OpenMP without
3244- # # any extra hand-holding?
3245- # openmp_already_works="no"
3246-
3247- # # default to not even thinking about OpenMP as Armadillo wants a pragma
3248- # # variant available if and only if C++11 is used with g++ 5.4 or newer
3239+ # # Default to not assuming OpenMP, but then test a variety of setups
32493240can_use_openmp=" no"
32503241
32513242# # Ensure TMPDIR is set.
@@ -3279,19 +3270,14 @@ printf "%s\n" "yes" >&6; }
32793270 if test x" ${can_use_openmp} " = x" no" ; then
32803271 { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can already compile OpenMP programs" >&5
32813272printf %s " checking whether R CMD SHLIB can already compile OpenMP programs... " >&6 ; }
3282-
32833273 " ${R_HOME} /bin/R" CMD SHLIB test-omp.cpp > /dev/null 2>&1
32843274 if test x" $? " = x" 0" ; then
32853275 { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
32863276printf " %s\n" " yes" >&6 ; }
3287- # openmp_already_works="yes"
3288- arma_have_openmp=" #define ARMA_USE_OPENMP 1"
32893277 can_use_openmp=" yes"
32903278 else
32913279 { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
32923280printf " %s\n" " no" >&6 ; }
3293- # openmp_already_works="no"
3294- arma_have_openmp=" #define ARMA_DONT_USE_OPENMP 1"
32953281 can_use_openmp=" no"
32963282 fi
32973283 fi
@@ -3300,22 +3286,16 @@ printf "%s\n" "no" >&6; }
33003286 if test x" ${can_use_openmp} " = x" no" ; then
33013287 { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can compile OpenMP via -fopenmp" >&5
33023288printf %s " checking whether R CMD SHLIB can compile OpenMP via -fopenmp... " >&6 ; }
3303-
33043289 PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -fopenmp" PKG_LIBS=" ${PKG_LIBS} -fopen" " ${R_HOME} /bin/R" CMD SHLIB -fopenmp test-omp.cpp > /dev/null 2>&1
33053290 if test x" $? " = x" 0" ; then
33063291 { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
33073292printf " %s\n" " yes" >&6 ; }
3308- # openmp_already_works="yes"
3309- arma_have_openmp=" #define ARMA_USE_OPENMP 1"
3310- can_use_openmp=" yes"
33113293 # keep any entries user may have set
33123294 PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -fopenmp"
33133295 PKG_LIBS=" ${PKG_LIBS} -fopenmp"
33143296 else
33153297 { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
33163298printf " %s\n" " no" >&6 ; }
3317- # openmp_already_works="no"
3318- arma_have_openmp=" #define ARMA_DONT_USE_OPENMP 1"
33193299 can_use_openmp=" no"
33203300 fi
33213301 fi
@@ -3334,24 +3314,63 @@ printf "%s\n" "yes" >&6; }
33343314 if test x" ${can_use_openmp} " = x" no" ; then
33353315 { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can compile OpenMP programs using '-Xclang -fopenmp'" >&5
33363316printf %s " checking whether R CMD SHLIB can compile OpenMP programs using '-Xclang -fopenmp'... " >&6 ; }
3337-
33383317 PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -Xclang -fopenmp" PKG_LIBS=" ${PKG_LIBS} -lomp" " ${R_HOME} /bin/R" CMD SHLIB test-omp.cpp > /dev/null 2>&1
33393318 if test x" $? " = x" 0" ; then
33403319 { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
33413320printf " %s\n" " yes" >&6 ; }
3342- # openmp_already_works="yes"
3343- arma_have_openmp=" #define ARMA_USE_OPENMP 1"
33443321 can_use_openmp=" yes"
33453322 # keep any entries user may have set
33463323 PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -Xclang -fopenmp"
33473324 PKG_LIBS=" ${PKG_LIBS} -lomp"
33483325 else
33493326 { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
33503327printf " %s\n" " no" >&6 ; }
3351- # openmp_already_works="no"
3352- arma_have_openmp=" #define ARMA_DONT_USE_OPENMP 1"
33533328 can_use_openmp=" no"
33543329 fi
3330+ fi
3331+
3332+ # # Check if R is configured to compile OpenMP programs using -fopenmp (cf data.table #6409)
3333+ if test x" ${can_use_openmp} " = x" no" ; then
3334+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can compile OpenMP programs using '-fopenmp'" >&5
3335+ printf %s " checking whether R CMD SHLIB can compile OpenMP programs using '-fopenmp'... " >&6 ; }
3336+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -fopenmp" PKG_LIBS=" ${PKG_LIBS} -fopenmp" " ${R_HOME} /bin/R" CMD SHLIB test-omp.cpp > /dev/null 2>&1
3337+ if test x" $? " = x" 0" ; then
3338+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
3339+ printf " %s\n" " yes" >&6 ; }
3340+ can_use_openmp=" yes"
3341+ # keep any entries user may have set
3342+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -fopenmp"
3343+ PKG_LIBS=" ${PKG_LIBS} -fopenmp"
3344+ else
3345+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
3346+ printf " %s\n" " no" >&6 ; }
3347+ can_use_openmp=" no"
3348+ fi
3349+ fi
3350+
3351+ if test x" ${can_use_openmp} " = x" no" ; then
3352+ if test x" ${SYSMACHINE} " = x" arm64" ; then
3353+ HOMEBREW_PREFIX=/opt/homebrew
3354+ else
3355+ HOMEBREW_PREFIX=/usr/local
3356+ fi
3357+ if test -e " ${HOMEBREW_PREFIX} /opt/libomp" ; then
3358+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking whether R CMD SHLIB can use libomp at ${HOMEBREW_PREFIX} /opt/libomp" >&5
3359+ printf %s " checking whether R CMD SHLIB can use libomp at ${HOMEBREW_PREFIX} /opt/libomp... " >&6 ; }
3360+ LIBOMP_INCLUDE=" -I${HOMEBREW_PREFIX} /opt/libomp/include -Xclang -fopenmp" LIBOMP_LINK=" -L${HOMEBREW_PREFIX} /opt/libomp/lib -lomp" " ${R_HOME} /bin/R" CMD SHLIB test-omp.cpp > /dev/null 2>&1
3361+ if test x" $? " = x" 0" ; then
3362+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: yes" >&5
3363+ printf " %s\n" " yes" >&6 ; }
3364+ can_use_openmp=" yes"
3365+ # keep any entries user may have set
3366+ PKG_CXXFLAGS=" ${PKG_CXXFLAGS} -I${HOMEBREW_PREFIX} /opt/libomp/include -Xclang -fopenmp"
3367+ PKG_LIBS=" ${PKG_LIBS} -L${HOMEBREW_PREFIX} /opt/libomp/lib -lomp"
3368+ else
3369+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
3370+ printf " %s\n" " no" >&6 ; }
3371+ can_use_openmp=" no"
3372+ fi
3373+ fi
33553374 fi
33563375else
33573376 { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: no" >&5
@@ -3362,9 +3381,22 @@ fi # if macOS
33623381cd " ${owd} "
33633382rm -rf " ${BUILDDIR} "
33643383
3384+ # Overall summary
3385+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : checking for OpenMP" >&5
3386+ printf %s " checking for OpenMP... " >&6 ; }
3387+ if test x" ${can_use_openmp} " = x" yes" ; then
3388+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: found and suitable" >&5
3389+ printf " %s\n" " found and suitable" >&6 ; }
3390+ arma_have_openmp=" #define ARMA_USE_OPENMP 1"
3391+ openmp_flag=' $(SHLIB_OPENMP_CXXFLAGS)'
3392+ else
3393+ { printf " %s\n" " $as_me :${as_lineno-$LINENO } : result: missing so no OpenMP acceleration" >&5
3394+ printf " %s\n" " missing so no OpenMP acceleration" >&6 ; }
3395+ arma_have_openmp=" #define ARMA_DONT_USE_OPENMP 1"
3396+ openmp_flag=" "
3397+ fi
33653398
3366-
3367- # # now use all these
3399+ # # Now use all these
33683400ARMA_HAVE_OPENMP=" ${arma_have_openmp} "
33693401
33703402OPENMP_FLAG=" ${openmp_flag} "
0 commit comments