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-package] fix MM_PREFETCH and MM_MALLOC checks in configure.ac #3510

Merged
merged 2 commits into from
Nov 1, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ python-package/lightgbm/VERSION.txt

# R build artefacts
**/autom4te.cache/
conftest*
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/gha run r-valgrind

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R-package/config.status
R-package/docs
R-package/src/CMakeLists.txt
Expand Down
39 changes: 27 additions & 12 deletions R-package/configure
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,7 @@ if test -z "${R_HOME}"; then
exit 1
fi
CC=`"${R_HOME}/bin/R" CMD config CC`
CXX=`"${R_HOME}/bin/R" CMD config CXX11`

# LightGBM-specific flags
LGB_CPPFLAGS=""
Expand All @@ -1705,6 +1706,12 @@ LGB_CPPFLAGS=""
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether MM_PREFETCH works" >&5
$as_echo_n "checking whether MM_PREFETCH works... " >&6; }
ac_mmprefetch=no
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

Expand All @@ -1715,11 +1722,9 @@ int
main ()
{

int main() {
int a = 0;
_mm_prefetch(&a, _MM_HINT_NTA);
return 0;
}
int a = 0;
_mm_prefetch(&a, _MM_HINT_NTA);
return 0;


;
Expand All @@ -1728,7 +1733,7 @@ main ()


_ACEOF
${CC} -o conftest conftest.c 2>/dev/null && ./conftest && ac_mmprefetch=yes
${CXX} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mmprefetch=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_mmprefetch}" >&5
$as_echo "${ac_mmprefetch}" >&6; }
if test "${ac_mmprefetch}" = yes; then
Expand All @@ -1742,6 +1747,12 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether MM_MALLOC works" >&5
$as_echo_n "checking whether MM_MALLOC works... " >&6; }
ac_mm_malloc=no
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

Expand All @@ -1752,11 +1763,9 @@ int
main ()
{

int main() {
char *a = (char*)_mm_malloc(8, 16);
_mm_free(a);
return 0;
}
char *a = (char*)_mm_malloc(8, 16);
_mm_free(a);
return 0;


;
Expand All @@ -1765,7 +1774,7 @@ main ()


_ACEOF
${CC} -o conftest conftest.c 2>/dev/null && ./conftest && ac_mm_malloc=yes
${CXX} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_malloc=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_mm_malloc}" >&5
$as_echo "${ac_mm_malloc}" >&6; }
if test "${ac_mm_malloc}" = yes; then
Expand All @@ -1790,6 +1799,12 @@ then
ac_pkg_openmp=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether OpenMP will work in a package" >&5
$as_echo_n "checking whether OpenMP will work in a package... " >&6; }
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

Expand Down
24 changes: 12 additions & 12 deletions R-package/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if test -z "${R_HOME}"; then
exit 1
fi
CC=`"${R_HOME}/bin/R" CMD config CC`
CXX=`"${R_HOME}/bin/R" CMD config CXX11`

# LightGBM-specific flags
LGB_CPPFLAGS=""
Expand All @@ -31,23 +32,22 @@ LGB_CPPFLAGS=""

AC_MSG_CHECKING([whether MM_PREFETCH works])
ac_mmprefetch=no
AC_LANG(C++)
AC_LANG_CONFTEST(
[
AC_LANG_PROGRAM(
[[
#include <xmmintrin.h>
]],
[[
int main() {
int a = 0;
_mm_prefetch(&a, _MM_HINT_NTA);
return 0;
}
int a = 0;
_mm_prefetch(&a, _MM_HINT_NTA);
return 0;
]]
)
]
)
${CC} -o conftest conftest.c 2>/dev/null && ./conftest && ac_mmprefetch=yes
${CXX} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mmprefetch=yes
AC_MSG_RESULT([${ac_mmprefetch}])
if test "${ac_mmprefetch}" = yes; then
LGB_CPPFLAGS+=" -DMM_PREFETCH=1"
Expand All @@ -59,23 +59,22 @@ fi

AC_MSG_CHECKING([whether MM_MALLOC works])
ac_mm_malloc=no
AC_LANG(C++)
AC_LANG_CONFTEST(
[
AC_LANG_PROGRAM(
[[
#include <mm_malloc.h>
]],
[[
int main() {
char *a = (char*)_mm_malloc(8, 16);
_mm_free(a);
return 0;
}
char *a = (char*)_mm_malloc(8, 16);
_mm_free(a);
return 0;
]]
)
]
)
${CC} -o conftest conftest.c 2>/dev/null && ./conftest && ac_mm_malloc=yes
${CXX} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_malloc=yes
AC_MSG_RESULT([${ac_mm_malloc}])
if test "${ac_mm_malloc}" = yes; then
LGB_CPPFLAGS+=" -DMM_MALLOC=1"
Expand All @@ -98,6 +97,7 @@ then
OPENMP_LIB='-lomp'
ac_pkg_openmp=no
AC_MSG_CHECKING([whether OpenMP will work in a package])
AC_LANG(C)
AC_LANG_CONFTEST(
[
AC_LANG_PROGRAM(
Expand Down