Export c++ headers in CMake installation. (#4897)
* Move get transpose into cc. * Clean up headers in host device vector, remove thrust dependency. * Move span and host device vector into public. * Install c++ headers. * Short notes for c and c++. Co-Authored-By: Philip Hyunsu Cho <chohyu01@cs.washington.edu>
This commit is contained in:
parent
4ab1df5fe6
commit
095de3bf5f
@ -187,11 +187,9 @@ if (BUILD_C_DOC)
|
|||||||
endif (BUILD_C_DOC)
|
endif (BUILD_C_DOC)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
# Exposing only C APIs.
|
# Install all headers. Please note that currently the C++ headers does not form an "API".
|
||||||
install(FILES
|
install(DIRECTORY ${xgboost_SOURCE_DIR}/include/xgboost
|
||||||
"${PROJECT_SOURCE_DIR}/include/xgboost/c_api.h"
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
DESTINATION
|
|
||||||
include/xgboost/)
|
|
||||||
|
|
||||||
install(TARGETS xgboost runxgboost
|
install(TARGETS xgboost runxgboost
|
||||||
EXPORT XGBoostTargets
|
EXPORT XGBoostTargets
|
||||||
|
|||||||
4
demo/c-api/CMakeLists.txt
Normal file
4
demo/c-api/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.3)
|
||||||
|
find_package(xgboost REQUIRED)
|
||||||
|
add_executable(api-demo c-api-demo.c)
|
||||||
|
target_link_libraries(api-demo xgboost::xgboost)
|
||||||
12
doc/c++.rst
Normal file
12
doc/c++.rst
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
###############
|
||||||
|
XGBoost C++ API
|
||||||
|
###############
|
||||||
|
|
||||||
|
Starting from 1.0 release, CMake will generate installation rules to export all C++ headers. But
|
||||||
|
the c++ interface is much closer to the internal of XGBoost than other language bindings.
|
||||||
|
As a result it's changing quite often and we don't maintain its stability. Along with the
|
||||||
|
plugin system (see ``plugin/example`` in XGBoost's source tree), users can utilize some
|
||||||
|
existing c++ headers for gaining more access to the internal of XGBoost.
|
||||||
|
|
||||||
|
* `C++ interface documentation (latest master branch) <https://xgboost.readthedocs.io/en/latest/dev/files.html>`_
|
||||||
|
* `C++ interface documentation (last stable release) <https://xgboost.readthedocs.io/en/stable/dev/files.html>`_
|
||||||
12
doc/c.rst
Normal file
12
doc/c.rst
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#################
|
||||||
|
XGBoost C Package
|
||||||
|
#################
|
||||||
|
|
||||||
|
XGBoost implements a set of C API designed for various bindings, we maintain its
|
||||||
|
stability and the CMake/make build interface. See ``demo/c-api/README.md`` for an
|
||||||
|
overview and related examples. Also one can generate doxygen document by providing
|
||||||
|
``-DBUILD_C_DOC=ON`` as parameter to ``CMake`` during build, or simply look at function
|
||||||
|
comments in ``include/xgboost/c_api.h``.
|
||||||
|
|
||||||
|
* `C API documentation (latest master branch) <https://xgboost.readthedocs.io/en/latest/dev/c__api_8h.html>`_
|
||||||
|
* `C API documentation (last stable release) <https://xgboost.readthedocs.io/en/stable/dev/c__api_8h.html>`_
|
||||||
@ -27,5 +27,7 @@ Contents
|
|||||||
JVM package <jvm/index>
|
JVM package <jvm/index>
|
||||||
Ruby package <https://github.com/ankane/xgb>
|
Ruby package <https://github.com/ankane/xgb>
|
||||||
Julia package <julia>
|
Julia package <julia>
|
||||||
|
C Package <c>
|
||||||
|
C++ Interface <c++>
|
||||||
CLI interface <cli>
|
CLI interface <cli>
|
||||||
contrib/index
|
contrib/index
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
#include <dmlc/data.h>
|
#include <dmlc/data.h>
|
||||||
#include <rabit/rabit.h>
|
#include <rabit/rabit.h>
|
||||||
#include <xgboost/base.h>
|
#include <xgboost/base.h>
|
||||||
|
#include <xgboost/span.h>
|
||||||
|
#include <xgboost/host_device_vector.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
@ -19,10 +21,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../../src/common/span.h"
|
|
||||||
#include "../../src/common/group_data.h"
|
|
||||||
#include "../../src/common/host_device_vector.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
// forward declare learner.
|
// forward declare learner.
|
||||||
class LearnerImpl;
|
class LearnerImpl;
|
||||||
@ -214,35 +212,7 @@ class SparsePage {
|
|||||||
data.HostVector().clear();
|
data.HostVector().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
SparsePage GetTranspose(int num_columns) const {
|
SparsePage GetTranspose(int num_columns) const;
|
||||||
SparsePage transpose;
|
|
||||||
common::ParallelGroupBuilder<Entry> builder(&transpose.offset.HostVector(),
|
|
||||||
&transpose.data.HostVector());
|
|
||||||
const int nthread = omp_get_max_threads();
|
|
||||||
builder.InitBudget(num_columns, nthread);
|
|
||||||
long batch_size = static_cast<long>(this->Size()); // NOLINT(*)
|
|
||||||
#pragma omp parallel for default(none) shared(batch_size, builder) schedule(static)
|
|
||||||
for (long i = 0; i < batch_size; ++i) { // NOLINT(*)
|
|
||||||
int tid = omp_get_thread_num();
|
|
||||||
auto inst = (*this)[i];
|
|
||||||
for (const auto& entry : inst) {
|
|
||||||
builder.AddBudget(entry.index, tid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
builder.InitStorage();
|
|
||||||
#pragma omp parallel for default(none) shared(batch_size, builder) schedule(static)
|
|
||||||
for (long i = 0; i < batch_size; ++i) { // NOLINT(*)
|
|
||||||
int tid = omp_get_thread_num();
|
|
||||||
auto inst = (*this)[i];
|
|
||||||
for (const auto& entry : inst) {
|
|
||||||
builder.Push(
|
|
||||||
entry.index,
|
|
||||||
Entry(static_cast<bst_uint>(this->base_rowid + i), entry.fvalue),
|
|
||||||
tid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return transpose;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SortRows() {
|
void SortRows() {
|
||||||
auto ncol = static_cast<bst_omp_uint>(this->Size());
|
auto ncol = static_cast<bst_omp_uint>(this->Size());
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include <xgboost/objective.h>
|
#include <xgboost/objective.h>
|
||||||
#include <xgboost/feature_map.h>
|
#include <xgboost/feature_map.h>
|
||||||
#include <xgboost/generic_parameters.h>
|
#include <xgboost/generic_parameters.h>
|
||||||
|
#include <xgboost/host_device_vector.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -21,8 +22,6 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "../../src/common/host_device_vector.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
/*!
|
/*!
|
||||||
* \brief interface of gradient boosting model.
|
* \brief interface of gradient boosting model.
|
||||||
|
|||||||
@ -44,31 +44,16 @@
|
|||||||
* 'HostDeviceVector' with a special-case implementation in host_device_vector.cc
|
* 'HostDeviceVector' with a special-case implementation in host_device_vector.cc
|
||||||
*
|
*
|
||||||
* @note: Size and Devices methods are thread-safe.
|
* @note: Size and Devices methods are thread-safe.
|
||||||
* DevicePointer, DeviceStart, DeviceSize, tbegin and tend methods are thread-safe
|
|
||||||
* if different threads call these methods with different values of the device argument.
|
|
||||||
* All other methods are not thread safe.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef XGBOOST_COMMON_HOST_DEVICE_VECTOR_H_
|
#ifndef XGBOOST_HOST_DEVICE_VECTOR_H_
|
||||||
#define XGBOOST_COMMON_HOST_DEVICE_VECTOR_H_
|
#define XGBOOST_HOST_DEVICE_VECTOR_H_
|
||||||
|
|
||||||
#include <dmlc/logging.h>
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "span.h"
|
#include "span.h"
|
||||||
|
|
||||||
// only include thrust-related files if host_device_vector.h
|
|
||||||
// is included from a .cu file
|
|
||||||
#ifdef __CUDACC__
|
|
||||||
#include <thrust/device_ptr.h>
|
|
||||||
#endif // __CUDACC__
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
@ -118,19 +103,6 @@ class HostDeviceVector {
|
|||||||
const T* ConstHostPointer() const { return ConstHostVector().data(); }
|
const T* ConstHostPointer() const { return ConstHostVector().data(); }
|
||||||
const T* HostPointer() const { return ConstHostPointer(); }
|
const T* HostPointer() const { return ConstHostPointer(); }
|
||||||
|
|
||||||
// only define functions returning device_ptr
|
|
||||||
// if HostDeviceVector.h is included from a .cu file
|
|
||||||
#ifdef __CUDACC__
|
|
||||||
thrust::device_ptr<T> tbegin(); // NOLINT
|
|
||||||
thrust::device_ptr<T> tend(); // NOLINT
|
|
||||||
thrust::device_ptr<const T> tcbegin() const; // NOLINT
|
|
||||||
thrust::device_ptr<const T> tcend() const; // NOLINT
|
|
||||||
thrust::device_ptr<const T> tbegin() const { // NOLINT
|
|
||||||
return tcbegin();
|
|
||||||
}
|
|
||||||
thrust::device_ptr<const T> tend() const { return tcend(); } // NOLINT
|
|
||||||
#endif // __CUDACC__
|
|
||||||
|
|
||||||
void Fill(T v);
|
void Fill(T v);
|
||||||
void Copy(const HostDeviceVector<T>& other);
|
void Copy(const HostDeviceVector<T>& other);
|
||||||
void Copy(const std::vector<T>& other);
|
void Copy(const std::vector<T>& other);
|
||||||
@ -155,4 +127,4 @@ class HostDeviceVector {
|
|||||||
|
|
||||||
} // namespace xgboost
|
} // namespace xgboost
|
||||||
|
|
||||||
#endif // XGBOOST_COMMON_HOST_DEVICE_VECTOR_H_
|
#endif // XGBOOST_HOST_DEVICE_VECTOR_H_
|
||||||
@ -7,14 +7,20 @@
|
|||||||
#include <xgboost/base.h>
|
#include <xgboost/base.h>
|
||||||
#include <xgboost/data.h>
|
#include <xgboost/data.h>
|
||||||
#include <xgboost/generic_parameters.h>
|
#include <xgboost/generic_parameters.h>
|
||||||
|
#include <xgboost/host_device_vector.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../../src/gbm/gblinear_model.h"
|
|
||||||
#include "../../src/common/host_device_vector.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|
||||||
|
namespace gbm {
|
||||||
|
class GBLinearModel;
|
||||||
|
} // namespace gbm
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief interface of linear updater
|
* \brief interface of linear updater
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -11,14 +11,13 @@
|
|||||||
#include <xgboost/generic_parameters.h>
|
#include <xgboost/generic_parameters.h>
|
||||||
#include <xgboost/data.h>
|
#include <xgboost/data.h>
|
||||||
#include <xgboost/base.h>
|
#include <xgboost/base.h>
|
||||||
|
#include <xgboost/host_device_vector.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "../../src/common/host_device_vector.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
/*!
|
/*!
|
||||||
* \brief interface of evaluation metric used to evaluate model performance.
|
* \brief interface of evaluation metric used to evaluate model performance.
|
||||||
|
|||||||
@ -11,14 +11,13 @@
|
|||||||
#include <xgboost/base.h>
|
#include <xgboost/base.h>
|
||||||
#include <xgboost/data.h>
|
#include <xgboost/data.h>
|
||||||
#include <xgboost/generic_parameters.h>
|
#include <xgboost/generic_parameters.h>
|
||||||
|
#include <xgboost/host_device_vector.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "../../src/common/host_device_vector.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|
||||||
/*! \brief interface of objective function */
|
/*! \brief interface of objective function */
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
#include <xgboost/base.h>
|
#include <xgboost/base.h>
|
||||||
#include <xgboost/data.h>
|
#include <xgboost/data.h>
|
||||||
#include <xgboost/generic_parameters.h>
|
#include <xgboost/generic_parameters.h>
|
||||||
|
#include <xgboost/host_device_vector.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -16,12 +17,12 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../../src/gbm/gbtree_model.h"
|
|
||||||
#include "../../src/common/host_device_vector.h"
|
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
class TreeUpdater;
|
class TreeUpdater;
|
||||||
|
namespace gbm {
|
||||||
|
class GBTreeModel;
|
||||||
|
} // namespace gbm
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|||||||
@ -26,8 +26,8 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef XGBOOST_COMMON_SPAN_H_
|
#ifndef XGBOOST_SPAN_H_
|
||||||
#define XGBOOST_COMMON_SPAN_H_
|
#define XGBOOST_SPAN_H_
|
||||||
|
|
||||||
#include <xgboost/logging.h> // CHECK
|
#include <xgboost/logging.h> // CHECK
|
||||||
|
|
||||||
@ -637,4 +637,4 @@ XGBOOST_DEVICE auto as_writable_bytes(Span<T, E> s) __span_noexcept -> // NOLIN
|
|||||||
#undef __span_noexcept
|
#undef __span_noexcept
|
||||||
#endif // _MSC_VER < 1910
|
#endif // _MSC_VER < 1910
|
||||||
|
|
||||||
#endif // XGBOOST_COMMON_SPAN_H_
|
#endif // XGBOOST_SPAN_H_
|
||||||
@ -1,5 +1,5 @@
|
|||||||
/*!
|
/*!
|
||||||
* Copyright 2014 by Contributors
|
* Copyright 2014-2019 by Contributors
|
||||||
* \file tree_model.h
|
* \file tree_model.h
|
||||||
* \brief model structure for tree
|
* \brief model structure for tree
|
||||||
* \author Tianqi Chen
|
* \author Tianqi Chen
|
||||||
@ -9,16 +9,18 @@
|
|||||||
|
|
||||||
#include <dmlc/io.h>
|
#include <dmlc/io.h>
|
||||||
#include <dmlc/parameter.h>
|
#include <dmlc/parameter.h>
|
||||||
|
|
||||||
|
#include <xgboost/base.h>
|
||||||
|
#include <xgboost/data.h>
|
||||||
|
#include <xgboost/logging.h>
|
||||||
|
#include <xgboost/feature_map.h>
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include "./base.h"
|
|
||||||
#include "./data.h"
|
|
||||||
#include "./logging.h"
|
|
||||||
#include "./feature_map.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|
||||||
|
|||||||
@ -13,14 +13,13 @@
|
|||||||
#include <xgboost/data.h>
|
#include <xgboost/data.h>
|
||||||
#include <xgboost/tree_model.h>
|
#include <xgboost/tree_model.h>
|
||||||
#include <xgboost/generic_parameters.h>
|
#include <xgboost/generic_parameters.h>
|
||||||
|
#include <xgboost/host_device_vector.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "../../src/common/host_device_vector.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
/*!
|
/*!
|
||||||
* \brief interface of tree update module, that performs update of a tree.
|
* \brief interface of tree update module, that performs update of a tree.
|
||||||
|
|||||||
@ -13,7 +13,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "span.h"
|
#if defined(__CUDACC__)
|
||||||
|
#include <thrust/copy.h>
|
||||||
|
#include <thrust/device_ptr.h>
|
||||||
|
#endif // defined(__CUDACC__)
|
||||||
|
|
||||||
|
#include "xgboost/span.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|
||||||
|
|||||||
@ -11,8 +11,10 @@
|
|||||||
#include <rabit/rabit.h>
|
#include <rabit/rabit.h>
|
||||||
#include <cub/util_allocator.cuh>
|
#include <cub/util_allocator.cuh>
|
||||||
|
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
|
#include "xgboost/span.h"
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "span.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
@ -1132,6 +1134,27 @@ xgboost::common::Span<T> ToSpan(thrust::device_vector<T>& vec,
|
|||||||
return ToSpan(vec, static_cast<IndexT>(offset), static_cast<IndexT>(size));
|
return ToSpan(vec, static_cast<IndexT>(offset), static_cast<IndexT>(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// thrust begin, similiar to std::begin
|
||||||
|
template <typename T>
|
||||||
|
thrust::device_ptr<T> tbegin(xgboost::HostDeviceVector<T>& vector) { // NOLINT
|
||||||
|
return thrust::device_ptr<T>(vector.DevicePointer());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
thrust::device_ptr<T> tend(xgboost::HostDeviceVector<T>& vector) { // // NOLINT
|
||||||
|
return tbegin(vector) + vector.Size();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
thrust::device_ptr<T const> tcbegin(xgboost::HostDeviceVector<T> const& vector) {
|
||||||
|
return thrust::device_ptr<T const>(vector.ConstDevicePointer());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
thrust::device_ptr<T const> tcend(xgboost::HostDeviceVector<T> const& vector) {
|
||||||
|
return tcbegin(vector) + vector.Size();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename FunctionT>
|
template <typename FunctionT>
|
||||||
class LauncherItr {
|
class LauncherItr {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -8,6 +8,8 @@
|
|||||||
#include <dmlc/omp.h>
|
#include <dmlc/omp.h>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../common/common.h"
|
||||||
#include "./random.h"
|
#include "./random.h"
|
||||||
#include "./column_matrix.h"
|
#include "./column_matrix.h"
|
||||||
#include "./quantile.h"
|
#include "./quantile.h"
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
* Copyright 2018 XGBoost contributors
|
* Copyright 2018 XGBoost contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "./hist_util.h"
|
|
||||||
#include <xgboost/logging.h>
|
#include <xgboost/logging.h>
|
||||||
|
|
||||||
#include <thrust/copy.h>
|
#include <thrust/copy.h>
|
||||||
@ -17,10 +16,11 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
#include "hist_util.h"
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
|
#include "device_helpers.cuh"
|
||||||
|
#include "quantile.h"
|
||||||
#include "../tree/param.h"
|
#include "../tree/param.h"
|
||||||
#include "./host_device_vector.h"
|
|
||||||
#include "./device_helpers.cuh"
|
|
||||||
#include "./quantile.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
namespace common {
|
namespace common {
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
#include <xgboost/data.h>
|
#include <xgboost/data.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "./host_device_vector.h"
|
#include "xgboost/host_device_vector.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|
||||||
|
|||||||
@ -2,13 +2,16 @@
|
|||||||
* Copyright 2017 XGBoost contributors
|
* Copyright 2017 XGBoost contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "./host_device_vector.h"
|
|
||||||
#include <thrust/fill.h>
|
#include <thrust/fill.h>
|
||||||
#include <xgboost/data.h>
|
#include <thrust/device_ptr.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "./device_helpers.cuh"
|
|
||||||
|
#include "xgboost/data.h"
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
|
#include "device_helpers.cuh"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|
||||||
@ -75,22 +78,6 @@ class HostDeviceVectorImpl {
|
|||||||
return {data_d_.data().get(), static_cast<SpanInd>(Size())};
|
return {data_d_.data().get(), static_cast<SpanInd>(Size())};
|
||||||
}
|
}
|
||||||
|
|
||||||
thrust::device_ptr<T> tbegin() { // NOLINT
|
|
||||||
return thrust::device_ptr<T>(DevicePointer());
|
|
||||||
}
|
|
||||||
|
|
||||||
thrust::device_ptr<const T> tcbegin() { // NOLINT
|
|
||||||
return thrust::device_ptr<const T>(ConstDevicePointer());
|
|
||||||
}
|
|
||||||
|
|
||||||
thrust::device_ptr<T> tend() { // NOLINT
|
|
||||||
return tbegin() + Size();
|
|
||||||
}
|
|
||||||
|
|
||||||
thrust::device_ptr<const T> tcend() { // NOLINT
|
|
||||||
return tcbegin() + Size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fill(T v) { // NOLINT
|
void Fill(T v) { // NOLINT
|
||||||
if (HostCanWrite()) {
|
if (HostCanWrite()) {
|
||||||
std::fill(data_h_.begin(), data_h_.end(), v);
|
std::fill(data_h_.begin(), data_h_.end(), v);
|
||||||
@ -304,26 +291,6 @@ common::Span<const T> HostDeviceVector<T>::ConstDeviceSpan() const {
|
|||||||
return impl_->ConstDeviceSpan();
|
return impl_->ConstDeviceSpan();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
thrust::device_ptr<T> HostDeviceVector<T>::tbegin() { // NOLINT
|
|
||||||
return impl_->tbegin();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
thrust::device_ptr<const T> HostDeviceVector<T>::tcbegin() const { // NOLINT
|
|
||||||
return impl_->tcbegin();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
thrust::device_ptr<T> HostDeviceVector<T>::tend() { // NOLINT
|
|
||||||
return impl_->tend();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
thrust::device_ptr<const T> HostDeviceVector<T>::tcend() const { // NOLINT
|
|
||||||
return impl_->tcend();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void HostDeviceVector<T>::Fill(T v) {
|
void HostDeviceVector<T>::Fill(T v) {
|
||||||
impl_->Fill(v);
|
impl_->Fill(v);
|
||||||
|
|||||||
@ -17,8 +17,8 @@
|
|||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "host_device_vector.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
namespace common {
|
namespace common {
|
||||||
@ -113,7 +113,7 @@ class ColumnSampler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* \brief Column sampler constructor.
|
* \brief Column sampler constructor.
|
||||||
* \note This constructor manually sets the rng seed
|
* \note This constructor manually sets the rng seed
|
||||||
*/
|
*/
|
||||||
@ -169,7 +169,7 @@ class ColumnSampler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Samples a feature set.
|
* \brief Samples a feature set.
|
||||||
*
|
*
|
||||||
* \param depth The tree depth of the node at which to sample.
|
* \param depth The tree depth of the node at which to sample.
|
||||||
* \return The sampled feature set.
|
* \return The sampled feature set.
|
||||||
* \note If colsample_bynode_ < 1.0, this method creates a new feature set each time it
|
* \note If colsample_bynode_ < 1.0, this method creates a new feature set each time it
|
||||||
|
|||||||
@ -10,9 +10,10 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <type_traits> // enable_if
|
#include <type_traits> // enable_if
|
||||||
|
|
||||||
#include "host_device_vector.h"
|
#include "xgboost/host_device_vector.h"
|
||||||
|
#include "xgboost/span.h"
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "span.h"
|
|
||||||
|
|
||||||
#if defined (__CUDACC__)
|
#if defined (__CUDACC__)
|
||||||
#include "device_helpers.cuh"
|
#include "device_helpers.cuh"
|
||||||
|
|||||||
@ -13,7 +13,8 @@
|
|||||||
#include "xgboost/data.h"
|
#include "xgboost/data.h"
|
||||||
#include "xgboost/json.h"
|
#include "xgboost/json.h"
|
||||||
#include "xgboost/logging.h"
|
#include "xgboost/logging.h"
|
||||||
#include "../common/span.h"
|
#include "xgboost/span.h"
|
||||||
|
|
||||||
#include "../common/bitfield.h"
|
#include "../common/bitfield.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#include "./simple_dmatrix.h"
|
#include "./simple_dmatrix.h"
|
||||||
#include "./simple_csr_source.h"
|
#include "./simple_csr_source.h"
|
||||||
#include "../common/io.h"
|
#include "../common/io.h"
|
||||||
|
#include "../common/group_data.h"
|
||||||
|
|
||||||
#if DMLC_ENABLE_STD_THREAD
|
#if DMLC_ENABLE_STD_THREAD
|
||||||
#include "./sparse_page_source.h"
|
#include "./sparse_page_source.h"
|
||||||
@ -322,7 +323,35 @@ data::SparsePageFormat::DecideFormat(const std::string& cache_prefix) {
|
|||||||
return std::make_pair(raw, raw);
|
return std::make_pair(raw, raw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SparsePage SparsePage::GetTranspose(int num_columns) const {
|
||||||
|
SparsePage transpose;
|
||||||
|
common::ParallelGroupBuilder<Entry> builder(&transpose.offset.HostVector(),
|
||||||
|
&transpose.data.HostVector());
|
||||||
|
const int nthread = omp_get_max_threads();
|
||||||
|
builder.InitBudget(num_columns, nthread);
|
||||||
|
long batch_size = static_cast<long>(this->Size()); // NOLINT(*)
|
||||||
|
#pragma omp parallel for default(none) shared(batch_size, builder) schedule(static)
|
||||||
|
for (long i = 0; i < batch_size; ++i) { // NOLINT(*)
|
||||||
|
int tid = omp_get_thread_num();
|
||||||
|
auto inst = (*this)[i];
|
||||||
|
for (const auto& entry : inst) {
|
||||||
|
builder.AddBudget(entry.index, tid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder.InitStorage();
|
||||||
|
#pragma omp parallel for default(none) shared(batch_size, builder) schedule(static)
|
||||||
|
for (long i = 0; i < batch_size; ++i) { // NOLINT(*)
|
||||||
|
int tid = omp_get_thread_num();
|
||||||
|
auto inst = (*this)[i];
|
||||||
|
for (const auto& entry : inst) {
|
||||||
|
builder.Push(
|
||||||
|
entry.index,
|
||||||
|
Entry(static_cast<bst_uint>(this->base_rowid + i), entry.fvalue),
|
||||||
|
tid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return transpose;
|
||||||
|
}
|
||||||
void SparsePage::Push(const SparsePage &batch) {
|
void SparsePage::Push(const SparsePage &batch) {
|
||||||
auto& data_vec = data.HostVector();
|
auto& data_vec = data.HostVector();
|
||||||
auto& offset_vec = offset.HostVector();
|
auto& offset_vec = offset.HostVector();
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "sparse_page_writer.h"
|
#include "sparse_page_writer.h"
|
||||||
|
#include "../common/common.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|||||||
@ -10,10 +10,13 @@
|
|||||||
#include <xgboost/gbm.h>
|
#include <xgboost/gbm.h>
|
||||||
#include <xgboost/logging.h>
|
#include <xgboost/logging.h>
|
||||||
#include <xgboost/linear_updater.h>
|
#include <xgboost/linear_updater.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "gblinear_model.h"
|
||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|||||||
@ -6,11 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
#include <dmlc/omp.h>
|
#include <dmlc/omp.h>
|
||||||
#include <dmlc/parameter.h>
|
#include <dmlc/parameter.h>
|
||||||
#include <dmlc/timer.h>
|
|
||||||
#include <xgboost/logging.h>
|
|
||||||
#include <xgboost/gbm.h>
|
|
||||||
#include <xgboost/predictor.h>
|
|
||||||
#include <xgboost/tree_updater.h>
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -19,11 +14,16 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "../common/common.h"
|
#include "xgboost/logging.h"
|
||||||
#include "../common/host_device_vector.h"
|
#include "xgboost/gbm.h"
|
||||||
#include "../common/random.h"
|
#include "xgboost/predictor.h"
|
||||||
|
#include "xgboost/tree_updater.h"
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
|
|
||||||
#include "gbtree.h"
|
#include "gbtree.h"
|
||||||
#include "gbtree_model.h"
|
#include "gbtree_model.h"
|
||||||
|
#include "../common/common.h"
|
||||||
|
#include "../common/random.h"
|
||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,8 +23,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "gbtree_model.h"
|
#include "gbtree_model.h"
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
|
|
||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
#include "../common/host_device_vector.h"
|
|
||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|||||||
@ -19,11 +19,12 @@
|
|||||||
#include <ios>
|
#include <ios>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "./common/common.h"
|
|
||||||
#include "./common/host_device_vector.h"
|
#include "xgboost/host_device_vector.h"
|
||||||
#include "./common/io.h"
|
#include "common/common.h"
|
||||||
#include "./common/random.h"
|
#include "common/io.h"
|
||||||
#include "./common/timer.h"
|
#include "common/random.h"
|
||||||
|
#include "common/timer.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|||||||
@ -7,12 +7,13 @@
|
|||||||
#include <thrust/inner_product.h>
|
#include <thrust/inner_product.h>
|
||||||
#include <xgboost/data.h>
|
#include <xgboost/data.h>
|
||||||
#include <xgboost/linear_updater.h>
|
#include <xgboost/linear_updater.h>
|
||||||
|
#include "xgboost/span.h"
|
||||||
|
|
||||||
|
#include "coordinate_common.h"
|
||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
#include "../common/span.h"
|
|
||||||
#include "../common/device_helpers.cuh"
|
#include "../common/device_helpers.cuh"
|
||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
#include "./param.h"
|
#include "./param.h"
|
||||||
#include "coordinate_common.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
namespace linear {
|
namespace linear {
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../common/host_device_vector.h"
|
#include "xgboost/host_device_vector.h"
|
||||||
#include "../common/math.h"
|
#include "../common/math.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|||||||
@ -4,12 +4,13 @@
|
|||||||
* \brief Provides an implementation of the hinge loss function
|
* \brief Provides an implementation of the hinge loss function
|
||||||
* \author Henry Gouk
|
* \author Henry Gouk
|
||||||
*/
|
*/
|
||||||
#include <xgboost/objective.h>
|
#include "xgboost/objective.h"
|
||||||
|
#include "xgboost/span.h"
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
|
|
||||||
#include "../common/math.h"
|
#include "../common/math.h"
|
||||||
#include "../common/transform.h"
|
#include "../common/transform.h"
|
||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
#include "../common/span.h"
|
|
||||||
#include "../common/host_device_vector.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
namespace obj {
|
namespace obj {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include <xgboost/objective.h>
|
#include <xgboost/objective.h>
|
||||||
#include <dmlc/registry.h>
|
#include <dmlc/registry.h>
|
||||||
|
|
||||||
#include "../common/host_device_vector.h"
|
#include "xgboost/host_device_vector.h"
|
||||||
|
|
||||||
namespace dmlc {
|
namespace dmlc {
|
||||||
DMLC_REGISTRY_ENABLE(::xgboost::ObjFunctionReg);
|
DMLC_REGISTRY_ENABLE(::xgboost::ObjFunctionReg);
|
||||||
|
|||||||
@ -12,10 +12,11 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../common/span.h"
|
#include "xgboost/span.h"
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
|
|
||||||
#include "../common/transform.h"
|
#include "../common/transform.h"
|
||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
#include "../common/host_device_vector.h"
|
|
||||||
#include "./regression_loss.h"
|
#include "./regression_loss.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
/*!
|
/*!
|
||||||
* Copyright by Contributors 2017
|
* Copyright by Contributors 2017
|
||||||
*/
|
*/
|
||||||
#include <xgboost/predictor.h>
|
#include "xgboost/predictor.h"
|
||||||
#include <xgboost/tree_model.h>
|
#include "xgboost/tree_model.h"
|
||||||
#include <xgboost/tree_updater.h>
|
#include "xgboost/tree_updater.h"
|
||||||
#include "dmlc/logging.h"
|
#include "xgboost/logging.h"
|
||||||
#include "../common/host_device_vector.h"
|
#include "xgboost/host_device_vector.h"
|
||||||
|
|
||||||
|
#include "../gbm/gbtree_model.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
namespace predictor {
|
namespace predictor {
|
||||||
|
|||||||
@ -6,14 +6,17 @@
|
|||||||
#include <thrust/device_ptr.h>
|
#include <thrust/device_ptr.h>
|
||||||
#include <thrust/device_vector.h>
|
#include <thrust/device_vector.h>
|
||||||
#include <thrust/fill.h>
|
#include <thrust/fill.h>
|
||||||
#include <xgboost/data.h>
|
|
||||||
#include <xgboost/predictor.h>
|
|
||||||
#include <xgboost/tree_model.h>
|
|
||||||
#include <xgboost/tree_updater.h>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "xgboost/data.h"
|
||||||
|
#include "xgboost/predictor.h"
|
||||||
|
#include "xgboost/tree_model.h"
|
||||||
|
#include "xgboost/tree_updater.h"
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
|
|
||||||
|
#include "../gbm/gbtree_model.h"
|
||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
#include "../common/device_helpers.cuh"
|
#include "../common/device_helpers.cuh"
|
||||||
#include "../common/host_device_vector.h"
|
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
namespace predictor {
|
namespace predictor {
|
||||||
|
|||||||
@ -6,17 +6,16 @@
|
|||||||
#include <thrust/execution_policy.h>
|
#include <thrust/execution_policy.h>
|
||||||
#include <thrust/iterator/counting_iterator.h>
|
#include <thrust/iterator/counting_iterator.h>
|
||||||
|
|
||||||
#include <xgboost/logging.h>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
#include "xgboost/logging.h"
|
||||||
|
#include "xgboost/span.h"
|
||||||
#include "constraints.cuh"
|
#include "constraints.cuh"
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
#include "../common/span.h"
|
|
||||||
#include "../common/device_helpers.cuh"
|
#include "../common/device_helpers.cuh"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
#include "../common/span.h"
|
#include "xgboost/span.h"
|
||||||
#include "../common/bitfield.h"
|
#include "../common/bitfield.h"
|
||||||
#include "../common/device_helpers.cuh"
|
#include "../common/device_helpers.cuh"
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,8 @@
|
|||||||
* \file split_evaluator.cc
|
* \file split_evaluator.cc
|
||||||
* \brief Contains implementations of different split evaluators.
|
* \brief Contains implementations of different split evaluators.
|
||||||
*/
|
*/
|
||||||
#include "split_evaluator.h"
|
|
||||||
#include <dmlc/json.h>
|
#include <dmlc/json.h>
|
||||||
#include <dmlc/registry.h>
|
#include <dmlc/registry.h>
|
||||||
#include <xgboost/logging.h>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -15,9 +13,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "xgboost/logging.h"
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
|
#include "split_evaluator.h"
|
||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
#include "../common/host_device_vector.h"
|
|
||||||
|
|
||||||
namespace dmlc {
|
namespace dmlc {
|
||||||
DMLC_REGISTRY_ENABLE(::xgboost::tree::SplitEvaluatorReg);
|
DMLC_REGISTRY_ENABLE(::xgboost::tree::SplitEvaluatorReg);
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
* \file tree_updater.cc
|
* \file tree_updater.cc
|
||||||
* \brief Registry of tree updaters.
|
* \brief Registry of tree updaters.
|
||||||
*/
|
*/
|
||||||
#include <xgboost/tree_updater.h>
|
|
||||||
#include <dmlc/registry.h>
|
#include <dmlc/registry.h>
|
||||||
|
|
||||||
#include "../common/host_device_vector.h"
|
#include "xgboost/tree_updater.h"
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
|
|
||||||
namespace dmlc {
|
namespace dmlc {
|
||||||
DMLC_REGISTRY_ENABLE(::xgboost::TreeUpdaterReg);
|
DMLC_REGISTRY_ENABLE(::xgboost::TreeUpdaterReg);
|
||||||
|
|||||||
@ -14,13 +14,15 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "xgboost/host_device_vector.h"
|
||||||
|
#include "xgboost/span.h"
|
||||||
|
|
||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
#include "../common/compressed_iterator.h"
|
#include "../common/compressed_iterator.h"
|
||||||
#include "../common/device_helpers.cuh"
|
#include "../common/device_helpers.cuh"
|
||||||
#include "../common/hist_util.h"
|
#include "../common/hist_util.h"
|
||||||
#include "../common/host_device_vector.h"
|
|
||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
#include "../common/span.h"
|
|
||||||
#include "../data/ellpack_page.cuh"
|
#include "../data/ellpack_page.cuh"
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
#include "updater_gpu_common.cuh"
|
#include "updater_gpu_common.cuh"
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
#include <thrust/iterator/counting_iterator.h>
|
#include <thrust/iterator/counting_iterator.h>
|
||||||
|
|
||||||
#include "../../../src/common/device_helpers.cuh"
|
#include "../../../src/common/device_helpers.cuh"
|
||||||
#include "../../../src/common/host_device_vector.h"
|
#include <xgboost/host_device_vector.h>
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
namespace common {
|
namespace common {
|
||||||
@ -58,7 +58,7 @@ void InitHostDeviceVector(size_t n, int device, HostDeviceVector<int> *v) {
|
|||||||
void PlusOne(HostDeviceVector<int> *v) {
|
void PlusOne(HostDeviceVector<int> *v) {
|
||||||
int device = v->DeviceIdx();
|
int device = v->DeviceIdx();
|
||||||
SetDevice(device);
|
SetDevice(device);
|
||||||
thrust::transform(v->tbegin(), v->tend(), v->tbegin(),
|
thrust::transform(dh::tcbegin(*v), dh::tcend(*v), dh::tbegin(*v),
|
||||||
[=]__device__(unsigned int a){ return a + 1; });
|
[=]__device__(unsigned int a){ return a + 1; });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ void CheckDevice(HostDeviceVector<int>* v,
|
|||||||
ASSERT_EQ(v->Size(), size);
|
ASSERT_EQ(v->Size(), size);
|
||||||
SetDevice(v->DeviceIdx());
|
SetDevice(v->DeviceIdx());
|
||||||
|
|
||||||
ASSERT_TRUE(thrust::equal(v->tcbegin(), v->tcend(),
|
ASSERT_TRUE(thrust::equal(dh::tcbegin(*v), dh::tcend(*v),
|
||||||
thrust::make_counting_iterator(first)));
|
thrust::make_counting_iterator(first)));
|
||||||
ASSERT_TRUE(v->DeviceCanRead());
|
ASSERT_TRUE(v->DeviceCanRead());
|
||||||
// ensure that the device has at most the access specified by access
|
// ensure that the device has at most the access specified by access
|
||||||
@ -77,7 +77,7 @@ void CheckDevice(HostDeviceVector<int>* v,
|
|||||||
ASSERT_EQ(v->HostCanRead(), access == GPUAccess::kRead);
|
ASSERT_EQ(v->HostCanRead(), access == GPUAccess::kRead);
|
||||||
ASSERT_FALSE(v->HostCanWrite());
|
ASSERT_FALSE(v->HostCanWrite());
|
||||||
|
|
||||||
ASSERT_TRUE(thrust::equal(v->tbegin(), v->tend(),
|
ASSERT_TRUE(thrust::equal(dh::tbegin(*v), dh::tend(*v),
|
||||||
thrust::make_counting_iterator(first)));
|
thrust::make_counting_iterator(first)));
|
||||||
ASSERT_TRUE(v->DeviceCanRead());
|
ASSERT_TRUE(v->DeviceCanRead());
|
||||||
ASSERT_TRUE(v->DeviceCanWrite());
|
ASSERT_TRUE(v->DeviceCanWrite());
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../../../src/common/span.h"
|
#include <xgboost/span.h>
|
||||||
#include "test_span.h"
|
#include "test_span.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
#include <thrust/execution_policy.h>
|
#include <thrust/execution_policy.h>
|
||||||
|
|
||||||
#include "../../../src/common/device_helpers.cuh"
|
#include "../../../src/common/device_helpers.cuh"
|
||||||
#include "../../../src/common/span.h"
|
#include <xgboost/span.h>
|
||||||
#include "test_span.h"
|
#include "test_span.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|||||||
@ -4,8 +4,8 @@
|
|||||||
#ifndef XGBOOST_TEST_SPAN_H_
|
#ifndef XGBOOST_TEST_SPAN_H_
|
||||||
#define XGBOOST_TEST_SPAN_H_
|
#define XGBOOST_TEST_SPAN_H_
|
||||||
|
|
||||||
#include "../../include/xgboost/base.h"
|
#include <xgboost/base.h>
|
||||||
#include "../../../src/common/span.h"
|
#include <xgboost/span.h>
|
||||||
|
|
||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
XGBOOST_DEVICE void InitializeRange(Iter _begin, Iter _end) {
|
XGBOOST_DEVICE void InitializeRange(Iter _begin, Iter _end) {
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
#include <xgboost/base.h>
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#include <xgboost/base.h>
|
||||||
|
#include <xgboost/span.h>
|
||||||
|
#include <xgboost/host_device_vector.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../../../src/common/host_device_vector.h"
|
|
||||||
#include "../../../src/common/transform.h"
|
#include "../../../src/common/transform.h"
|
||||||
#include "../../../src/common/span.h"
|
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
|
|
||||||
#if defined(__CUDACC__)
|
#if defined(__CUDACC__)
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
#include "xgboost/c_api.h"
|
#include "xgboost/c_api.h"
|
||||||
|
|
||||||
#include "../../src/data/simple_csr_source.h"
|
#include "../../src/data/simple_csr_source.h"
|
||||||
|
#include "../../src/gbm/gbtree_model.h"
|
||||||
|
|
||||||
bool FileExists(const std::string& filename) {
|
bool FileExists(const std::string& filename) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|||||||
@ -2,8 +2,11 @@
|
|||||||
* Copyright 2018-2019 by Contributors
|
* Copyright 2018-2019 by Contributors
|
||||||
*/
|
*/
|
||||||
#include <xgboost/linear_updater.h>
|
#include <xgboost/linear_updater.h>
|
||||||
|
#include <xgboost/gbm.h>
|
||||||
|
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
#include "xgboost/gbm.h"
|
|
||||||
|
#include "../../../src/gbm/gblinear_model.h"
|
||||||
|
|
||||||
TEST(Linear, shotgun) {
|
TEST(Linear, shotgun) {
|
||||||
auto mat = xgboost::CreateDMatrix(10, 10, 0);
|
auto mat = xgboost::CreateDMatrix(10, 10, 0);
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
// Copyright by Contributors
|
// Copyright by Contributors
|
||||||
#include <xgboost/linear_updater.h>
|
#include <xgboost/linear_updater.h>
|
||||||
|
#include <xgboost/gbm.h>
|
||||||
|
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
#include "xgboost/gbm.h"
|
#include "../../../src/gbm/gblinear_model.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,9 @@
|
|||||||
#include <dmlc/filesystem.h>
|
#include <dmlc/filesystem.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <xgboost/predictor.h>
|
#include <xgboost/predictor.h>
|
||||||
|
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
|
#include "../../../src/gbm/gbtree_model.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
TEST(cpu_predictor, Test) {
|
TEST(cpu_predictor, Test) {
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
|
#include "../../../src/gbm/gbtree_model.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2018-2019 by Contributors
|
* Copyright 2018-2019 by Contributors
|
||||||
*/
|
*/
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
#include "../../../src/common/host_device_vector.h"
|
#include <xgboost/host_device_vector.h>
|
||||||
#include <xgboost/tree_updater.h>
|
#include <xgboost/tree_updater.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
/*!
|
/*!
|
||||||
* Copyright 2018-2019 by Contributors
|
* Copyright 2018-2019 by Contributors
|
||||||
*/
|
*/
|
||||||
#include "../helpers.h"
|
#include <xgboost/host_device_vector.h>
|
||||||
#include "../../../src/tree/param.h"
|
|
||||||
#include "../../../src/tree/updater_quantile_hist.h"
|
|
||||||
#include "../../../src/tree/split_evaluator.h"
|
|
||||||
#include "../../../src/common/host_device_vector.h"
|
|
||||||
|
|
||||||
#include <xgboost/tree_updater.h>
|
#include <xgboost/tree_updater.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
@ -14,6 +9,11 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "../helpers.h"
|
||||||
|
#include "../../../src/tree/param.h"
|
||||||
|
#include "../../../src/tree/updater_quantile_hist.h"
|
||||||
|
#include "../../../src/tree/split_evaluator.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
namespace tree {
|
namespace tree {
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
/*!
|
/*!
|
||||||
* Copyright 2018-2019 by Contributors
|
* Copyright 2018-2019 by Contributors
|
||||||
*/
|
*/
|
||||||
#include "../helpers.h"
|
#include <xgboost/host_device_vector.h>
|
||||||
#include "../../../src/common/host_device_vector.h"
|
|
||||||
#include <xgboost/tree_updater.h>
|
#include <xgboost/tree_updater.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "../helpers.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
namespace tree {
|
namespace tree {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user