Skip to content

Commit

Permalink
add prefetcher args if supported
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cortes committed Dec 19, 2024
1 parent b4aa479 commit 88479d3
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 4 deletions.
70 changes: 66 additions & 4 deletions R-package/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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 <xmmintrin.h>
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"
Expand Down Expand Up @@ -3289,6 +3349,8 @@ fi





ac_config_files="$ac_config_files src/Makevars"

ac_config_headers="$ac_config_headers config.h"
Expand Down
32 changes: 32 additions & 0 deletions R-package/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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 <xmmintrin.h>],
[_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"
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions R-package/src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down

0 comments on commit 88479d3

Please sign in to comment.