Skip to content

Commit

Permalink
Merge pull request #2377 from rsbivand/tbb_240411
Browse files Browse the repository at this point in the history
Tbb 240411
  • Loading branch information
kbenoit committed Apr 23, 2024
2 parents 5601355 + 681a588 commit f132153
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 68 deletions.
118 changes: 82 additions & 36 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_tbb
'
ac_precious_vars='build_alias
host_alias
Expand Down Expand Up @@ -1298,6 +1299,13 @@ if test -n "$ac_init_help"; then
esac
cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-tbb "to choose to disable Intel TBB even if installed,
use --disable-tbb"
Some influential environment variables:
CXX C++ compiler command
CXXFLAGS C++ compiler flags
Expand Down Expand Up @@ -2945,11 +2953,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 @@ -2991,11 +2999,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 @@ -4185,11 +4193,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 @@ -4231,11 +4239,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 @@ -4285,39 +4293,60 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
TBBFLAGS=
TBBLIBS=
# Configure argument to avoid TBB
WITH_TBB="yes"
# Check whether --enable-tbb was given.
if test ${enable_tbb+y}
then :
enableval=$enable_tbb; if test "${enableval}" = no; then
want_tbb=no
elif test "${enableval}" = yes; then
want_tbb=yes
else
want_tbb=yes
fi
else $as_nop
want_tbb=yes
fi
if test "$want_tbb" = no ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Intel TBB detection disabled" >&5
printf "%s\n" "$as_me: Intel TBB detection disabled" >&6;}
else
# If tbb/tbb.h and libtbb are found, define TBB and add -ltbb
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking Intel TBB existence:" >&5
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking Intel TBB existence:" >&5
printf %s "checking Intel TBB existence:... " >&6; }
TBB_EXISTS=no
pkg-config --exists tbb >/dev/null 2>&1
SH_TBB_EXISTS=`echo $?`
if test ${SH_TBB_EXISTS} = 0 ; then
TBB_EXISTS=yes
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
TBB_EXISTS=no
pkg-config --exists tbb >/dev/null 2>&1
SH_TBB_EXISTS=`echo $?`
if test ${SH_TBB_EXISTS} = 0 ; then
TBB_EXISTS=yes
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
else
if test ${SH_TBB_EXISTS} = 1 ; then
TBB_EXISTS=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
else
if test ${SH_TBB_EXISTS} = 1 ; then
TBB_EXISTS=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Intel TBB not installed; install TBB devel package for parallel processing or update PKG_CONFIG_PATH environment variable" >&5
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Intel TBB not installed; install TBB devel package for parallel processing or update PKG_CONFIG_PATH environment variable" >&5
printf "%s\n" "$as_me: WARNING: Intel TBB not installed; install TBB devel package for parallel processing or update PKG_CONFIG_PATH environment variable" >&2;}
else
TBB_EXISTS=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
else
TBB_EXISTS=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config not found; install pkg-config to auto-detect Intel TBB; assumed absent" >&5
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config not found; install pkg-config to auto-detect Intel TBB; assumed absent" >&5
printf "%s\n" "$as_me: WARNING: pkg-config not found; install pkg-config to auto-detect Intel TBB; assumed absent" >&2;}
fi
fi
fi
if test ${TBB_EXISTS} = yes ; then
TBBFLAGS="-DTBB $(pkg-config --cflags tbb)"
if test ${TBB_EXISTS} = yes ; then
TBBFLAGS="-DTBB $(pkg-config --cflags tbb)"
TBBLIBS="$(pkg-config --libs tbb)"
TBBLIBS="$(pkg-config --libs tbb)"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking tbb available for compiling and linking:" >&5
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking tbb available for compiling and linking:" >&5
printf %s "checking tbb available for compiling and linking:... " >&6; }
cat > libtbb_test.cpp <<_EOCONF
#include <tbb/tbb.h>
Expand All @@ -4337,18 +4366,35 @@ int main() {
}
}
_EOCONF
${CXX} ${CXXFLAGS} ${TBBFLAGS} -o libtbb_test libtbb_test.cpp ${TBBLIBS} 2> errors.txt
${CXX} ${CXXFLAGS} ${TBBFLAGS} -o libtbb_test libtbb_test.cpp ${TBBLIBS} 2> errors.txt
if test `echo $?` -ne 0 ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
if test `echo $?` -ne 0 ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: parallel computing is disabled because the Intel TBB devel package is absent" >&5
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: parallel computing is disabled because the Intel TBB devel package is absent" >&5
printf "%s\n" "$as_me: WARNING: parallel computing is disabled because the Intel TBB devel package is absent" >&2;}
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
TBBFLAGS=""
TBBLIBS=""
else
./libtbb_test >/dev/null 2>&1
if test `echo $?` -ne 0 ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: parallel computing is disabled because Intel TBB did not load" >&5
printf "%s\n" "$as_me: WARNING: parallel computing is disabled because Intel TBB did not load" >&2;}
TBBFLAGS=""
TBBLIBS=""
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
fi
fi
rm -f libtbb_test.cpp libtbb_test errors.txt
fi
rm -f libtbb_test.cpp libtbb_test errors.txt
fi
# Now substitute these variables in src/Makevars.in to create src/Makevars
TBB_CFLAGS=${TBBFLAGS}
Expand Down
82 changes: 54 additions & 28 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,46 @@ AC_PROG_CXX
TBBFLAGS=
TBBLIBS=

# Configure argument to avoid TBB
WITH_TBB="yes"
AC_ARG_ENABLE([tbb], [AS_HELP_STRING([--enable-tbb],["to choose to disable Intel TBB even if installed, use --disable-tbb"])],
[if test "${enableval}" = no; then
want_tbb=no
elif test "${enableval}" = yes; then
want_tbb=yes
else
want_tbb=yes
fi],
[want_tbb=yes])

if test "$want_tbb" = no ; then
AC_MSG_NOTICE([Intel TBB detection disabled])
else
# If tbb/tbb.h and libtbb are found, define TBB and add -ltbb
AC_MSG_CHECKING([Intel TBB existence:])
TBB_EXISTS=no
pkg-config --exists tbb >/dev/null 2>&1
SH_TBB_EXISTS=`echo $?`
if test ${SH_TBB_EXISTS} = 0 ; then
TBB_EXISTS=yes
AC_MSG_RESULT(yes)
else
if test ${SH_TBB_EXISTS} = 1 ; then
TBB_EXISTS=no
AC_MSG_RESULT(no)
AC_MSG_WARN([Intel TBB not installed; install TBB devel package for parallel processing or update PKG_CONFIG_PATH environment variable])
else
TBB_EXISTS=no
AC_MSG_RESULT(no)
AC_MSG_WARN([pkg-config not found; install pkg-config to auto-detect Intel TBB; assumed absent])
AC_MSG_CHECKING([Intel TBB existence:])
TBB_EXISTS=no
pkg-config --exists tbb >/dev/null 2>&1
SH_TBB_EXISTS=`echo $?`
if test ${SH_TBB_EXISTS} = 0 ; then
TBB_EXISTS=yes
AC_MSG_RESULT(yes)
else
if test ${SH_TBB_EXISTS} = 1 ; then
TBB_EXISTS=no
AC_MSG_RESULT(no)
AC_MSG_WARN([Intel TBB not installed; install TBB devel package for parallel processing or update PKG_CONFIG_PATH environment variable])
else
TBB_EXISTS=no
AC_MSG_RESULT(no)
AC_MSG_WARN([pkg-config not found; install pkg-config to auto-detect Intel TBB; assumed absent])
fi
fi
fi

if test ${TBB_EXISTS} = yes ; then
AC_SUBST(TBBFLAGS, ["-DTBB $(pkg-config --cflags tbb)"])
AC_SUBST(TBBLIBS, ["$(pkg-config --libs tbb)"])
if test ${TBB_EXISTS} = yes ; then
AC_SUBST(TBBFLAGS, ["-DTBB $(pkg-config --cflags tbb)"])
AC_SUBST(TBBLIBS, ["$(pkg-config --libs tbb)"])

AC_MSG_CHECKING([tbb available for compiling and linking:])
AC_MSG_CHECKING([tbb available for compiling and linking:])
[cat > libtbb_test.cpp <<_EOCONF
#include <tbb/tbb.h>
Expand All @@ -66,15 +81,26 @@ int main() {
}
}
_EOCONF]
${CXX} ${CXXFLAGS} ${TBBFLAGS} -o libtbb_test libtbb_test.cpp ${TBBLIBS} 2> errors.txt
${CXX} ${CXXFLAGS} ${TBBFLAGS} -o libtbb_test libtbb_test.cpp ${TBBLIBS} 2> errors.txt

if test `echo $?` -ne 0 ; then
AC_MSG_RESULT(no)
AC_MSG_WARN([parallel computing is disabled because the Intel TBB devel package is absent])
else
AC_MSG_RESULT(yes)
if test `echo $?` -ne 0 ; then
AC_MSG_RESULT(no)
AC_MSG_WARN([parallel computing is disabled because the Intel TBB devel package is absent])
AC_SUBST(TBBFLAGS, [""])
AC_SUBST(TBBLIBS, [""])
else
./libtbb_test >/dev/null 2>&1
if test `echo $?` -ne 0 ; then
AC_MSG_RESULT(no)
AC_MSG_WARN([parallel computing is disabled because Intel TBB did not load])
AC_SUBST(TBBFLAGS, [""])
AC_SUBST(TBBLIBS, [""])
else
AC_MSG_RESULT(yes)
fi
fi
rm -f libtbb_test.cpp libtbb_test errors.txt
fi
rm -f libtbb_test.cpp libtbb_test errors.txt
fi
# Now substitute these variables in src/Makevars.in to create src/Makevars
AC_SUBST(TBB_CFLAGS, ${TBBFLAGS})
Expand Down
11 changes: 7 additions & 4 deletions tests/testthat/test-tbb.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
test_that("TBB is enabled", {

skip_on_cran()

info <- info_tbb()
expect_true(info$enabled)
expect_true(info$max_threads > 1)
if (info$enabled) {
expect_true(info$enabled)
expect_true(info$max_threads > 1)
} else {
expect_false(info$enabled)
expect_false(info$max_threads > 1)
}

})

0 comments on commit f132153

Please sign in to comment.