Skip to content

Commit

Permalink
[R] Enable prefetch on windows configure script (#11141)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cortes authored Jan 7, 2025
1 parent 2183e49 commit a475327
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions R-package/configure.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R.exe"
CXX=`"${R_EXE}" CMD config CXX`

cat > test.cpp <<EOL
#include <xmmintrin.h>
int main() {
char data = 0;
const char* address = &data;
_mm_prefetch(address, _MM_HINT_NTA);
return 0;
}
EOL

XGBOOST_MM_PREFETCH_PRESENT=""
${CXX} -o test test.cpp 2>/dev/null && ./test && XGBOOST_MM_PREFETCH_PRESENT="-DXGBOOST_MM_PREFETCH_PRESENT=1"
rm -f ./test
rm -f ./test.cpp

sed \
-e "s/@XGBOOST_MM_PREFETCH_PRESENT@/$XGBOOST_MM_PREFETCH_PRESENT/" \
< src/Makevars.win.in > src/Makevars.win
2 changes: 2 additions & 0 deletions R-package/src/Makevars.win → R-package/src/Makevars.win.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ PKG_CPPFLAGS = \
-I$(PKGROOT)/include \
-I$(PKGROOT)/dmlc-core/include \
-I$(PKGROOT) \
-DXGBOOST_BUILTIN_PREFETCH_PRESENT=1 \
@XGBOOST_MM_PREFETCH_PRESENT@ \
$(XGB_RFLAGS)

PKG_CXXFLAGS = \
Expand Down
2 changes: 1 addition & 1 deletion ops/script/test_r_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def pkgroot(path: str) -> None:
if os.path.exists(osxmakef):
os.remove(osxmakef)
pkgroot("Makevars.in")
pkgroot("Makevars.win")
pkgroot("Makevars.win.in")
# misc
rwsp = Path("R-package") / "remove_warning_suppression_pragma.sh"
if system() != "Windows":
Expand Down

0 comments on commit a475327

Please sign in to comment.