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:
Jiaming Yuan 2019-10-06 23:53:09 -04:00 committed by GitHub
parent 4ab1df5fe6
commit 095de3bf5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 240 additions and 209 deletions

View File

@ -187,11 +187,9 @@ if (BUILD_C_DOC)
endif (BUILD_C_DOC)
include(GNUInstallDirs)
# Exposing only C APIs.
install(FILES
"${PROJECT_SOURCE_DIR}/include/xgboost/c_api.h"
DESTINATION
include/xgboost/)
# Install all headers. Please note that currently the C++ headers does not form an "API".
install(DIRECTORY ${xgboost_SOURCE_DIR}/include/xgboost
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS xgboost runxgboost
EXPORT XGBoostTargets

View 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
View 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
View 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>`_

View File

@ -27,5 +27,7 @@ Contents
JVM package <jvm/index>
Ruby package <https://github.com/ankane/xgb>
Julia package <julia>
C Package <c>
C++ Interface <c++>
CLI interface <cli>
contrib/index

View File

@ -11,6 +11,8 @@
#include <dmlc/data.h>
#include <rabit/rabit.h>
#include <xgboost/base.h>
#include <xgboost/span.h>
#include <xgboost/host_device_vector.h>
#include <memory>
#include <numeric>
@ -19,10 +21,6 @@
#include <utility>
#include <vector>
#include "../../src/common/span.h"
#include "../../src/common/group_data.h"
#include "../../src/common/host_device_vector.h"
namespace xgboost {
// forward declare learner.
class LearnerImpl;
@ -214,35 +212,7 @@ class SparsePage {
data.HostVector().clear();
}
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;
}
SparsePage GetTranspose(int num_columns) const;
void SortRows() {
auto ncol = static_cast<bst_omp_uint>(this->Size());

View File

@ -14,6 +14,7 @@
#include <xgboost/objective.h>
#include <xgboost/feature_map.h>
#include <xgboost/generic_parameters.h>
#include <xgboost/host_device_vector.h>
#include <vector>
#include <utility>
@ -21,8 +22,6 @@
#include <functional>
#include <memory>
#include "../../src/common/host_device_vector.h"
namespace xgboost {
/*!
* \brief interface of gradient boosting model.

View File

@ -44,31 +44,16 @@
* 'HostDeviceVector' with a special-case implementation in host_device_vector.cc
*
* @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_
#define XGBOOST_COMMON_HOST_DEVICE_VECTOR_H_
#ifndef XGBOOST_HOST_DEVICE_VECTOR_H_
#define XGBOOST_HOST_DEVICE_VECTOR_H_
#include <dmlc/logging.h>
#include <algorithm>
#include <cstdlib>
#include <initializer_list>
#include <utility>
#include <vector>
#include "common.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 {
#ifdef __CUDACC__
@ -118,19 +103,6 @@ class HostDeviceVector {
const T* ConstHostPointer() const { return ConstHostVector().data(); }
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 Copy(const HostDeviceVector<T>& other);
void Copy(const std::vector<T>& other);
@ -155,4 +127,4 @@ class HostDeviceVector {
} // namespace xgboost
#endif // XGBOOST_COMMON_HOST_DEVICE_VECTOR_H_
#endif // XGBOOST_HOST_DEVICE_VECTOR_H_

View File

@ -7,14 +7,20 @@
#include <xgboost/base.h>
#include <xgboost/data.h>
#include <xgboost/generic_parameters.h>
#include <xgboost/host_device_vector.h>
#include <functional>
#include <string>
#include <utility>
#include <vector>
#include "../../src/gbm/gblinear_model.h"
#include "../../src/common/host_device_vector.h"
namespace xgboost {
namespace gbm {
class GBLinearModel;
} // namespace gbm
/*!
* \brief interface of linear updater
*/

View File

@ -11,14 +11,13 @@
#include <xgboost/generic_parameters.h>
#include <xgboost/data.h>
#include <xgboost/base.h>
#include <xgboost/host_device_vector.h>
#include <vector>
#include <string>
#include <functional>
#include <utility>
#include "../../src/common/host_device_vector.h"
namespace xgboost {
/*!
* \brief interface of evaluation metric used to evaluate model performance.

View File

@ -11,14 +11,13 @@
#include <xgboost/base.h>
#include <xgboost/data.h>
#include <xgboost/generic_parameters.h>
#include <xgboost/host_device_vector.h>
#include <vector>
#include <utility>
#include <string>
#include <functional>
#include "../../src/common/host_device_vector.h"
namespace xgboost {
/*! \brief interface of objective function */

View File

@ -8,6 +8,7 @@
#include <xgboost/base.h>
#include <xgboost/data.h>
#include <xgboost/generic_parameters.h>
#include <xgboost/host_device_vector.h>
#include <functional>
#include <memory>
@ -16,12 +17,12 @@
#include <utility>
#include <vector>
#include "../../src/gbm/gbtree_model.h"
#include "../../src/common/host_device_vector.h"
// Forward declarations
namespace xgboost {
class TreeUpdater;
namespace gbm {
class GBTreeModel;
} // namespace gbm
}
namespace xgboost {

View File

@ -26,8 +26,8 @@
* THE SOFTWARE.
*/
#ifndef XGBOOST_COMMON_SPAN_H_
#define XGBOOST_COMMON_SPAN_H_
#ifndef XGBOOST_SPAN_H_
#define XGBOOST_SPAN_H_
#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
#endif // _MSC_VER < 1910
#endif // XGBOOST_COMMON_SPAN_H_
#endif // XGBOOST_SPAN_H_

View File

@ -1,5 +1,5 @@
/*!
* Copyright 2014 by Contributors
* Copyright 2014-2019 by Contributors
* \file tree_model.h
* \brief model structure for tree
* \author Tianqi Chen
@ -9,16 +9,18 @@
#include <dmlc/io.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 <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <tuple>
#include "./base.h"
#include "./data.h"
#include "./logging.h"
#include "./feature_map.h"
namespace xgboost {

View File

@ -13,14 +13,13 @@
#include <xgboost/data.h>
#include <xgboost/tree_model.h>
#include <xgboost/generic_parameters.h>
#include <xgboost/host_device_vector.h>
#include <functional>
#include <vector>
#include <utility>
#include <string>
#include "../../src/common/host_device_vector.h"
namespace xgboost {
/*!
* \brief interface of tree update module, that performs update of a tree.

View File

@ -13,7 +13,12 @@
#include <string>
#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 {

View File

@ -11,8 +11,10 @@
#include <rabit/rabit.h>
#include <cub/util_allocator.cuh>
#include "xgboost/host_device_vector.h"
#include "xgboost/span.h"
#include "common.h"
#include "span.h"
#include <algorithm>
#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));
}
// 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>
class LauncherItr {
public:

View File

@ -8,6 +8,8 @@
#include <dmlc/omp.h>
#include <numeric>
#include <vector>
#include "../common/common.h"
#include "./random.h"
#include "./column_matrix.h"
#include "./quantile.h"

View File

@ -2,7 +2,6 @@
* Copyright 2018 XGBoost contributors
*/
#include "./hist_util.h"
#include <xgboost/logging.h>
#include <thrust/copy.h>
@ -17,10 +16,11 @@
#include <memory>
#include <mutex>
#include "hist_util.h"
#include "xgboost/host_device_vector.h"
#include "device_helpers.cuh"
#include "quantile.h"
#include "../tree/param.h"
#include "./host_device_vector.h"
#include "./device_helpers.cuh"
#include "./quantile.h"
namespace xgboost {
namespace common {

View File

@ -9,7 +9,7 @@
#include <xgboost/data.h>
#include <cstdint>
#include <utility>
#include "./host_device_vector.h"
#include "xgboost/host_device_vector.h"
namespace xgboost {

View File

@ -2,13 +2,16 @@
* Copyright 2017 XGBoost contributors
*/
#include "./host_device_vector.h"
#include <thrust/fill.h>
#include <xgboost/data.h>
#include <thrust/device_ptr.h>
#include <algorithm>
#include <cstdint>
#include <mutex>
#include "./device_helpers.cuh"
#include "xgboost/data.h"
#include "xgboost/host_device_vector.h"
#include "device_helpers.cuh"
namespace xgboost {
@ -75,22 +78,6 @@ class HostDeviceVectorImpl {
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
if (HostCanWrite()) {
std::fill(data_h_.begin(), data_h_.end(), v);
@ -304,26 +291,6 @@ common::Span<const T> HostDeviceVector<T>::ConstDeviceSpan() const {
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>
void HostDeviceVector<T>::Fill(T v) {
impl_->Fill(v);

View File

@ -17,8 +17,8 @@
#include <numeric>
#include <random>
#include "xgboost/host_device_vector.h"
#include "io.h"
#include "host_device_vector.h"
namespace xgboost {
namespace common {
@ -113,7 +113,7 @@ class ColumnSampler {
}
public:
/**
/**
* \brief Column sampler constructor.
* \note This constructor manually sets the rng seed
*/
@ -169,7 +169,7 @@ class ColumnSampler {
/**
* \brief Samples a feature set.
*
*
* \param depth The tree depth of the node at which to sample.
* \return The sampled feature set.
* \note If colsample_bynode_ < 1.0, this method creates a new feature set each time it

View File

@ -10,9 +10,10 @@
#include <vector>
#include <type_traits> // enable_if
#include "host_device_vector.h"
#include "xgboost/host_device_vector.h"
#include "xgboost/span.h"
#include "common.h"
#include "span.h"
#if defined (__CUDACC__)
#include "device_helpers.cuh"

View File

@ -13,7 +13,8 @@
#include "xgboost/data.h"
#include "xgboost/json.h"
#include "xgboost/logging.h"
#include "../common/span.h"
#include "xgboost/span.h"
#include "../common/bitfield.h"
namespace xgboost {

View File

@ -11,6 +11,7 @@
#include "./simple_dmatrix.h"
#include "./simple_csr_source.h"
#include "../common/io.h"
#include "../common/group_data.h"
#if DMLC_ENABLE_STD_THREAD
#include "./sparse_page_source.h"
@ -322,7 +323,35 @@ data::SparsePageFormat::DecideFormat(const std::string& cache_prefix) {
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) {
auto& data_vec = data.HostVector();
auto& offset_vec = offset.HostVector();

View File

@ -21,6 +21,7 @@
#include <vector>
#include "sparse_page_writer.h"
#include "../common/common.h"
namespace {

View File

@ -10,10 +10,13 @@
#include <xgboost/gbm.h>
#include <xgboost/logging.h>
#include <xgboost/linear_updater.h>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include "gblinear_model.h"
#include "../common/timer.h"
namespace xgboost {

View File

@ -6,11 +6,6 @@
*/
#include <dmlc/omp.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 <memory>
@ -19,11 +14,16 @@
#include <limits>
#include <algorithm>
#include "../common/common.h"
#include "../common/host_device_vector.h"
#include "../common/random.h"
#include "xgboost/logging.h"
#include "xgboost/gbm.h"
#include "xgboost/predictor.h"
#include "xgboost/tree_updater.h"
#include "xgboost/host_device_vector.h"
#include "gbtree.h"
#include "gbtree_model.h"
#include "../common/common.h"
#include "../common/random.h"
#include "../common/timer.h"

View File

@ -23,8 +23,9 @@
#include <string>
#include "gbtree_model.h"
#include "xgboost/host_device_vector.h"
#include "../common/common.h"
#include "../common/host_device_vector.h"
#include "../common/timer.h"
namespace xgboost {

View File

@ -19,11 +19,12 @@
#include <ios>
#include <utility>
#include <vector>
#include "./common/common.h"
#include "./common/host_device_vector.h"
#include "./common/io.h"
#include "./common/random.h"
#include "./common/timer.h"
#include "xgboost/host_device_vector.h"
#include "common/common.h"
#include "common/io.h"
#include "common/random.h"
#include "common/timer.h"
namespace {

View File

@ -7,12 +7,13 @@
#include <thrust/inner_product.h>
#include <xgboost/data.h>
#include <xgboost/linear_updater.h>
#include "xgboost/span.h"
#include "coordinate_common.h"
#include "../common/common.h"
#include "../common/span.h"
#include "../common/device_helpers.cuh"
#include "../common/timer.h"
#include "./param.h"
#include "coordinate_common.h"
namespace xgboost {
namespace linear {

View File

@ -11,7 +11,7 @@
#include <vector>
#include "../common/host_device_vector.h"
#include "xgboost/host_device_vector.h"
#include "../common/math.h"
namespace {

View File

@ -4,12 +4,13 @@
* \brief Provides an implementation of the hinge loss function
* \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/transform.h"
#include "../common/common.h"
#include "../common/span.h"
#include "../common/host_device_vector.h"
namespace xgboost {
namespace obj {

View File

@ -6,7 +6,7 @@
#include <xgboost/objective.h>
#include <dmlc/registry.h>
#include "../common/host_device_vector.h"
#include "xgboost/host_device_vector.h"
namespace dmlc {
DMLC_REGISTRY_ENABLE(::xgboost::ObjFunctionReg);

View File

@ -12,10 +12,11 @@
#include <memory>
#include <vector>
#include "../common/span.h"
#include "xgboost/span.h"
#include "xgboost/host_device_vector.h"
#include "../common/transform.h"
#include "../common/common.h"
#include "../common/host_device_vector.h"
#include "./regression_loss.h"

View File

@ -1,11 +1,13 @@
/*!
* Copyright by Contributors 2017
*/
#include <xgboost/predictor.h>
#include <xgboost/tree_model.h>
#include <xgboost/tree_updater.h>
#include "dmlc/logging.h"
#include "../common/host_device_vector.h"
#include "xgboost/predictor.h"
#include "xgboost/tree_model.h"
#include "xgboost/tree_updater.h"
#include "xgboost/logging.h"
#include "xgboost/host_device_vector.h"
#include "../gbm/gbtree_model.h"
namespace xgboost {
namespace predictor {

View File

@ -6,14 +6,17 @@
#include <thrust/device_ptr.h>
#include <thrust/device_vector.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 "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/device_helpers.cuh"
#include "../common/host_device_vector.h"
namespace xgboost {
namespace predictor {

View File

@ -6,17 +6,16 @@
#include <thrust/execution_policy.h>
#include <thrust/iterator/counting_iterator.h>
#include <xgboost/logging.h>
#include <algorithm>
#include <bitset>
#include <string>
#include <sstream>
#include <set>
#include "xgboost/logging.h"
#include "xgboost/span.h"
#include "constraints.cuh"
#include "param.h"
#include "../common/span.h"
#include "../common/device_helpers.cuh"

View File

@ -12,7 +12,7 @@
#include <vector>
#include "param.h"
#include "../common/span.h"
#include "xgboost/span.h"
#include "../common/bitfield.h"
#include "../common/device_helpers.cuh"

View File

@ -3,10 +3,8 @@
* \file split_evaluator.cc
* \brief Contains implementations of different split evaluators.
*/
#include "split_evaluator.h"
#include <dmlc/json.h>
#include <dmlc/registry.h>
#include <xgboost/logging.h>
#include <algorithm>
#include <unordered_set>
#include <vector>
@ -15,9 +13,12 @@
#include <string>
#include <sstream>
#include <utility>
#include "xgboost/logging.h"
#include "xgboost/host_device_vector.h"
#include "param.h"
#include "split_evaluator.h"
#include "../common/common.h"
#include "../common/host_device_vector.h"
namespace dmlc {
DMLC_REGISTRY_ENABLE(::xgboost::tree::SplitEvaluatorReg);

View File

@ -3,10 +3,10 @@
* \file tree_updater.cc
* \brief Registry of tree updaters.
*/
#include <xgboost/tree_updater.h>
#include <dmlc/registry.h>
#include "../common/host_device_vector.h"
#include "xgboost/tree_updater.h"
#include "xgboost/host_device_vector.h"
namespace dmlc {
DMLC_REGISTRY_ENABLE(::xgboost::TreeUpdaterReg);

View File

@ -14,13 +14,15 @@
#include <queue>
#include <utility>
#include <vector>
#include "xgboost/host_device_vector.h"
#include "xgboost/span.h"
#include "../common/common.h"
#include "../common/compressed_iterator.h"
#include "../common/device_helpers.cuh"
#include "../common/hist_util.h"
#include "../common/host_device_vector.h"
#include "../common/timer.h"
#include "../common/span.h"
#include "../data/ellpack_page.cuh"
#include "param.h"
#include "updater_gpu_common.cuh"

View File

@ -7,7 +7,7 @@
#include <thrust/iterator/counting_iterator.h>
#include "../../../src/common/device_helpers.cuh"
#include "../../../src/common/host_device_vector.h"
#include <xgboost/host_device_vector.h>
namespace xgboost {
namespace common {
@ -58,7 +58,7 @@ void InitHostDeviceVector(size_t n, int device, HostDeviceVector<int> *v) {
void PlusOne(HostDeviceVector<int> *v) {
int device = v->DeviceIdx();
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; });
}
@ -69,7 +69,7 @@ void CheckDevice(HostDeviceVector<int>* v,
ASSERT_EQ(v->Size(), size);
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)));
ASSERT_TRUE(v->DeviceCanRead());
// 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_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)));
ASSERT_TRUE(v->DeviceCanRead());
ASSERT_TRUE(v->DeviceCanWrite());

View File

@ -4,7 +4,7 @@
#include <gtest/gtest.h>
#include <vector>
#include "../../../src/common/span.h"
#include <xgboost/span.h>
#include "test_span.h"
namespace xgboost {

View File

@ -8,7 +8,7 @@
#include <thrust/execution_policy.h>
#include "../../../src/common/device_helpers.cuh"
#include "../../../src/common/span.h"
#include <xgboost/span.h>
#include "test_span.h"
namespace xgboost {

View File

@ -4,8 +4,8 @@
#ifndef XGBOOST_TEST_SPAN_H_
#define XGBOOST_TEST_SPAN_H_
#include "../../include/xgboost/base.h"
#include "../../../src/common/span.h"
#include <xgboost/base.h>
#include <xgboost/span.h>
template <typename Iter>
XGBOOST_DEVICE void InitializeRange(Iter _begin, Iter _end) {

View File

@ -1,10 +1,11 @@
#include <xgboost/base.h>
#include <gtest/gtest.h>
#include <xgboost/base.h>
#include <xgboost/span.h>
#include <xgboost/host_device_vector.h>
#include <vector>
#include "../../../src/common/host_device_vector.h"
#include "../../../src/common/transform.h"
#include "../../../src/common/span.h"
#include "../helpers.h"
#if defined(__CUDACC__)

View File

@ -9,6 +9,7 @@
#include "xgboost/c_api.h"
#include "../../src/data/simple_csr_source.h"
#include "../../src/gbm/gbtree_model.h"
bool FileExists(const std::string& filename) {
struct stat st;

View File

@ -2,8 +2,11 @@
* Copyright 2018-2019 by Contributors
*/
#include <xgboost/linear_updater.h>
#include <xgboost/gbm.h>
#include "../helpers.h"
#include "xgboost/gbm.h"
#include "../../../src/gbm/gblinear_model.h"
TEST(Linear, shotgun) {
auto mat = xgboost::CreateDMatrix(10, 10, 0);

View File

@ -1,7 +1,9 @@
// Copyright by Contributors
#include <xgboost/linear_updater.h>
#include <xgboost/gbm.h>
#include "../helpers.h"
#include "xgboost/gbm.h"
#include "../../../src/gbm/gblinear_model.h"
namespace xgboost {

View File

@ -2,7 +2,9 @@
#include <dmlc/filesystem.h>
#include <gtest/gtest.h>
#include <xgboost/predictor.h>
#include "../helpers.h"
#include "../../../src/gbm/gbtree_model.h"
namespace xgboost {
TEST(cpu_predictor, Test) {

View File

@ -11,6 +11,7 @@
#include <string>
#include "gtest/gtest.h"
#include "../helpers.h"
#include "../../../src/gbm/gbtree_model.h"
namespace {

View File

@ -2,7 +2,7 @@
* Copyright 2018-2019 by Contributors
*/
#include "../helpers.h"
#include "../../../src/common/host_device_vector.h"
#include <xgboost/host_device_vector.h>
#include <xgboost/tree_updater.h>
#include <gtest/gtest.h>
#include <vector>

View File

@ -1,12 +1,7 @@
/*!
* Copyright 2018-2019 by Contributors
*/
#include "../helpers.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/host_device_vector.h>
#include <xgboost/tree_updater.h>
#include <gtest/gtest.h>
@ -14,6 +9,11 @@
#include <vector>
#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 tree {

View File

@ -1,14 +1,16 @@
/*!
* Copyright 2018-2019 by Contributors
*/
#include "../helpers.h"
#include "../../../src/common/host_device_vector.h"
#include <xgboost/host_device_vector.h>
#include <xgboost/tree_updater.h>
#include <gtest/gtest.h>
#include <vector>
#include <string>
#include <memory>
#include "../helpers.h"
namespace xgboost {
namespace tree {