From 901c01004f708f8bb1a0ad4cf3422bf1a40558fa Mon Sep 17 00:00:00 2001 From: david-cortes Date: Sat, 4 Jan 2025 11:15:44 +0100 Subject: [PATCH 1/2] enable prefetch on windows configure script --- R-package/configure.win | 21 +++++++++++++++++++ .../src/{Makevars.win => Makevars.win.in} | 2 ++ 2 files changed, 23 insertions(+) rename R-package/src/{Makevars.win => Makevars.win.in} (98%) diff --git a/R-package/configure.win b/R-package/configure.win index e69de29bb2d1..3a01292ab6a3 100644 --- a/R-package/configure.win +++ b/R-package/configure.win @@ -0,0 +1,21 @@ +R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R.exe" +CXX=`"${R_EXE}" CMD config CXX` + +cat > test.cpp < +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 diff --git a/R-package/src/Makevars.win b/R-package/src/Makevars.win.in similarity index 98% rename from R-package/src/Makevars.win rename to R-package/src/Makevars.win.in index 875b3aaca630..8a86ba97c34d 100644 --- a/R-package/src/Makevars.win +++ b/R-package/src/Makevars.win.in @@ -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 = \ From 20f16c54aca8773054010d000efd51cbc9d6bfb8 Mon Sep 17 00:00:00 2001 From: david-cortes Date: Sat, 4 Jan 2025 11:37:45 +0100 Subject: [PATCH 2/2] update name of packaged file --- ops/script/test_r_package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ops/script/test_r_package.py b/ops/script/test_r_package.py index 3ce886c1bc41..ed0d6b1d9faa 100644 --- a/ops/script/test_r_package.py +++ b/ops/script/test_r_package.py @@ -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":