From f5dbe6409063a887fc4bb0d90ab6c0350860af7a Mon Sep 17 00:00:00 2001 From: fis Date: Tue, 27 Oct 2020 16:12:37 +0800 Subject: [PATCH 1/3] Support unity build. --- src/CMakeLists.txt | 4 ++++ src/predictor/predictor.cc | 2 +- tests/cpp/common/test_span.cu | 4 ++-- tests/cpp/common/test_transform_range.cc | 12 ++---------- tests/cpp/common/test_transform_range.cu | 4 ++-- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e02539435576..75c1f2064d82 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,10 @@ list(REMOVE_ITEM CPU_SOURCES ${xgboost_SOURCE_DIR}/src/cli_main.cc) # Object library is necessary for jvm-package, which creates its own shared library. add_library(objxgboost OBJECT) target_sources(objxgboost PRIVATE ${CPU_SOURCES}) +# Skip files with factory object +set_source_files_properties( + predictor/predictor.cc gbm/gbm.cc tree/tree_updater.cc metric/metric.cc objective/objective.cc + PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) target_sources(objxgboost PRIVATE ${RABIT_SOURCES}) if (USE_CUDA) diff --git a/src/predictor/predictor.cc b/src/predictor/predictor.cc index 23e7301afbdf..2a310ba105ae 100644 --- a/src/predictor/predictor.cc +++ b/src/predictor/predictor.cc @@ -11,8 +11,8 @@ namespace dmlc { DMLC_REGISTRY_ENABLE(::xgboost::PredictorReg); } // namespace dmlc -namespace xgboost { +namespace xgboost { void PredictionContainer::ClearExpiredEntries() { std::vector expired; for (auto& kv : container_) { diff --git a/tests/cpp/common/test_span.cu b/tests/cpp/common/test_span.cu index 7e9336902b36..901c640233e0 100644 --- a/tests/cpp/common/test_span.cu +++ b/tests/cpp/common/test_span.cu @@ -64,7 +64,7 @@ __global__ void TestFromOtherKernelConst(Span span) { */ TEST(GPUSpan, FromOther) { thrust::host_vector h_vec (16); - InitializeRange(h_vec.begin(), h_vec.end()); + std::iota(h_vec.begin(), h_vec.end(), 0); thrust::device_vector d_vec (h_vec.size()); thrust::copy(h_vec.begin(), h_vec.end(), d_vec.begin()); @@ -123,7 +123,7 @@ TEST(GPUSpan, WithTrust) { // Not adviced to initialize span with host_vector, since h_vec.data() is // a host function. thrust::host_vector h_vec (16); - InitializeRange(h_vec.begin(), h_vec.end()); + std::iota(h_vec.begin(), h_vec.end(), 0); thrust::device_vector d_vec (h_vec.size()); thrust::copy(h_vec.begin(), h_vec.end(), d_vec.begin()); diff --git a/tests/cpp/common/test_transform_range.cc b/tests/cpp/common/test_transform_range.cc index 84163ea669b7..a740c278cb97 100644 --- a/tests/cpp/common/test_transform_range.cc +++ b/tests/cpp/common/test_transform_range.cc @@ -18,14 +18,6 @@ #endif -template -void InitializeRange(Iter _begin, Iter _end) { - float j = 0; - for (Iter i = _begin; i != _end; ++i, ++j) { - *i = j; - } -} - namespace xgboost { namespace common { @@ -41,9 +33,9 @@ TEST(Transform, DeclareUnifiedTest(Basic)) { const size_t size {256}; std::vector h_in(size); std::vector h_out(size); - InitializeRange(h_in.begin(), h_in.end()); + std::iota(h_in.begin(), h_in.end(), 0); std::vector h_sol(size); - InitializeRange(h_sol.begin(), h_sol.end()); + std::iota(h_sol.begin(), h_sol.end(), 0); const HostDeviceVector in_vec{h_in, TRANSFORM_GPU}; HostDeviceVector out_vec{h_out, TRANSFORM_GPU}; diff --git a/tests/cpp/common/test_transform_range.cu b/tests/cpp/common/test_transform_range.cu index a1958ded5111..5e1b2b024a7b 100644 --- a/tests/cpp/common/test_transform_range.cu +++ b/tests/cpp/common/test_transform_range.cu @@ -15,9 +15,9 @@ TEST(Transform, MGPU_SpecifiedGpuId) { // NOLINT const size_t size {256}; std::vector h_in(size); std::vector h_out(size); - InitializeRange(h_in.begin(), h_in.end()); + std::iota(h_in.begin(), h_in.end(), 0); std::vector h_sol(size); - InitializeRange(h_sol.begin(), h_sol.end()); + std::iota(h_sol.begin(), h_sol.end(), 0); const HostDeviceVector in_vec {h_in, device}; HostDeviceVector out_vec {h_out, device}; From 8345cb8d2b009eec8ae9fa6f16412a7c9b6ec12c Mon Sep 17 00:00:00 2001 From: fis Date: Wed, 28 Oct 2020 13:48:09 +0800 Subject: [PATCH 2/3] Setup on Windows Jenkins. --- Jenkinsfile-win64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-win64 b/Jenkinsfile-win64 index 573a900a752f..929cd1439e0b 100644 --- a/Jenkinsfile-win64 +++ b/Jenkinsfile-win64 @@ -85,7 +85,7 @@ def BuildWin64() { bat """ mkdir build cd build - cmake .. -G"Visual Studio 15 2017 Win64" -DUSE_CUDA=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DGOOGLE_TEST=ON -DUSE_DMLC_GTEST=ON ${arch_flag} + cmake .. -G"Visual Studio 15 2017 Win64" -DUSE_CUDA=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DGOOGLE_TEST=ON -DUSE_DMLC_GTEST=ON -DCMAKE_UNITY_BUILD=ON ${arch_flag} """ bat """ cd build From ee25335fb255839c873741e7d13e0c7dbd080e61 Mon Sep 17 00:00:00 2001 From: fis Date: Wed, 28 Oct 2020 16:40:06 +0800 Subject: [PATCH 3/3] Revert "Setup on Windows Jenkins." This reverts commit 8345cb8d2b009eec8ae9fa6f16412a7c9b6ec12c. --- Jenkinsfile-win64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-win64 b/Jenkinsfile-win64 index 929cd1439e0b..573a900a752f 100644 --- a/Jenkinsfile-win64 +++ b/Jenkinsfile-win64 @@ -85,7 +85,7 @@ def BuildWin64() { bat """ mkdir build cd build - cmake .. -G"Visual Studio 15 2017 Win64" -DUSE_CUDA=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DGOOGLE_TEST=ON -DUSE_DMLC_GTEST=ON -DCMAKE_UNITY_BUILD=ON ${arch_flag} + cmake .. -G"Visual Studio 15 2017 Win64" -DUSE_CUDA=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DGOOGLE_TEST=ON -DUSE_DMLC_GTEST=ON ${arch_flag} """ bat """ cd build