Support unity build. (#6295)

* Support unity build.

* Setup on Windows Jenkins.

* Revert "Setup on Windows Jenkins."

This reverts commit 8345cb8d2b009eec8ae9fa6f16412a7c9b6ec12c.
This commit is contained in:
Jiaming Yuan 2020-10-29 02:49:28 +08:00 committed by GitHub
parent f6169c0b16
commit c4da967b5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 15 deletions

View File

@ -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. # Object library is necessary for jvm-package, which creates its own shared library.
add_library(objxgboost OBJECT) add_library(objxgboost OBJECT)
target_sources(objxgboost PRIVATE ${CPU_SOURCES}) 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}) target_sources(objxgboost PRIVATE ${RABIT_SOURCES})
if (USE_CUDA) if (USE_CUDA)

View File

@ -11,8 +11,8 @@
namespace dmlc { namespace dmlc {
DMLC_REGISTRY_ENABLE(::xgboost::PredictorReg); DMLC_REGISTRY_ENABLE(::xgboost::PredictorReg);
} // namespace dmlc } // namespace dmlc
namespace xgboost {
namespace xgboost {
void PredictionContainer::ClearExpiredEntries() { void PredictionContainer::ClearExpiredEntries() {
std::vector<DMatrix*> expired; std::vector<DMatrix*> expired;
for (auto& kv : container_) { for (auto& kv : container_) {

View File

@ -64,7 +64,7 @@ __global__ void TestFromOtherKernelConst(Span<float const, 16> span) {
*/ */
TEST(GPUSpan, FromOther) { TEST(GPUSpan, FromOther) {
thrust::host_vector<float> h_vec (16); thrust::host_vector<float> h_vec (16);
InitializeRange(h_vec.begin(), h_vec.end()); std::iota(h_vec.begin(), h_vec.end(), 0);
thrust::device_vector<float> d_vec (h_vec.size()); thrust::device_vector<float> d_vec (h_vec.size());
thrust::copy(h_vec.begin(), h_vec.end(), d_vec.begin()); 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 // Not adviced to initialize span with host_vector, since h_vec.data() is
// a host function. // a host function.
thrust::host_vector<float> h_vec (16); thrust::host_vector<float> h_vec (16);
InitializeRange(h_vec.begin(), h_vec.end()); std::iota(h_vec.begin(), h_vec.end(), 0);
thrust::device_vector<float> d_vec (h_vec.size()); thrust::device_vector<float> d_vec (h_vec.size());
thrust::copy(h_vec.begin(), h_vec.end(), d_vec.begin()); thrust::copy(h_vec.begin(), h_vec.end(), d_vec.begin());

View File

@ -18,14 +18,6 @@
#endif #endif
template <typename Iter>
void InitializeRange(Iter _begin, Iter _end) {
float j = 0;
for (Iter i = _begin; i != _end; ++i, ++j) {
*i = j;
}
}
namespace xgboost { namespace xgboost {
namespace common { namespace common {
@ -41,9 +33,9 @@ TEST(Transform, DeclareUnifiedTest(Basic)) {
const size_t size {256}; const size_t size {256};
std::vector<bst_float> h_in(size); std::vector<bst_float> h_in(size);
std::vector<bst_float> h_out(size); std::vector<bst_float> h_out(size);
InitializeRange(h_in.begin(), h_in.end()); std::iota(h_in.begin(), h_in.end(), 0);
std::vector<bst_float> h_sol(size); std::vector<bst_float> h_sol(size);
InitializeRange(h_sol.begin(), h_sol.end()); std::iota(h_sol.begin(), h_sol.end(), 0);
const HostDeviceVector<bst_float> in_vec{h_in, TRANSFORM_GPU}; const HostDeviceVector<bst_float> in_vec{h_in, TRANSFORM_GPU};
HostDeviceVector<bst_float> out_vec{h_out, TRANSFORM_GPU}; HostDeviceVector<bst_float> out_vec{h_out, TRANSFORM_GPU};

View File

@ -15,9 +15,9 @@ TEST(Transform, MGPU_SpecifiedGpuId) { // NOLINT
const size_t size {256}; const size_t size {256};
std::vector<bst_float> h_in(size); std::vector<bst_float> h_in(size);
std::vector<bst_float> h_out(size); std::vector<bst_float> h_out(size);
InitializeRange(h_in.begin(), h_in.end()); std::iota(h_in.begin(), h_in.end(), 0);
std::vector<bst_float> h_sol(size); std::vector<bst_float> h_sol(size);
InitializeRange(h_sol.begin(), h_sol.end()); std::iota(h_sol.begin(), h_sol.end(), 0);
const HostDeviceVector<bst_float> in_vec {h_in, device}; const HostDeviceVector<bst_float> in_vec {h_in, device};
HostDeviceVector<bst_float> out_vec {h_out, device}; HostDeviceVector<bst_float> out_vec {h_out, device};