Make HostDeviceVector single gpu only (#4773)
* Make HostDeviceVector single gpu only
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
#include "../../../src/common/common.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace xgboost {
|
||||
TEST(GPUSet, Basic) {
|
||||
GPUSet devices = GPUSet::Empty();
|
||||
ASSERT_TRUE(devices.IsEmpty());
|
||||
|
||||
devices = GPUSet{0, 1};
|
||||
ASSERT_TRUE(devices != GPUSet::Empty());
|
||||
EXPECT_EQ(devices.Size(), 1);
|
||||
|
||||
devices = GPUSet::Range(1, 0);
|
||||
EXPECT_EQ(devices.Size(), 0);
|
||||
EXPECT_TRUE(devices.IsEmpty());
|
||||
|
||||
EXPECT_FALSE(devices.Contains(1));
|
||||
|
||||
devices = GPUSet::Range(2, -1);
|
||||
EXPECT_EQ(devices, GPUSet::Empty());
|
||||
EXPECT_EQ(devices.Size(), 0);
|
||||
EXPECT_TRUE(devices.IsEmpty());
|
||||
|
||||
devices = GPUSet::Range(2, 8); // 2 ~ 10
|
||||
EXPECT_EQ(devices.Size(), 8);
|
||||
EXPECT_ANY_THROW(devices.DeviceId(8));
|
||||
|
||||
auto device_id = devices.DeviceId(0);
|
||||
EXPECT_EQ(device_id, 2);
|
||||
auto device_index = devices.Index(2);
|
||||
EXPECT_EQ(device_index, 0);
|
||||
|
||||
#ifndef XGBOOST_USE_CUDA
|
||||
EXPECT_EQ(GPUSet::AllVisible(), GPUSet::Empty());
|
||||
#endif
|
||||
}
|
||||
} // namespace xgboost
|
||||
@@ -1,83 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/logging.h>
|
||||
#include "../../../src/common/common.h"
|
||||
#include "../helpers.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
TEST(GPUSet, GPUBasic) {
|
||||
GPUSet devices = GPUSet::Empty();
|
||||
ASSERT_TRUE(devices.IsEmpty());
|
||||
|
||||
devices = GPUSet{1, 1};
|
||||
ASSERT_TRUE(devices != GPUSet::Empty());
|
||||
EXPECT_EQ(devices.Size(), 1);
|
||||
EXPECT_EQ(*(devices.begin()), 1);
|
||||
|
||||
devices = GPUSet::Range(1, 0);
|
||||
EXPECT_EQ(devices, GPUSet::Empty());
|
||||
EXPECT_EQ(devices.Size(), 0);
|
||||
EXPECT_TRUE(devices.IsEmpty());
|
||||
|
||||
EXPECT_FALSE(devices.Contains(1));
|
||||
|
||||
devices = GPUSet::Range(2, -1);
|
||||
EXPECT_EQ(devices, GPUSet::Empty());
|
||||
|
||||
devices = GPUSet::Range(2, 8);
|
||||
EXPECT_EQ(devices.Size(), 8);
|
||||
|
||||
EXPECT_EQ(*devices.begin(), 2);
|
||||
EXPECT_EQ(*devices.end(), 2 + devices.Size());
|
||||
EXPECT_EQ(8, devices.Size());
|
||||
|
||||
ASSERT_NO_THROW(GPUSet::AllVisible());
|
||||
devices = GPUSet::AllVisible();
|
||||
if (devices.IsEmpty()) {
|
||||
LOG(WARNING) << "Empty devices.";
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GPUSet, Verbose) {
|
||||
{
|
||||
std::map<std::string, std::string> args {};
|
||||
args["verbosity"] = "3"; // LOG INFO
|
||||
|
||||
testing::internal::CaptureStderr();
|
||||
ConsoleLogger::Configure({args.cbegin(), args.cend()});
|
||||
GPUSet::All(0, 1);
|
||||
std::string output = testing::internal::GetCapturedStderr();
|
||||
ASSERT_NE(output.find("GPU ID: 0"), std::string::npos);
|
||||
ASSERT_NE(output.find("GPUs: 1"), std::string::npos);
|
||||
|
||||
args["verbosity"] = "1"; // restore
|
||||
ConsoleLogger::Configure({args.cbegin(), args.cend()});
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(XGBOOST_USE_NCCL)
|
||||
TEST(GPUSet, MGPU_GPUBasic) {
|
||||
{
|
||||
GPUSet devices = GPUSet::All(1, 1);
|
||||
ASSERT_EQ(*(devices.begin()), 1);
|
||||
ASSERT_EQ(*(devices.end()), 2);
|
||||
ASSERT_EQ(devices.Size(), 1);
|
||||
ASSERT_TRUE(devices.Contains(1));
|
||||
}
|
||||
|
||||
{
|
||||
GPUSet devices = GPUSet::All(0, -1);
|
||||
ASSERT_GE(devices.Size(), 2);
|
||||
}
|
||||
|
||||
// Specify number of rows.
|
||||
{
|
||||
GPUSet devices = GPUSet::All(0, -1, 1);
|
||||
ASSERT_EQ(devices.Size(), 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace xgboost
|
||||
@@ -87,8 +87,8 @@ TEST(ConfigParser, ParseKeyValuePair) {
|
||||
ASSERT_TRUE(parser.ParseKeyValuePair("booster = gbtree", &key, &value));
|
||||
ASSERT_EQ(key, "booster");
|
||||
ASSERT_EQ(value, "gbtree");
|
||||
ASSERT_TRUE(parser.ParseKeyValuePair("n_gpus = 2", &key, &value));
|
||||
ASSERT_EQ(key, "n_gpus");
|
||||
ASSERT_TRUE(parser.ParseKeyValuePair("gpu_id = 2", &key, &value));
|
||||
ASSERT_EQ(key, "gpu_id");
|
||||
ASSERT_EQ(value, "2");
|
||||
ASSERT_TRUE(parser.ParseKeyValuePair("monotone_constraints = (1,0,-1)",
|
||||
&key, &value));
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
namespace xgboost {
|
||||
namespace common {
|
||||
|
||||
void TestDeviceSketch(const GPUSet& devices, bool use_external_memory) {
|
||||
void TestDeviceSketch(bool use_external_memory) {
|
||||
// create the data
|
||||
int nrows = 10001;
|
||||
std::shared_ptr<xgboost::DMatrix> *dmat = nullptr;
|
||||
@@ -53,7 +53,7 @@ void TestDeviceSketch(const GPUSet& devices, bool use_external_memory) {
|
||||
|
||||
// find the cuts on the GPU
|
||||
HistogramCuts hmat_gpu;
|
||||
size_t row_stride = DeviceSketch(p, CreateEmptyGenericParam(0, devices.Size()), gpu_batch_nrows,
|
||||
size_t row_stride = DeviceSketch(p, CreateEmptyGenericParam(0), gpu_batch_nrows,
|
||||
dmat->get(), &hmat_gpu);
|
||||
|
||||
// compare the row stride with the one obtained from the dmatrix
|
||||
@@ -81,11 +81,11 @@ void TestDeviceSketch(const GPUSet& devices, bool use_external_memory) {
|
||||
}
|
||||
|
||||
TEST(gpu_hist_util, DeviceSketch) {
|
||||
TestDeviceSketch(GPUSet::Range(0, 1), false);
|
||||
TestDeviceSketch(false);
|
||||
}
|
||||
|
||||
TEST(gpu_hist_util, DeviceSketch_ExternalMemory) {
|
||||
TestDeviceSketch(GPUSet::Range(0, 1), true);
|
||||
TestDeviceSketch(true);
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
|
||||
@@ -30,45 +30,36 @@ struct HostDeviceVectorSetDeviceHandler {
|
||||
}
|
||||
};
|
||||
|
||||
void InitHostDeviceVector(size_t n, const GPUDistribution& distribution,
|
||||
HostDeviceVector<int> *v) {
|
||||
void InitHostDeviceVector(size_t n, int device, HostDeviceVector<int> *v) {
|
||||
// create the vector
|
||||
GPUSet devices = distribution.Devices();
|
||||
v->Shard(distribution);
|
||||
v->SetDevice(device);
|
||||
v->Resize(n);
|
||||
|
||||
ASSERT_EQ(v->Size(), n);
|
||||
ASSERT_TRUE(v->Distribution() == distribution);
|
||||
ASSERT_TRUE(v->Devices() == devices);
|
||||
// ensure that the devices have read-write access
|
||||
for (int i = 0; i < devices.Size(); ++i) {
|
||||
ASSERT_TRUE(v->DeviceCanAccess(i, GPUAccess::kRead));
|
||||
ASSERT_TRUE(v->DeviceCanAccess(i, GPUAccess::kWrite));
|
||||
}
|
||||
ASSERT_EQ(v->DeviceIdx(), device);
|
||||
// ensure that the device have read-write access
|
||||
ASSERT_TRUE(v->DeviceCanAccess(GPUAccess::kRead));
|
||||
ASSERT_TRUE(v->DeviceCanAccess(GPUAccess::kWrite));
|
||||
// ensure that the host has no access
|
||||
ASSERT_FALSE(v->HostCanAccess(GPUAccess::kWrite));
|
||||
ASSERT_FALSE(v->HostCanAccess(GPUAccess::kRead));
|
||||
|
||||
// fill in the data on the host
|
||||
std::vector<int>& data_h = v->HostVector();
|
||||
// ensure that the host has full access, while the devices have none
|
||||
// ensure that the host has full access, while the device have none
|
||||
ASSERT_TRUE(v->HostCanAccess(GPUAccess::kRead));
|
||||
ASSERT_TRUE(v->HostCanAccess(GPUAccess::kWrite));
|
||||
for (int i = 0; i < devices.Size(); ++i) {
|
||||
ASSERT_FALSE(v->DeviceCanAccess(i, GPUAccess::kRead));
|
||||
ASSERT_FALSE(v->DeviceCanAccess(i, GPUAccess::kWrite));
|
||||
}
|
||||
ASSERT_FALSE(v->DeviceCanAccess(GPUAccess::kRead));
|
||||
ASSERT_FALSE(v->DeviceCanAccess(GPUAccess::kWrite));
|
||||
ASSERT_EQ(data_h.size(), n);
|
||||
std::copy_n(thrust::make_counting_iterator(0), n, data_h.begin());
|
||||
}
|
||||
|
||||
void PlusOne(HostDeviceVector<int> *v) {
|
||||
int n_devices = v->Devices().Size();
|
||||
for (int i = 0; i < n_devices; ++i) {
|
||||
SetDevice(i);
|
||||
thrust::transform(v->tbegin(i), v->tend(i), v->tbegin(i),
|
||||
[=]__device__(unsigned int a){ return a + 1; });
|
||||
}
|
||||
int device = v->DeviceIdx();
|
||||
SetDevice(device);
|
||||
thrust::transform(v->tbegin(), v->tend(), v->tbegin(),
|
||||
[=]__device__(unsigned int a){ return a + 1; });
|
||||
}
|
||||
|
||||
void CheckDevice(HostDeviceVector<int> *v,
|
||||
@@ -76,24 +67,24 @@ void CheckDevice(HostDeviceVector<int> *v,
|
||||
const std::vector<size_t>& sizes,
|
||||
unsigned int first, GPUAccess access) {
|
||||
int n_devices = sizes.size();
|
||||
ASSERT_EQ(v->Devices().Size(), n_devices);
|
||||
ASSERT_EQ(n_devices, 1);
|
||||
for (int i = 0; i < n_devices; ++i) {
|
||||
ASSERT_EQ(v->DeviceSize(i), sizes.at(i));
|
||||
ASSERT_EQ(v->DeviceSize(), sizes.at(i));
|
||||
SetDevice(i);
|
||||
ASSERT_TRUE(thrust::equal(v->tcbegin(i), v->tcend(i),
|
||||
ASSERT_TRUE(thrust::equal(v->tcbegin(), v->tcend(),
|
||||
thrust::make_counting_iterator(first + starts[i])));
|
||||
ASSERT_TRUE(v->DeviceCanAccess(i, GPUAccess::kRead));
|
||||
ASSERT_TRUE(v->DeviceCanAccess(GPUAccess::kRead));
|
||||
// ensure that the device has at most the access specified by access
|
||||
ASSERT_EQ(v->DeviceCanAccess(i, GPUAccess::kWrite), access == GPUAccess::kWrite);
|
||||
ASSERT_EQ(v->DeviceCanAccess(GPUAccess::kWrite), access == GPUAccess::kWrite);
|
||||
}
|
||||
ASSERT_EQ(v->HostCanAccess(GPUAccess::kRead), access == GPUAccess::kRead);
|
||||
ASSERT_FALSE(v->HostCanAccess(GPUAccess::kWrite));
|
||||
for (int i = 0; i < n_devices; ++i) {
|
||||
SetDevice(i);
|
||||
ASSERT_TRUE(thrust::equal(v->tbegin(i), v->tend(i),
|
||||
ASSERT_TRUE(thrust::equal(v->tbegin(), v->tend(),
|
||||
thrust::make_counting_iterator(first + starts[i])));
|
||||
ASSERT_TRUE(v->DeviceCanAccess(i, GPUAccess::kRead));
|
||||
ASSERT_TRUE(v->DeviceCanAccess(i, GPUAccess::kWrite));
|
||||
ASSERT_TRUE(v->DeviceCanAccess(GPUAccess::kRead));
|
||||
ASSERT_TRUE(v->DeviceCanAccess(GPUAccess::kWrite));
|
||||
}
|
||||
ASSERT_FALSE(v->HostCanAccess(GPUAccess::kRead));
|
||||
ASSERT_FALSE(v->HostCanAccess(GPUAccess::kWrite));
|
||||
@@ -107,20 +98,20 @@ void CheckHost(HostDeviceVector<int> *v, GPUAccess access) {
|
||||
}
|
||||
ASSERT_TRUE(v->HostCanAccess(GPUAccess::kRead));
|
||||
ASSERT_EQ(v->HostCanAccess(GPUAccess::kWrite), access == GPUAccess::kWrite);
|
||||
size_t n_devices = v->Devices().Size();
|
||||
size_t n_devices = 1;
|
||||
for (int i = 0; i < n_devices; ++i) {
|
||||
ASSERT_EQ(v->DeviceCanAccess(i, GPUAccess::kRead), access == GPUAccess::kRead);
|
||||
ASSERT_EQ(v->DeviceCanAccess(GPUAccess::kRead), access == GPUAccess::kRead);
|
||||
// the devices should have no write access
|
||||
ASSERT_FALSE(v->DeviceCanAccess(i, GPUAccess::kWrite));
|
||||
ASSERT_FALSE(v->DeviceCanAccess(GPUAccess::kWrite));
|
||||
}
|
||||
}
|
||||
|
||||
void TestHostDeviceVector
|
||||
(size_t n, const GPUDistribution& distribution,
|
||||
(size_t n, int device,
|
||||
const std::vector<size_t>& starts, const std::vector<size_t>& sizes) {
|
||||
HostDeviceVectorSetDeviceHandler hdvec_dev_hndlr(SetDevice);
|
||||
HostDeviceVector<int> v;
|
||||
InitHostDeviceVector(n, distribution, &v);
|
||||
InitHostDeviceVector(n, device, &v);
|
||||
CheckDevice(&v, starts, sizes, 0, GPUAccess::kRead);
|
||||
PlusOne(&v);
|
||||
CheckDevice(&v, starts, sizes, 1, GPUAccess::kWrite);
|
||||
@@ -130,54 +121,24 @@ void TestHostDeviceVector
|
||||
|
||||
TEST(HostDeviceVector, TestBlock) {
|
||||
size_t n = 1001;
|
||||
int n_devices = 2;
|
||||
auto distribution = GPUDistribution::Block(GPUSet::Range(0, n_devices));
|
||||
std::vector<size_t> starts{0, 501};
|
||||
std::vector<size_t> sizes{501, 500};
|
||||
TestHostDeviceVector(n, distribution, starts, sizes);
|
||||
}
|
||||
|
||||
TEST(HostDeviceVector, TestGranular) {
|
||||
size_t n = 3003;
|
||||
int n_devices = 2;
|
||||
auto distribution = GPUDistribution::Granular(GPUSet::Range(0, n_devices), 3);
|
||||
std::vector<size_t> starts{0, 1503};
|
||||
std::vector<size_t> sizes{1503, 1500};
|
||||
TestHostDeviceVector(n, distribution, starts, sizes);
|
||||
}
|
||||
|
||||
TEST(HostDeviceVector, TestOverlap) {
|
||||
size_t n = 1001;
|
||||
int n_devices = 2;
|
||||
auto distribution = GPUDistribution::Overlap(GPUSet::Range(0, n_devices), 1);
|
||||
std::vector<size_t> starts{0, 500};
|
||||
std::vector<size_t> sizes{501, 501};
|
||||
TestHostDeviceVector(n, distribution, starts, sizes);
|
||||
}
|
||||
|
||||
TEST(HostDeviceVector, TestExplicit) {
|
||||
size_t n = 1001;
|
||||
int n_devices = 2;
|
||||
std::vector<size_t> offsets{0, 550, 1001};
|
||||
auto distribution = GPUDistribution::Explicit(GPUSet::Range(0, n_devices), offsets);
|
||||
std::vector<size_t> starts{0, 550};
|
||||
std::vector<size_t> sizes{550, 451};
|
||||
TestHostDeviceVector(n, distribution, starts, sizes);
|
||||
int device = 0;
|
||||
std::vector<size_t> starts{0};
|
||||
std::vector<size_t> sizes{1001};
|
||||
TestHostDeviceVector(n, device, starts, sizes);
|
||||
}
|
||||
|
||||
TEST(HostDeviceVector, TestCopy) {
|
||||
size_t n = 1001;
|
||||
int n_devices = 2;
|
||||
auto distribution = GPUDistribution::Block(GPUSet::Range(0, n_devices));
|
||||
std::vector<size_t> starts{0, 501};
|
||||
std::vector<size_t> sizes{501, 500};
|
||||
int device = 0;
|
||||
std::vector<size_t> starts{0};
|
||||
std::vector<size_t> sizes{1001};
|
||||
HostDeviceVectorSetDeviceHandler hdvec_dev_hndlr(SetDevice);
|
||||
|
||||
HostDeviceVector<int> v;
|
||||
{
|
||||
// a separate scope to ensure that v1 is gone before further checks
|
||||
HostDeviceVector<int> v1;
|
||||
InitHostDeviceVector(n, distribution, &v1);
|
||||
InitHostDeviceVector(n, device, &v1);
|
||||
v = v1;
|
||||
}
|
||||
CheckDevice(&v, starts, sizes, 0, GPUAccess::kRead);
|
||||
@@ -193,16 +154,16 @@ TEST(HostDeviceVector, Shard) {
|
||||
h_vec[i] = i;
|
||||
}
|
||||
HostDeviceVector<int> vec (h_vec);
|
||||
auto devices = GPUSet::Range(0, 1);
|
||||
auto device = 0;
|
||||
|
||||
vec.Shard(devices);
|
||||
ASSERT_EQ(vec.DeviceSize(0), h_vec.size());
|
||||
vec.SetDevice(device);
|
||||
ASSERT_EQ(vec.DeviceSize(), h_vec.size());
|
||||
ASSERT_EQ(vec.Size(), h_vec.size());
|
||||
auto span = vec.DeviceSpan(0); // sync to device
|
||||
auto span = vec.DeviceSpan(); // sync to device
|
||||
|
||||
vec.Reshard(GPUDistribution::Empty()); // pull back to cpu, empty devices.
|
||||
vec.SetDevice(-1); // pull back to cpu.
|
||||
ASSERT_EQ(vec.Size(), h_vec.size());
|
||||
ASSERT_TRUE(vec.Devices().IsEmpty());
|
||||
ASSERT_EQ(vec.DeviceIdx(), -1);
|
||||
|
||||
auto h_vec_1 = vec.HostVector();
|
||||
ASSERT_TRUE(std::equal(h_vec_1.cbegin(), h_vec_1.cend(), h_vec.cbegin()));
|
||||
@@ -214,16 +175,16 @@ TEST(HostDeviceVector, Reshard) {
|
||||
h_vec[i] = i;
|
||||
}
|
||||
HostDeviceVector<int> vec (h_vec);
|
||||
auto devices = GPUSet::Range(0, 1);
|
||||
auto device = 0;
|
||||
|
||||
vec.Shard(devices);
|
||||
ASSERT_EQ(vec.DeviceSize(0), h_vec.size());
|
||||
vec.SetDevice(device);
|
||||
ASSERT_EQ(vec.DeviceSize(), h_vec.size());
|
||||
ASSERT_EQ(vec.Size(), h_vec.size());
|
||||
PlusOne(&vec);
|
||||
|
||||
vec.Reshard(GPUDistribution::Empty());
|
||||
vec.SetDevice(-1);
|
||||
ASSERT_EQ(vec.Size(), h_vec.size());
|
||||
ASSERT_TRUE(vec.Devices().IsEmpty());
|
||||
ASSERT_EQ(vec.DeviceIdx(), -1);
|
||||
|
||||
auto h_vec_1 = vec.HostVector();
|
||||
for (size_t i = 0; i < h_vec_1.size(); ++i) {
|
||||
@@ -233,97 +194,14 @@ TEST(HostDeviceVector, Reshard) {
|
||||
|
||||
TEST(HostDeviceVector, Span) {
|
||||
HostDeviceVector<float> vec {1.0f, 2.0f, 3.0f, 4.0f};
|
||||
vec.Shard(GPUSet{0, 1});
|
||||
auto span = vec.DeviceSpan(0);
|
||||
ASSERT_EQ(vec.DeviceSize(0), span.size());
|
||||
ASSERT_EQ(vec.DevicePointer(0), span.data());
|
||||
auto const_span = vec.ConstDeviceSpan(0);
|
||||
ASSERT_EQ(vec.DeviceSize(0), span.size());
|
||||
ASSERT_EQ(vec.ConstDevicePointer(0), span.data());
|
||||
vec.SetDevice(0);
|
||||
auto span = vec.DeviceSpan();
|
||||
ASSERT_EQ(vec.DeviceSize(), span.size());
|
||||
ASSERT_EQ(vec.DevicePointer(), span.data());
|
||||
auto const_span = vec.ConstDeviceSpan();
|
||||
ASSERT_EQ(vec.DeviceSize(), span.size());
|
||||
ASSERT_EQ(vec.ConstDevicePointer(), span.data());
|
||||
}
|
||||
|
||||
// Multi-GPUs' test
|
||||
#if defined(XGBOOST_USE_NCCL)
|
||||
TEST(HostDeviceVector, MGPU_Shard) {
|
||||
auto devices = GPUSet::AllVisible();
|
||||
if (devices.Size() < 2) {
|
||||
LOG(WARNING) << "Not testing in multi-gpu environment.";
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<int> h_vec (2345);
|
||||
for (size_t i = 0; i < h_vec.size(); ++i) {
|
||||
h_vec[i] = i;
|
||||
}
|
||||
HostDeviceVector<int> vec (h_vec);
|
||||
|
||||
// Data size for each device.
|
||||
std::vector<size_t> devices_size (devices.Size());
|
||||
|
||||
// From CPU to GPUs.
|
||||
vec.Shard(devices);
|
||||
size_t total_size = 0;
|
||||
for (size_t i = 0; i < devices.Size(); ++i) {
|
||||
total_size += vec.DeviceSize(i);
|
||||
devices_size[i] = vec.DeviceSize(i);
|
||||
}
|
||||
ASSERT_EQ(total_size, h_vec.size());
|
||||
ASSERT_EQ(total_size, vec.Size());
|
||||
|
||||
// Shard from devices to devices with different distribution.
|
||||
EXPECT_ANY_THROW(
|
||||
vec.Shard(GPUDistribution::Granular(devices, 12)));
|
||||
|
||||
// All data is drawn back to CPU
|
||||
vec.Reshard(GPUDistribution::Empty());
|
||||
ASSERT_TRUE(vec.Devices().IsEmpty());
|
||||
ASSERT_EQ(vec.Size(), h_vec.size());
|
||||
|
||||
vec.Shard(GPUDistribution::Granular(devices, 12));
|
||||
total_size = 0;
|
||||
for (size_t i = 0; i < devices.Size(); ++i) {
|
||||
total_size += vec.DeviceSize(i);
|
||||
devices_size[i] = vec.DeviceSize(i);
|
||||
}
|
||||
ASSERT_EQ(total_size, h_vec.size());
|
||||
ASSERT_EQ(total_size, vec.Size());
|
||||
}
|
||||
|
||||
TEST(HostDeviceVector, MGPU_Reshard) {
|
||||
auto devices = GPUSet::AllVisible();
|
||||
if (devices.Size() < 2) {
|
||||
LOG(WARNING) << "Not testing in multi-gpu environment.";
|
||||
return;
|
||||
}
|
||||
|
||||
size_t n = 1001;
|
||||
int n_devices = 2;
|
||||
auto distribution = GPUDistribution::Block(GPUSet::Range(0, n_devices));
|
||||
std::vector<size_t> starts{0, 501};
|
||||
std::vector<size_t> sizes{501, 500};
|
||||
|
||||
HostDeviceVector<int> v;
|
||||
InitHostDeviceVector(n, distribution, &v);
|
||||
CheckDevice(&v, starts, sizes, 0, GPUAccess::kRead);
|
||||
PlusOne(&v);
|
||||
CheckDevice(&v, starts, sizes, 1, GPUAccess::kWrite);
|
||||
CheckHost(&v, GPUAccess::kRead);
|
||||
CheckHost(&v, GPUAccess::kWrite);
|
||||
|
||||
auto distribution1 = GPUDistribution::Overlap(GPUSet::Range(0, n_devices), 1);
|
||||
v.Reshard(distribution1);
|
||||
|
||||
for (size_t i = 0; i < n_devices; ++i) {
|
||||
auto span = v.DeviceSpan(i); // sync to device
|
||||
}
|
||||
|
||||
std::vector<size_t> starts1{0, 500};
|
||||
std::vector<size_t> sizes1{501, 501};
|
||||
CheckDevice(&v, starts1, sizes1, 1, GPUAccess::kWrite);
|
||||
CheckHost(&v, GPUAccess::kRead);
|
||||
CheckHost(&v, GPUAccess::kWrite);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace common
|
||||
} // namespace xgboost
|
||||
|
||||
@@ -33,7 +33,7 @@ std::string GetModelStr() {
|
||||
},
|
||||
"configuration": {
|
||||
"booster": "gbtree",
|
||||
"n_gpus": "1",
|
||||
"gpu_id": "0",
|
||||
"num_class": "0",
|
||||
"num_feature": "10",
|
||||
"objective": "reg:linear",
|
||||
|
||||
@@ -9,13 +9,11 @@
|
||||
|
||||
#if defined(__CUDACC__)
|
||||
|
||||
#define TRANSFORM_GPU_RANGE GPUSet::Range(0, 1)
|
||||
#define TRANSFORM_GPU_DIST GPUDistribution::Block(GPUSet::Range(0, 1))
|
||||
#define TRANSFORM_GPU 0
|
||||
|
||||
#else
|
||||
|
||||
#define TRANSFORM_GPU_RANGE GPUSet::Empty()
|
||||
#define TRANSFORM_GPU_DIST GPUDistribution::Block(GPUSet::Empty())
|
||||
#define TRANSFORM_GPU -1
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,13 +44,13 @@ TEST(Transform, DeclareUnifiedTest(Basic)) {
|
||||
std::vector<bst_float> h_sol(size);
|
||||
InitializeRange(h_sol.begin(), h_sol.end());
|
||||
|
||||
const HostDeviceVector<bst_float> in_vec{h_in, TRANSFORM_GPU_DIST};
|
||||
HostDeviceVector<bst_float> out_vec{h_out, TRANSFORM_GPU_DIST};
|
||||
const HostDeviceVector<bst_float> in_vec{h_in, TRANSFORM_GPU};
|
||||
HostDeviceVector<bst_float> out_vec{h_out, TRANSFORM_GPU};
|
||||
out_vec.Fill(0);
|
||||
|
||||
Transform<>::Init(TestTransformRange<bst_float>{},
|
||||
Range{0, static_cast<Range::DifferenceType>(size)},
|
||||
TRANSFORM_GPU_RANGE)
|
||||
TRANSFORM_GPU)
|
||||
.Eval(&out_vec, &in_vec);
|
||||
std::vector<bst_float> res = out_vec.HostVector();
|
||||
|
||||
|
||||
@@ -5,87 +5,13 @@
|
||||
namespace xgboost {
|
||||
namespace common {
|
||||
|
||||
// Test here is multi gpu specific
|
||||
TEST(Transform, MGPU_Basic) {
|
||||
auto devices = GPUSet::AllVisible();
|
||||
CHECK_GT(devices.Size(), 1);
|
||||
const size_t size {256};
|
||||
std::vector<bst_float> h_in(size);
|
||||
std::vector<bst_float> h_out(size);
|
||||
InitializeRange(h_in.begin(), h_in.end());
|
||||
std::vector<bst_float> h_sol(size);
|
||||
InitializeRange(h_sol.begin(), h_sol.end());
|
||||
|
||||
const HostDeviceVector<bst_float> in_vec {h_in,
|
||||
GPUDistribution::Block(GPUSet::Empty())};
|
||||
HostDeviceVector<bst_float> out_vec {h_out,
|
||||
GPUDistribution::Block(GPUSet::Empty())};
|
||||
out_vec.Fill(0);
|
||||
|
||||
in_vec.Shard(GPUDistribution::Granular(devices, 8));
|
||||
out_vec.Shard(GPUDistribution::Block(devices));
|
||||
|
||||
// Granularity is different, sharding will throw.
|
||||
EXPECT_ANY_THROW(
|
||||
Transform<>::Init(TestTransformRange<bst_float>{}, Range{0, size}, devices)
|
||||
.Eval(&out_vec, &in_vec));
|
||||
|
||||
|
||||
Transform<>::Init(TestTransformRange<bst_float>{}, Range{0, size},
|
||||
devices, false).Eval(&out_vec, &in_vec);
|
||||
std::vector<bst_float> res = out_vec.HostVector();
|
||||
|
||||
ASSERT_TRUE(std::equal(h_sol.begin(), h_sol.end(), res.begin()));
|
||||
}
|
||||
|
||||
// Test for multi-classes setting.
|
||||
template <typename T>
|
||||
struct TestTransformRangeGranular {
|
||||
const size_t granularity = 8;
|
||||
|
||||
explicit TestTransformRangeGranular(const size_t granular) : granularity{granular} {}
|
||||
void XGBOOST_DEVICE operator()(size_t _idx,
|
||||
Span<bst_float> _out, Span<const bst_float> _in) {
|
||||
auto in_sub = _in.subspan(_idx * granularity, granularity);
|
||||
auto out_sub = _out.subspan(_idx * granularity, granularity);
|
||||
for (size_t i = 0; i < granularity; ++i) {
|
||||
out_sub[i] = in_sub[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Transform, MGPU_Granularity) {
|
||||
GPUSet devices = GPUSet::All(0, -1);
|
||||
|
||||
const size_t size {8990};
|
||||
const size_t granularity = 10;
|
||||
|
||||
GPUDistribution distribution =
|
||||
GPUDistribution::Granular(devices, granularity);
|
||||
|
||||
std::vector<bst_float> h_in(size);
|
||||
std::vector<bst_float> h_out(size);
|
||||
InitializeRange(h_in.begin(), h_in.end());
|
||||
std::vector<bst_float> h_sol(size);
|
||||
InitializeRange(h_sol.begin(), h_sol.end());
|
||||
|
||||
const HostDeviceVector<bst_float> in_vec {h_in, distribution};
|
||||
HostDeviceVector<bst_float> out_vec {h_out, distribution};
|
||||
|
||||
ASSERT_NO_THROW(
|
||||
Transform<>::Init(
|
||||
TestTransformRangeGranular<bst_float>{granularity},
|
||||
Range{0, size / granularity},
|
||||
distribution)
|
||||
.Eval(&out_vec, &in_vec));
|
||||
std::vector<bst_float> res = out_vec.HostVector();
|
||||
|
||||
ASSERT_TRUE(std::equal(h_sol.begin(), h_sol.end(), res.begin()));
|
||||
}
|
||||
|
||||
TEST(Transform, MGPU_SpecifiedGpuId) {
|
||||
if (AllVisibleGPUs() < 2) {
|
||||
LOG(WARNING) << "Not testing in multi-gpu environment.";
|
||||
return;
|
||||
}
|
||||
// Use 1 GPU, Numbering of GPU starts from 1
|
||||
auto devices = GPUSet::All(1, 1);
|
||||
auto device = 1;
|
||||
const size_t size {256};
|
||||
std::vector<bst_float> h_in(size);
|
||||
std::vector<bst_float> h_out(size);
|
||||
@@ -93,13 +19,11 @@ TEST(Transform, MGPU_SpecifiedGpuId) {
|
||||
std::vector<bst_float> h_sol(size);
|
||||
InitializeRange(h_sol.begin(), h_sol.end());
|
||||
|
||||
const HostDeviceVector<bst_float> in_vec {h_in,
|
||||
GPUDistribution::Block(devices)};
|
||||
HostDeviceVector<bst_float> out_vec {h_out,
|
||||
GPUDistribution::Block(devices)};
|
||||
const HostDeviceVector<bst_float> in_vec {h_in, device};
|
||||
HostDeviceVector<bst_float> out_vec {h_out, device};
|
||||
|
||||
ASSERT_NO_THROW(
|
||||
Transform<>::Init(TestTransformRange<bst_float>{}, Range{0, size}, devices)
|
||||
Transform<>::Init(TestTransformRange<bst_float>{}, Range{0, size}, device)
|
||||
.Eval(&out_vec, &in_vec));
|
||||
std::vector<bst_float> res = out_vec.HostVector();
|
||||
ASSERT_TRUE(std::equal(h_sol.begin(), h_sol.end(), res.begin()));
|
||||
|
||||
@@ -12,7 +12,7 @@ TEST(GBTree, SelectTreeMethod) {
|
||||
auto p_dmat {(*p_shared_ptr_dmat).get()};
|
||||
|
||||
GenericParameter generic_param;
|
||||
generic_param.InitAllowUnknown(std::vector<Arg>{Arg("n_gpus", "0")});
|
||||
generic_param.InitAllowUnknown(std::vector<Arg>{});
|
||||
std::unique_ptr<GradientBooster> p_gbm{
|
||||
GradientBooster::Create("gbtree", &generic_param, {}, 0)};
|
||||
auto& gbtree = dynamic_cast<gbm::GBTree&> (*p_gbm);
|
||||
@@ -35,7 +35,7 @@ TEST(GBTree, SelectTreeMethod) {
|
||||
Arg{"num_feature", n_feat}}, p_dmat);
|
||||
ASSERT_EQ(tparam.updater_seq, "grow_quantile_histmaker");
|
||||
#ifdef XGBOOST_USE_CUDA
|
||||
generic_param.InitAllowUnknown(std::vector<Arg>{Arg{"n_gpus", "1"}});
|
||||
generic_param.InitAllowUnknown(std::vector<Arg>{Arg{"gpu_id", "0"}});
|
||||
gbtree.ConfigureWithKnownData({Arg("tree_method", "gpu_hist"), Arg("num_feature", n_feat)},
|
||||
p_dmat);
|
||||
ASSERT_EQ(tparam.updater_seq, "grow_gpu_hist");
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#endif
|
||||
|
||||
#if defined(__CUDACC__)
|
||||
#define NGPUS 1
|
||||
#define GPUIDX 0
|
||||
#else
|
||||
#define NGPUS 0
|
||||
#define GPUIDX -1
|
||||
#endif
|
||||
|
||||
bool FileExists(const std::string& filename);
|
||||
@@ -189,11 +189,10 @@ std::unique_ptr<DMatrix> CreateSparsePageDMatrixWithRC(size_t n_rows, size_t n_c
|
||||
|
||||
gbm::GBTreeModel CreateTestModel();
|
||||
|
||||
inline GenericParameter CreateEmptyGenericParam(int gpu_id, int n_gpus) {
|
||||
inline GenericParameter CreateEmptyGenericParam(int gpu_id) {
|
||||
xgboost::GenericParameter tparam;
|
||||
std::vector<std::pair<std::string, std::string>> args {
|
||||
{"gpu_id", std::to_string(gpu_id)},
|
||||
{"n_gpus", std::to_string(n_gpus)}};
|
||||
{"gpu_id", std::to_string(gpu_id)}};
|
||||
tparam.Init(args);
|
||||
return tparam;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
TEST(Linear, shotgun) {
|
||||
auto mat = xgboost::CreateDMatrix(10, 10, 0);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, 0);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
{
|
||||
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
|
||||
xgboost::LinearUpdater::Create("shotgun", &lparam));
|
||||
@@ -33,7 +33,7 @@ TEST(Linear, shotgun) {
|
||||
|
||||
TEST(Linear, coordinate) {
|
||||
auto mat = xgboost::CreateDMatrix(10, 10, 0);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, 0);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
|
||||
xgboost::LinearUpdater::Create("coord_descent", &lparam));
|
||||
updater->Configure({{"eta", "1."}});
|
||||
|
||||
@@ -7,8 +7,7 @@ namespace xgboost {
|
||||
|
||||
TEST(Linear, GPUCoordinate) {
|
||||
auto mat = xgboost::CreateDMatrix(10, 10, 0);
|
||||
auto lparam = CreateEmptyGenericParam(0, 1);
|
||||
lparam.n_gpus = 1;
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
|
||||
xgboost::LinearUpdater::Create("gpu_coord_descent", &lparam));
|
||||
updater->Configure({{"eta", "1."}});
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "../helpers.h"
|
||||
|
||||
TEST(Metric, DeclareUnifiedTest(RMSE)) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("rmse", &lparam);
|
||||
metric->Configure({});
|
||||
ASSERT_STREQ(metric->Name(), "rmse");
|
||||
@@ -20,7 +20,7 @@ TEST(Metric, DeclareUnifiedTest(RMSE)) {
|
||||
}
|
||||
|
||||
TEST(Metric, DeclareUnifiedTest(RMSLE)) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("rmsle", &lparam);
|
||||
metric->Configure({});
|
||||
ASSERT_STREQ(metric->Name(), "rmsle");
|
||||
@@ -32,7 +32,7 @@ TEST(Metric, DeclareUnifiedTest(RMSLE)) {
|
||||
}
|
||||
|
||||
TEST(Metric, DeclareUnifiedTest(MAE)) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("mae", &lparam);
|
||||
metric->Configure({});
|
||||
ASSERT_STREQ(metric->Name(), "mae");
|
||||
@@ -45,7 +45,7 @@ TEST(Metric, DeclareUnifiedTest(MAE)) {
|
||||
}
|
||||
|
||||
TEST(Metric, DeclareUnifiedTest(LogLoss)) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("logloss", &lparam);
|
||||
metric->Configure({});
|
||||
ASSERT_STREQ(metric->Name(), "logloss");
|
||||
@@ -58,7 +58,7 @@ TEST(Metric, DeclareUnifiedTest(LogLoss)) {
|
||||
}
|
||||
|
||||
TEST(Metric, DeclareUnifiedTest(Error)) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("error", &lparam);
|
||||
metric->Configure({});
|
||||
ASSERT_STREQ(metric->Name(), "error");
|
||||
@@ -90,7 +90,7 @@ TEST(Metric, DeclareUnifiedTest(Error)) {
|
||||
}
|
||||
|
||||
TEST(Metric, DeclareUnifiedTest(PoissionNegLogLik)) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("poisson-nloglik", &lparam);
|
||||
metric->Configure({});
|
||||
ASSERT_STREQ(metric->Name(), "poisson-nloglik");
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "../helpers.h"
|
||||
|
||||
TEST(Metric, UnknownMetric) {
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(0, 0);
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = nullptr;
|
||||
EXPECT_ANY_THROW(metric = xgboost::Metric::Create("unknown_name", &tparam));
|
||||
EXPECT_NO_THROW(metric = xgboost::Metric::Create("rmse", &tparam));
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
#include "../helpers.h"
|
||||
|
||||
inline void TestMultiClassError(xgboost::GPUSet const& devices) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
lparam.gpu_id = *devices.begin();
|
||||
lparam.n_gpus = devices.Size();
|
||||
inline void TestMultiClassError(int device) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(device);
|
||||
lparam.gpu_id = device;
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("merror", &lparam);
|
||||
metric->Configure({});
|
||||
ASSERT_STREQ(metric->Name(), "merror");
|
||||
@@ -23,14 +22,12 @@ inline void TestMultiClassError(xgboost::GPUSet const& devices) {
|
||||
}
|
||||
|
||||
TEST(Metric, DeclareUnifiedTest(MultiClassError)) {
|
||||
auto devices = xgboost::GPUSet::Range(0, NGPUS);
|
||||
TestMultiClassError(devices);
|
||||
TestMultiClassError(GPUIDX);
|
||||
}
|
||||
|
||||
inline void TestMultiClassLogLoss(xgboost::GPUSet const& devices) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
lparam.gpu_id = *devices.begin();
|
||||
lparam.n_gpus = devices.Size();
|
||||
inline void TestMultiClassLogLoss(int device) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(device);
|
||||
lparam.gpu_id = device;
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("mlogloss", &lparam);
|
||||
metric->Configure({});
|
||||
ASSERT_STREQ(metric->Name(), "mlogloss");
|
||||
@@ -46,27 +43,31 @@ inline void TestMultiClassLogLoss(xgboost::GPUSet const& devices) {
|
||||
}
|
||||
|
||||
TEST(Metric, DeclareUnifiedTest(MultiClassLogLoss)) {
|
||||
auto devices = xgboost::GPUSet::Range(0, NGPUS);
|
||||
TestMultiClassLogLoss(devices);
|
||||
TestMultiClassLogLoss(GPUIDX);
|
||||
}
|
||||
|
||||
#if defined(XGBOOST_USE_NCCL) && defined(__CUDACC__)
|
||||
namespace xgboost {
|
||||
namespace common {
|
||||
TEST(Metric, MGPU_MultiClassError) {
|
||||
if (AllVisibleGPUs() < 2) {
|
||||
LOG(WARNING) << "Not testing in multi-gpu environment.";
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
auto devices = xgboost::GPUSet::All(0, -1);
|
||||
TestMultiClassError(devices);
|
||||
TestMultiClassError(0);
|
||||
}
|
||||
{
|
||||
auto devices = xgboost::GPUSet::All(1, -1);
|
||||
TestMultiClassError(devices);
|
||||
TestMultiClassError(1);
|
||||
}
|
||||
{
|
||||
auto devices = xgboost::GPUSet::All(0, -1);
|
||||
TestMultiClassLogLoss(devices);
|
||||
TestMultiClassLogLoss(0);
|
||||
}
|
||||
{
|
||||
auto devices = xgboost::GPUSet::All(1, -1);
|
||||
TestMultiClassLogLoss(devices);
|
||||
TestMultiClassLogLoss(1);
|
||||
}
|
||||
}
|
||||
} // namespace common
|
||||
} // namespace xgboost
|
||||
#endif // defined(XGBOOST_USE_NCCL)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "../helpers.h"
|
||||
|
||||
TEST(Metric, AMS) {
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(0, 0);
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
EXPECT_ANY_THROW(xgboost::Metric::Create("ams", &tparam));
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("ams@0.5f", &tparam);
|
||||
ASSERT_STREQ(metric->Name(), "ams@0.5");
|
||||
@@ -23,7 +23,7 @@ TEST(Metric, AMS) {
|
||||
}
|
||||
|
||||
TEST(Metric, AUC) {
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(0, 0);
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("auc", &tparam);
|
||||
ASSERT_STREQ(metric->Name(), "auc");
|
||||
EXPECT_NEAR(GetMetricEval(metric, {0, 1}, {0, 1}), 1, 1e-10);
|
||||
@@ -38,7 +38,7 @@ TEST(Metric, AUC) {
|
||||
}
|
||||
|
||||
TEST(Metric, AUCPR) {
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(0, 0);
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric *metric = xgboost::Metric::Create("aucpr", &tparam);
|
||||
ASSERT_STREQ(metric->Name(), "aucpr");
|
||||
EXPECT_NEAR(GetMetricEval(metric, {0, 0, 1, 1}, {0, 0, 1, 1}), 1, 1e-10);
|
||||
@@ -65,7 +65,7 @@ TEST(Metric, Precision) {
|
||||
// When the limit for precision is not given, it takes the limit at
|
||||
// std::numeric_limits<unsigned>::max(); hence all values are very small
|
||||
// NOTE(AbdealiJK): Maybe this should be fixed to be num_row by default.
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(0, 0);
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("pre", &tparam);
|
||||
ASSERT_STREQ(metric->Name(), "pre");
|
||||
EXPECT_NEAR(GetMetricEval(metric, {0, 1}, {0, 1}), 0, 1e-7);
|
||||
@@ -89,7 +89,7 @@ TEST(Metric, Precision) {
|
||||
}
|
||||
|
||||
TEST(Metric, NDCG) {
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(0, 0);
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("ndcg", &tparam);
|
||||
ASSERT_STREQ(metric->Name(), "ndcg");
|
||||
EXPECT_ANY_THROW(GetMetricEval(metric, {0, 1}, {}));
|
||||
@@ -147,7 +147,7 @@ TEST(Metric, NDCG) {
|
||||
}
|
||||
|
||||
TEST(Metric, MAP) {
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(0, 0);
|
||||
auto tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Metric * metric = xgboost::Metric::Create("map", &tparam);
|
||||
ASSERT_STREQ(metric->Name(), "map");
|
||||
EXPECT_NEAR(GetMetricEval(metric, {0, 1}, {0, 1}), 1, 1e-10);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "../helpers.h"
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(HingeObj)) {
|
||||
xgboost::GenericParameter tparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("binary:hinge", &tparam);
|
||||
|
||||
xgboost::bst_float eps = std::numeric_limits<xgboost::bst_float>::min();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "../helpers.h"
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassObjGPair)) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args {{"num_class", "3"}};
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("multi:softmax", &lparam);
|
||||
|
||||
@@ -25,7 +25,7 @@ TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassObjGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassBasic)) {
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
auto lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args{
|
||||
std::pair<std::string, std::string>("num_class", "3")};
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassBasic)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(SoftprobMultiClassBasic)) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args {
|
||||
std::pair<std::string, std::string>("num_class", "3")};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "../helpers.h"
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(LinearRegressionGPair)) {
|
||||
xgboost::GenericParameter tparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
|
||||
xgboost::ObjFunction * obj =
|
||||
@@ -32,7 +32,7 @@ TEST(Objective, DeclareUnifiedTest(LinearRegressionGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(SquaredLog)) {
|
||||
xgboost::GenericParameter tparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
|
||||
xgboost::ObjFunction * obj =
|
||||
@@ -56,7 +56,7 @@ TEST(Objective, DeclareUnifiedTest(SquaredLog)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(LogisticRegressionGPair)) {
|
||||
xgboost::GenericParameter tparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("reg:logistic", &tparam);
|
||||
|
||||
@@ -72,7 +72,7 @@ TEST(Objective, DeclareUnifiedTest(LogisticRegressionGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(LogisticRegressionBasic)) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("reg:logistic", &lparam);
|
||||
|
||||
@@ -102,7 +102,7 @@ TEST(Objective, DeclareUnifiedTest(LogisticRegressionBasic)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(LogisticRawGPair)) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("binary:logitraw", &lparam);
|
||||
|
||||
@@ -118,7 +118,7 @@ TEST(Objective, DeclareUnifiedTest(LogisticRawGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(PoissonRegressionGPair)) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("count:poisson", &lparam);
|
||||
|
||||
@@ -140,7 +140,7 @@ TEST(Objective, DeclareUnifiedTest(PoissonRegressionGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(PoissonRegressionBasic)) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("count:poisson", &lparam);
|
||||
|
||||
@@ -168,7 +168,7 @@ TEST(Objective, DeclareUnifiedTest(PoissonRegressionBasic)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(GammaRegressionGPair)) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("reg:gamma", &lparam);
|
||||
|
||||
@@ -189,7 +189,7 @@ TEST(Objective, DeclareUnifiedTest(GammaRegressionGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(GammaRegressionBasic)) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("reg:gamma", &lparam);
|
||||
|
||||
@@ -217,7 +217,7 @@ TEST(Objective, DeclareUnifiedTest(GammaRegressionBasic)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(TweedieRegressionGPair)) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("reg:tweedie", &lparam);
|
||||
|
||||
@@ -241,7 +241,7 @@ TEST(Objective, DeclareUnifiedTest(TweedieRegressionGPair)) {
|
||||
|
||||
#if defined(__CUDACC__)
|
||||
TEST(Objective, CPU_vs_CUDA) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, 1);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
|
||||
xgboost::ObjFunction * obj =
|
||||
xgboost::ObjFunction::Create("reg:squarederror", &lparam);
|
||||
@@ -267,12 +267,12 @@ TEST(Objective, CPU_vs_CUDA) {
|
||||
|
||||
{
|
||||
// CPU
|
||||
lparam.n_gpus = 0;
|
||||
lparam.gpu_id = -1;
|
||||
obj->GetGradient(preds, info, 0, &cpu_out_preds);
|
||||
}
|
||||
{
|
||||
// CUDA
|
||||
lparam.n_gpus = 1;
|
||||
lparam.gpu_id = 0;
|
||||
obj->GetGradient(preds, info, 0, &cuda_out_preds);
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ TEST(Objective, CPU_vs_CUDA) {
|
||||
#endif
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(TweedieRegressionBasic)) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, NGPUS);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::ObjFunction * obj = xgboost::ObjFunction::Create("reg:tweedie", &lparam);
|
||||
|
||||
@@ -325,7 +325,7 @@ TEST(Objective, DeclareUnifiedTest(TweedieRegressionBasic)) {
|
||||
// CoxRegression not implemented in GPU code, no need for testing.
|
||||
#if !defined(__CUDACC__)
|
||||
TEST(Objective, CoxRegressionGPair) {
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(0, 0);
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::ObjFunction * obj =
|
||||
xgboost::ObjFunction::Create("survival:cox", &lparam);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace xgboost {
|
||||
|
||||
TEST(Plugin, ExampleObjective) {
|
||||
xgboost::GenericParameter tparam = CreateEmptyGenericParam(0, 0);
|
||||
xgboost::GenericParameter tparam = CreateEmptyGenericParam(GPUIDX);
|
||||
auto * obj = xgboost::ObjFunction::Create("mylogistic", &tparam);
|
||||
ASSERT_EQ(obj->DefaultEvalMetric(), std::string{"error"});
|
||||
delete obj;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace xgboost {
|
||||
TEST(cpu_predictor, Test) {
|
||||
auto lparam = CreateEmptyGenericParam(0, 0);
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<Predictor> cpu_predictor =
|
||||
std::unique_ptr<Predictor>(Predictor::Create("cpu_predictor", &lparam));
|
||||
|
||||
@@ -59,7 +59,7 @@ TEST(cpu_predictor, ExternalMemoryTest) {
|
||||
dmlc::TemporaryDirectory tmpdir;
|
||||
std::string filename = tmpdir.path + "/big.libsvm";
|
||||
std::unique_ptr<DMatrix> dmat = CreateSparsePageDMatrix(12, 64, filename);
|
||||
auto lparam = CreateEmptyGenericParam(0, 0);
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<Predictor> cpu_predictor =
|
||||
std::unique_ptr<Predictor>(Predictor::Create("cpu_predictor", &lparam));
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace xgboost {
|
||||
namespace predictor {
|
||||
|
||||
TEST(gpu_predictor, Test) {
|
||||
auto cpu_lparam = CreateEmptyGenericParam(0, 0);
|
||||
auto gpu_lparam = CreateEmptyGenericParam(0, 1);
|
||||
auto cpu_lparam = CreateEmptyGenericParam(-1);
|
||||
auto gpu_lparam = CreateEmptyGenericParam(0);
|
||||
|
||||
std::unique_ptr<Predictor> gpu_predictor =
|
||||
std::unique_ptr<Predictor>(Predictor::Create("gpu_predictor", &gpu_lparam));
|
||||
@@ -69,7 +69,7 @@ TEST(gpu_predictor, Test) {
|
||||
}
|
||||
|
||||
TEST(gpu_predictor, ExternalMemoryTest) {
|
||||
auto lparam = CreateEmptyGenericParam(0, 1);
|
||||
auto lparam = CreateEmptyGenericParam(0);
|
||||
std::unique_ptr<Predictor> gpu_predictor =
|
||||
std::unique_ptr<Predictor>(Predictor::Create("gpu_predictor", &lparam));
|
||||
gpu_predictor->Configure({}, {});
|
||||
@@ -83,26 +83,26 @@ TEST(gpu_predictor, ExternalMemoryTest) {
|
||||
std::string file1 = tmpdir.path + "/big_1.libsvm";
|
||||
std::string file2 = tmpdir.path + "/big_2.libsvm";
|
||||
dmats.push_back(CreateSparsePageDMatrix(9, 64UL, file0));
|
||||
dmats.push_back(CreateSparsePageDMatrix(128, 128UL, file1));
|
||||
dmats.push_back(CreateSparsePageDMatrix(1024, 1024UL, file2));
|
||||
// dmats.push_back(CreateSparsePageDMatrix(128, 128UL, file1));
|
||||
// dmats.push_back(CreateSparsePageDMatrix(1024, 1024UL, file2));
|
||||
|
||||
for (const auto& dmat: dmats) {
|
||||
// Test predict batch
|
||||
dmat->Info().base_margin_.Resize(dmat->Info().num_row_ * n_classes, 0.5);
|
||||
HostDeviceVector<float> out_predictions;
|
||||
gpu_predictor->PredictBatch(dmat.get(), &out_predictions, model, 0);
|
||||
EXPECT_EQ(out_predictions.Size(), dmat->Info().num_row_ * n_classes);
|
||||
const std::vector<float> &host_vector = out_predictions.ConstHostVector();
|
||||
for (int i = 0; i < host_vector.size() / n_classes; i++) {
|
||||
ASSERT_EQ(host_vector[i * n_classes], 1.5);
|
||||
ASSERT_EQ(host_vector[i * n_classes + 1], 0.);
|
||||
ASSERT_EQ(host_vector[i * n_classes + 2], 0.);
|
||||
ASSERT_EQ(host_vector[i * n_classes], 2.0);
|
||||
ASSERT_EQ(host_vector[i * n_classes + 1], 0.5);
|
||||
ASSERT_EQ(host_vector[i * n_classes + 2], 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test whether pickling preserves predictor parameters
|
||||
TEST(gpu_predictor, PicklingTest) {
|
||||
int const ngpu = 1;
|
||||
int const gpuid = 0;
|
||||
|
||||
dmlc::TemporaryDirectory tempdir;
|
||||
const std::string tmp_file = tempdir.path + "/simple.libsvm";
|
||||
@@ -134,7 +134,7 @@ TEST(gpu_predictor, PicklingTest) {
|
||||
ASSERT_EQ(XGBoosterSetParam(
|
||||
bst, "tree_method", "gpu_hist"), 0) << XGBGetLastError();
|
||||
ASSERT_EQ(XGBoosterSetParam(
|
||||
bst, "n_gpus", std::to_string(ngpu).c_str()), 0) << XGBGetLastError();
|
||||
bst, "gpu_id", std::to_string(gpuid).c_str()), 0) << XGBGetLastError();
|
||||
ASSERT_EQ(XGBoosterSetParam(bst, "predictor", "gpu_predictor"), 0) << XGBGetLastError();
|
||||
|
||||
// Run boosting iterations
|
||||
@@ -160,7 +160,7 @@ TEST(gpu_predictor, PicklingTest) {
|
||||
{ // Query predictor
|
||||
const auto& kwargs = QueryBoosterConfigurationArguments(bst2);
|
||||
ASSERT_EQ(kwargs.at("predictor"), "gpu_predictor");
|
||||
ASSERT_EQ(kwargs.at("n_gpus"), std::to_string(ngpu).c_str());
|
||||
ASSERT_EQ(kwargs.at("gpu_id"), std::to_string(gpuid).c_str());
|
||||
}
|
||||
|
||||
{ // Change predictor and query again
|
||||
|
||||
@@ -168,10 +168,9 @@ TEST(Learner, IO) {
|
||||
std::unique_ptr<Learner> learner {Learner::Create(mat)};
|
||||
learner->SetParams({Arg{"tree_method", "auto"},
|
||||
Arg{"predictor", "gpu_predictor"},
|
||||
Arg{"n_gpus", "1"}});
|
||||
Arg{"gpu_id", "0"}});
|
||||
learner->UpdateOneIter(0, p_dmat.get());
|
||||
ASSERT_EQ(learner->GetGenericParameter().gpu_id, 0);
|
||||
ASSERT_EQ(learner->GetGenericParameter().n_gpus, 1);
|
||||
|
||||
dmlc::TemporaryDirectory tempdir;
|
||||
const std::string fname = tempdir.path + "/model.bst";
|
||||
@@ -185,7 +184,6 @@ TEST(Learner, IO) {
|
||||
std::unique_ptr<dmlc::Stream> fi(dmlc::Stream::Create(fname.c_str(), "r"));
|
||||
learner->Load(fi.get());
|
||||
ASSERT_EQ(learner->GetGenericParameter().gpu_id, 0);
|
||||
ASSERT_EQ(learner->GetGenericParameter().n_gpus, 0);
|
||||
|
||||
delete pp_dmat;
|
||||
}
|
||||
@@ -208,31 +206,27 @@ TEST(Learner, GPUConfiguration) {
|
||||
Arg{"updater", "gpu_coord_descent"}});
|
||||
learner->UpdateOneIter(0, p_dmat.get());
|
||||
ASSERT_EQ(learner->GetGenericParameter().gpu_id, 0);
|
||||
ASSERT_EQ(learner->GetGenericParameter().n_gpus, 1);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<Learner> learner {Learner::Create(mat)};
|
||||
learner->SetParams({Arg{"tree_method", "gpu_hist"}});
|
||||
learner->UpdateOneIter(0, p_dmat.get());
|
||||
ASSERT_EQ(learner->GetGenericParameter().gpu_id, 0);
|
||||
ASSERT_EQ(learner->GetGenericParameter().n_gpus, 1);
|
||||
}
|
||||
{
|
||||
// with CPU algorithm
|
||||
std::unique_ptr<Learner> learner {Learner::Create(mat)};
|
||||
learner->SetParams({Arg{"tree_method", "hist"}});
|
||||
learner->UpdateOneIter(0, p_dmat.get());
|
||||
ASSERT_EQ(learner->GetGenericParameter().gpu_id, 0);
|
||||
ASSERT_EQ(learner->GetGenericParameter().n_gpus, 0);
|
||||
ASSERT_EQ(learner->GetGenericParameter().gpu_id, -1);
|
||||
}
|
||||
{
|
||||
// with CPU algorithm, but `n_gpus` takes priority
|
||||
// with CPU algorithm, but `gpu_id` takes priority
|
||||
std::unique_ptr<Learner> learner {Learner::Create(mat)};
|
||||
learner->SetParams({Arg{"tree_method", "hist"},
|
||||
Arg{"n_gpus", "1"}});
|
||||
Arg{"gpu_id", "0"}});
|
||||
learner->UpdateOneIter(0, p_dmat.get());
|
||||
ASSERT_EQ(learner->GetGenericParameter().gpu_id, 0);
|
||||
ASSERT_EQ(learner->GetGenericParameter().n_gpus, 1);
|
||||
}
|
||||
{
|
||||
// With CPU algorithm but GPU Predictor, this is to simulate when
|
||||
@@ -243,7 +237,6 @@ TEST(Learner, GPUConfiguration) {
|
||||
Arg{"predictor", "gpu_predictor"}});
|
||||
learner->UpdateOneIter(0, p_dmat.get());
|
||||
ASSERT_EQ(learner->GetGenericParameter().gpu_id, 0);
|
||||
ASSERT_EQ(learner->GetGenericParameter().n_gpus, 1);
|
||||
}
|
||||
|
||||
delete pp_dmat;
|
||||
|
||||
@@ -366,7 +366,7 @@ TEST(GpuHist, EvaluateSplits) {
|
||||
ASSERT_NEAR(res[1].fvalue, 0.26, xgboost::kRtEps);
|
||||
}
|
||||
|
||||
void TestHistogramIndexImpl(int n_gpus) {
|
||||
void TestHistogramIndexImpl() {
|
||||
// Test if the compressed histogram index matches when using a sparse
|
||||
// dmatrix with and without using external memory
|
||||
|
||||
@@ -384,7 +384,7 @@ void TestHistogramIndexImpl(int n_gpus) {
|
||||
{"max_leaves", "0"}
|
||||
};
|
||||
|
||||
GenericParameter generic_param(CreateEmptyGenericParam(0, n_gpus));
|
||||
GenericParameter generic_param(CreateEmptyGenericParam(0));
|
||||
hist_maker.Configure(training_params, &generic_param);
|
||||
|
||||
hist_maker.InitDataOnce(hist_maker_dmat.get());
|
||||
@@ -412,7 +412,7 @@ void TestHistogramIndexImpl(int n_gpus) {
|
||||
}
|
||||
|
||||
TEST(GpuHist, TestHistogramIndex) {
|
||||
TestHistogramIndexImpl(1);
|
||||
TestHistogramIndexImpl();
|
||||
}
|
||||
|
||||
} // namespace tree
|
||||
|
||||
@@ -29,7 +29,7 @@ TEST(Updater, Prune) {
|
||||
{0.25f, 0.24f}, {0.25f, 0.24f}, {0.25f, 0.24f}, {0.25f, 0.24f} };
|
||||
auto dmat = CreateDMatrix(32, 16, 0.4, 3);
|
||||
|
||||
auto lparam = CreateEmptyGenericParam(0, 0);
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
|
||||
// prepare tree
|
||||
RegTree tree = RegTree();
|
||||
|
||||
@@ -25,7 +25,7 @@ TEST(Updater, Refresh) {
|
||||
{"reg_lambda", "1"}};
|
||||
|
||||
RegTree tree = RegTree();
|
||||
auto lparam = CreateEmptyGenericParam(0, 0);
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
tree.param.InitAllowUnknown(cfg);
|
||||
std::vector<RegTree*> trees {&tree};
|
||||
std::unique_ptr<TreeUpdater> refresher(TreeUpdater::Create("refresh", &lparam));
|
||||
|
||||
Reference in New Issue
Block a user