Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R] Add prefetcher compiler macros if supported #11124

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading