Skip to content
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

2. Continued work to remove non-API C functions, [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks Ivan Krylov for the PR and for writing a clear and concise guide about the R API: https://aitap.codeberg.page/R-api/.

3. `data.table` again properly detects OpenMP support when built using `gcc` on macOS, [#6409](https://github.com/Rdatatable/data.table/issues/6409). Thanks @barracuda156 for the report and @kevinushey for the fix.

# data.table [v1.16.0](https://github.com/Rdatatable/data.table/milestone/30) (25 August 2024)

## BREAKING CHANGES
Expand Down
11 changes: 11 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ detect_openmp () {
echo "no"
fi

# https://github.com/Rdatatable/data.table/issues/6409
printf "%s" "* checking if R installation supports OpenMP with \"-fopenmp\" ... "
Copy link
Member

Choose a reason for hiding this comment

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

LGTM!
To avoid the slight repetition with the check above though, you could consider merging them (if it still maintains readability), maybe something like:

printf "%s" "* Checking if R installation supports OpenMP with \"-Xclang -fopenmp\" or \"-fopenmp\" ... "
if CPPFLAGS="${CPPFLAGS} -Xclang -fopenmp" PKG_LIBS="-lomp" "${R_HOME}/bin/R" CMD SHLIB test-omp.c >> config.log 2>&1 || \
   CPPFLAGS="${CPPFLAGS} -fopenmp" "${R_HOME}/bin/R" CMD SHLIB test-omp.c >> config.log 2>&1; then
  echo "yes"
  if ${CC} --version 2>&1 | grep -q "clang"; then
    PKG_CFLAGS="${PKG_CFLAGS} -Xclang -fopenmp"
    PKG_LIBS="${PKG_LIBS} -lomp"
  else # This probably supports a few other GCC-compatible compilers too I reckon (such as ICC and PGI perhaps), so having a generic else sounds reasonable as opposed to being checked for GCC only.
    PKG_CFLAGS="${PKG_CFLAGS} -fopenmp"
  fi
  export PKG_CFLAGS
  export PKG_LIBS
  export R_OPENMP_ENABLED=1
  return
else
  echo "no"
fi

instead of:

printf "%s" "* checking if R installation supports OpenMP with \"-Xclang -fopenmp\" ... "
if CPPFLAGS="${CPPFLAGS} -Xclang -fopenmp" PKG_LIBS="-lomp" "${R_HOME}/bin/R" CMD SHLIB test-omp.c >> config.log 2>&1; then
  echo "yes"
  export PKG_CFLAGS="${PKG_CFLAGS} -Xclang -fopenmp"
  export PKG_LIBS="${PKG_LIBS} -lomp"
  export R_OPENMP_ENABLED=1
  return
else
  echo "no"
fi

printf "%s" "* checking if R installation supports OpenMP with \"-fopenmp\" ... "
if CPPFLAGS="${CPPFLAGS} -fopenmp" "${R_HOME}/bin/R" CMD SHLIB test-omp.c >> config.log 2>&1; then
  echo "yes"
  export PKG_CFLAGS="${PKG_CFLAGS} -fopenmp"
  export R_OPENMP_ENABLED=1
  return
else
  echo "no"
fi

Copy link
Member

Choose a reason for hiding this comment

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

Also: Unrelated to this PR, but a minor nit while we're discussing this file - 'openmp' > 'OpenMP' here: (for consistency with the other messages)

printf "%s" "* checking if R installation supports openmp with \"-fopenmp\" flag... "

if CPPFLAGS="${CPPFLAGS} -fopenmp" "${R_HOME}/bin/R" CMD SHLIB test-omp.c >> config.log 2>&1; then
echo "yes"
export PKG_CFLAGS="${PKG_CFLAGS} -fopenmp"
export R_OPENMP_ENABLED=1
return
else
echo "no"
fi

if [ "$(uname -m)" = "arm64" ]; then
HOMEBREW_PREFIX=/opt/homebrew
else
Expand Down