diff --git a/R-package/configure b/R-package/configure index d34a29286a42..9e2367edb736 100755 --- a/R-package/configure +++ b/R-package/configure @@ -646,6 +646,8 @@ ac_includes_default="\ ac_header_cxx_list= ac_subst_vars='LTLIBOBJS LIBOBJS +XGBOOST_MM_PREFETCH_PRESENT +XGBOOST_BUILTIN_PREFETCH_PRESENT BACKTRACE_LIB DMLC_DEFS ENDIAN_FLAG @@ -2794,11 +2796,11 @@ if test x$ac_prog_cxx_stdcxx = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5 printf %s "checking for $CXX option to enable C++11 features... " >&6; } -if test ${ac_cv_prog_cxx_11+y} +if test ${ac_cv_prog_cxx_cxx11+y} then : printf %s "(cached) " >&6 else $as_nop - ac_cv_prog_cxx_11=no + ac_cv_prog_cxx_cxx11=no ac_save_CXX=$CXX cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -2840,11 +2842,11 @@ if test x$ac_prog_cxx_stdcxx = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5 printf %s "checking for $CXX option to enable C++98 features... " >&6; } -if test ${ac_cv_prog_cxx_98+y} +if test ${ac_cv_prog_cxx_cxx98+y} then : printf %s "(cached) " >&6 else $as_nop - ac_cv_prog_cxx_98=no + ac_cv_prog_cxx_cxx98=no ac_save_CXX=$CXX cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -3238,6 +3240,64 @@ printf "%s\n" "$as_me: Forcing endianness to: ${USE_LITTLE_ENDIAN}" >&6;} fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checking for prefetch builtin" >&5 +printf "%s\n" "$as_me: Checking for prefetch builtin" >&6;} +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ +__builtin_prefetch + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO" +then : + XGBOOST_BUILTIN_PREFETCH_PRESENT="-DXGBOOST_BUILTIN_PREFETCH_PRESENT=1" +else $as_nop + XGBOOST_BUILTIN_PREFETCH_PRESENT="" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +if [ "$XGBOOST_BUILTIN_PREFETCH_PRESENT" = "" ]; then + echo "Has __builtin_prefetch" +else + echo "Doesn't have __builtin_prefetch" +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checking for mm_prefetch" >&5 +printf "%s\n" "$as_me: Checking for mm_prefetch" >&6;} +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +_mm_prefetch + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO" +then : + XGBOOST_MM_PREFETCH_PRESENT="-DXGBOOST_MM_PREFETCH_PRESENT=1" +else $as_nop + XGBOOST_MM_PREFETCH_PRESENT="" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +if [ "$XGBOOST_MM_PREFETCH_PRESENT" = "" ]; then + echo "Has _mm_prefetch" +else + echo "Doesn't have _mm_prefetch" +fi + OPENMP_CXXFLAGS="" if test `uname -s` = "Linux" @@ -3289,6 +3349,8 @@ fi + + ac_config_files="$ac_config_files src/Makevars" ac_config_headers="$ac_config_headers config.h" diff --git a/R-package/configure.ac b/R-package/configure.ac index e9d8cf113fd2..8fe010070a74 100644 --- a/R-package/configure.ac +++ b/R-package/configure.ac @@ -50,6 +50,36 @@ AS_IF([test -z "${USE_LITTLE_ENDIAN+x}"], [ ENDIAN_FLAG="-DDMLC_CMAKE_LITTLE_ENDIAN=${USE_LITTLE_ENDIAN}" ]) +AC_MSG_NOTICE([Checking for prefetch builtin]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [], + [__builtin_prefetch] + )], + [XGBOOST_BUILTIN_PREFETCH_PRESENT="-DXGBOOST_BUILTIN_PREFETCH_PRESENT=1"], + [XGBOOST_BUILTIN_PREFETCH_PRESENT=""] +) +if [[ "$XGBOOST_BUILTIN_PREFETCH_PRESENT" = "" ]]; then + echo "Has __builtin_prefetch" +else + echo "Doesn't have __builtin_prefetch" +fi + +AC_MSG_NOTICE([Checking for mm_prefetch]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include ], + [_mm_prefetch] + )], + [XGBOOST_MM_PREFETCH_PRESENT="-DXGBOOST_MM_PREFETCH_PRESENT=1"], + [XGBOOST_MM_PREFETCH_PRESENT=""] +) +if [[ "$XGBOOST_MM_PREFETCH_PRESENT" = "" ]]; then + echo "Has _mm_prefetch" +else + echo "Doesn't have _mm_prefetch" +fi + OPENMP_CXXFLAGS="" if test `uname -s` = "Linux" @@ -89,6 +119,8 @@ AC_SUBST(OPENMP_LIB) AC_SUBST(ENDIAN_FLAG) AC_SUBST(DMLC_DEFS) AC_SUBST(BACKTRACE_LIB) +AC_SUBST(XGBOOST_BUILTIN_PREFETCH_PRESENT) +AC_SUBST(XGBOOST_MM_PREFETCH_PRESENT) AC_CONFIG_FILES([src/Makevars]) AC_CONFIG_HEADERS([config.h]) AC_OUTPUT diff --git a/R-package/src/Makevars.in b/R-package/src/Makevars.in index 712eb8ba8d7e..5bd8f6f9e775 100644 --- a/R-package/src/Makevars.in +++ b/R-package/src/Makevars.in @@ -7,6 +7,8 @@ CXX_STD = CXX17 XGB_RFLAGS = \ @DMLC_DEFS@ \ + @XGBOOST_BUILTIN_PREFETCH_PRESENT@ \ + @XGBOOST_MM_PREFETCH_PRESENT@ \ -DXGBOOST_STRICT_R_MODE=1 \ -DDMLC_LOG_BEFORE_THROW=0 \ -DDMLC_ENABLE_STD_THREAD=$(ENABLE_STD_THREAD) \