rm some hip
This commit is contained in:
parent
f9f39b092b
commit
65012b356c
@ -180,10 +180,6 @@ TEST(Allocator, OOM) {
|
|||||||
ASSERT_THROW({dh::caching_device_vector<char> vec(size);}, dmlc::Error);
|
ASSERT_THROW({dh::caching_device_vector<char> vec(size);}, dmlc::Error);
|
||||||
ASSERT_THROW({dh::device_vector<char> vec(size);}, dmlc::Error);
|
ASSERT_THROW({dh::device_vector<char> vec(size);}, dmlc::Error);
|
||||||
// Clear last error so we don't fail subsequent tests
|
// Clear last error so we don't fail subsequent tests
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
cudaGetLastError();
|
cudaGetLastError();
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
hipGetLastError();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} // namespace xgboost
|
} // namespace xgboost
|
||||||
|
|||||||
@ -36,11 +36,7 @@ struct ReadSymbolFunction {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST(CompressedIterator, TestGPU) {
|
TEST(CompressedIterator, TestGPU) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
std::vector<int> test_cases = {1, 3, 426, 21, 64, 256, 100000, INT32_MAX};
|
std::vector<int> test_cases = {1, 3, 426, 21, 64, 256, 100000, INT32_MAX};
|
||||||
int num_elements = 1000;
|
int num_elements = 1000;
|
||||||
int repetitions = 1000;
|
int repetitions = 1000;
|
||||||
|
|||||||
@ -69,11 +69,7 @@ TEST(HistUtil, SketchBatchNumElements) {
|
|||||||
size_t constexpr kCols = 10000;
|
size_t constexpr kCols = 10000;
|
||||||
int device;
|
int device;
|
||||||
|
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaGetDevice(&device));
|
dh::safe_cuda(cudaGetDevice(&device));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipGetDevice(&device));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto avail = static_cast<size_t>(dh::AvailableMemory(device) * 0.8);
|
auto avail = static_cast<size_t>(dh::AvailableMemory(device) * 0.8);
|
||||||
auto per_elem = detail::BytesPerElement(false);
|
auto per_elem = detail::BytesPerElement(false);
|
||||||
|
|||||||
@ -25,36 +25,20 @@ struct TestStatus {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TestStatus () {
|
TestStatus () {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaMalloc(&status_, sizeof(int)));
|
dh::safe_cuda(cudaMalloc(&status_, sizeof(int)));
|
||||||
int h_status = 1;
|
int h_status = 1;
|
||||||
dh::safe_cuda(cudaMemcpy(status_, &h_status,
|
dh::safe_cuda(cudaMemcpy(status_, &h_status,
|
||||||
sizeof(int), cudaMemcpyHostToDevice));
|
sizeof(int), cudaMemcpyHostToDevice));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipMalloc(&status_, sizeof(int)));
|
|
||||||
int h_status = 1;
|
|
||||||
dh::safe_cuda(hipMemcpy(status_, &h_status,
|
|
||||||
sizeof(int), hipMemcpyHostToDevice));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
~TestStatus() {
|
~TestStatus() {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaFree(status_));
|
dh::safe_cuda(cudaFree(status_));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipFree(status_));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Get() {
|
int Get() {
|
||||||
int h_status;
|
int h_status;
|
||||||
|
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaMemcpy(&h_status, status_,
|
dh::safe_cuda(cudaMemcpy(&h_status, status_,
|
||||||
sizeof(int), cudaMemcpyDeviceToHost));
|
sizeof(int), cudaMemcpyDeviceToHost));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipMemcpy(&h_status, status_,
|
|
||||||
sizeof(int), hipMemcpyDeviceToHost));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return h_status;
|
return h_status;
|
||||||
}
|
}
|
||||||
@ -112,22 +96,14 @@ TEST(GPUSpan, FromOther) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpan, Assignment) {
|
TEST(GPUSpan, Assignment) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestAssignment{status.Data()});
|
dh::LaunchN(16, TestAssignment{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpan, TestStatus) {
|
TEST(GPUSpan, TestStatus) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestTestStatus{status.Data()});
|
dh::LaunchN(16, TestTestStatus{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), -1);
|
ASSERT_EQ(status.Get(), -1);
|
||||||
@ -150,11 +126,7 @@ struct TestEqual {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST(GPUSpan, WithTrust) {
|
TEST(GPUSpan, WithTrust) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
// Not adviced to initialize span with host_vector, since h_vec.data() is
|
// Not adviced to initialize span with host_vector, since h_vec.data() is
|
||||||
// a host function.
|
// a host function.
|
||||||
thrust::host_vector<float> h_vec (16);
|
thrust::host_vector<float> h_vec (16);
|
||||||
@ -191,22 +163,14 @@ TEST(GPUSpan, WithTrust) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpan, BeginEnd) {
|
TEST(GPUSpan, BeginEnd) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestBeginEnd{status.Data()});
|
dh::LaunchN(16, TestBeginEnd{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpan, RBeginREnd) {
|
TEST(GPUSpan, RBeginREnd) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestRBeginREnd{status.Data()});
|
dh::LaunchN(16, TestRBeginREnd{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
@ -238,22 +202,14 @@ TEST(GPUSpan, Modify) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpan, Observers) {
|
TEST(GPUSpan, Observers) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestObservers{status.Data()});
|
dh::LaunchN(16, TestObservers{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpan, Compare) {
|
TEST(GPUSpan, Compare) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestIterCompare{status.Data()});
|
dh::LaunchN(16, TestIterCompare{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
@ -273,11 +229,7 @@ struct TestElementAccess {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST(GPUSpanDeathTest, ElementAccess) {
|
TEST(GPUSpanDeathTest, ElementAccess) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
auto test_element_access = []() {
|
auto test_element_access = []() {
|
||||||
thrust::host_vector<float> h_vec (16);
|
thrust::host_vector<float> h_vec (16);
|
||||||
InitializeRange(h_vec.begin(), h_vec.end());
|
InitializeRange(h_vec.begin(), h_vec.end());
|
||||||
@ -375,13 +327,8 @@ void TestFrontBack() {
|
|||||||
// make sure the termination happens inside this test.
|
// make sure the termination happens inside this test.
|
||||||
try {
|
try {
|
||||||
dh::LaunchN(1, [=] __device__(size_t) { s.front(); });
|
dh::LaunchN(1, [=] __device__(size_t) { s.front(); });
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaDeviceSynchronize());
|
dh::safe_cuda(cudaDeviceSynchronize());
|
||||||
dh::safe_cuda(cudaGetLastError());
|
dh::safe_cuda(cudaGetLastError());
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipDeviceSynchronize());
|
|
||||||
dh::safe_cuda(hipGetLastError());
|
|
||||||
#endif
|
|
||||||
} catch (dmlc::Error const& e) {
|
} catch (dmlc::Error const& e) {
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
@ -391,13 +338,8 @@ void TestFrontBack() {
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
dh::LaunchN(1, [=] __device__(size_t) { s.back(); });
|
dh::LaunchN(1, [=] __device__(size_t) { s.back(); });
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaDeviceSynchronize());
|
dh::safe_cuda(cudaDeviceSynchronize());
|
||||||
dh::safe_cuda(cudaGetLastError());
|
dh::safe_cuda(cudaGetLastError());
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipDeviceSynchronize());
|
|
||||||
dh::safe_cuda(hipGetLastError());
|
|
||||||
#endif
|
|
||||||
} catch (dmlc::Error const& e) {
|
} catch (dmlc::Error const& e) {
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
@ -447,66 +389,42 @@ TEST(GPUSpanDeathTest, Subspan) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpanIter, Construct) {
|
TEST(GPUSpanIter, Construct) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestIterConstruct{status.Data()});
|
dh::LaunchN(16, TestIterConstruct{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpanIter, Ref) {
|
TEST(GPUSpanIter, Ref) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestIterRef{status.Data()});
|
dh::LaunchN(16, TestIterRef{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpanIter, Calculate) {
|
TEST(GPUSpanIter, Calculate) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestIterCalculate{status.Data()});
|
dh::LaunchN(16, TestIterCalculate{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpanIter, Compare) {
|
TEST(GPUSpanIter, Compare) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestIterCompare{status.Data()});
|
dh::LaunchN(16, TestIterCompare{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpan, AsBytes) {
|
TEST(GPUSpan, AsBytes) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestAsBytes{status.Data()});
|
dh::LaunchN(16, TestAsBytes{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GPUSpan, AsWritableBytes) {
|
TEST(GPUSpan, AsWritableBytes) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
dh::LaunchN(16, TestAsWritableBytes{status.Data()});
|
dh::LaunchN(16, TestAsWritableBytes{status.Data()});
|
||||||
ASSERT_EQ(status.Get(), 1);
|
ASSERT_EQ(status.Get(), 1);
|
||||||
|
|||||||
@ -76,7 +76,7 @@ TEST(Stats, Median) {
|
|||||||
Median(&ctx, values, weights, &out);
|
Median(&ctx, values, weights, &out);
|
||||||
m = out(0);
|
m = out(0);
|
||||||
ASSERT_EQ(m, .5f);
|
ASSERT_EQ(m, .5f);
|
||||||
#endif // defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP)
|
#endif // defined(XGBOOST_USE_CUDA)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ TEST(Stats, Median) {
|
|||||||
Median(&ctx, values, weights, &out);
|
Median(&ctx, values, weights, &out);
|
||||||
ASSERT_EQ(out(0), .5f);
|
ASSERT_EQ(out(0), .5f);
|
||||||
ASSERT_EQ(out(1), .5f);
|
ASSERT_EQ(out(1), .5f);
|
||||||
#endif // defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP)
|
#endif // defined(XGBOOST_USE_CUDA)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,25 +40,13 @@ TEST(ArrayInterface, Stream) {
|
|||||||
TEST(ArrayInterface, Ptr) {
|
TEST(ArrayInterface, Ptr) {
|
||||||
std::vector<float> h_data(10);
|
std::vector<float> h_data(10);
|
||||||
ASSERT_FALSE(ArrayInterfaceHandler::IsCudaPtr(h_data.data()));
|
ASSERT_FALSE(ArrayInterfaceHandler::IsCudaPtr(h_data.data()));
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaGetLastError());
|
dh::safe_cuda(cudaGetLastError());
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipGetLastError());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dh::device_vector<float> d_data(10);
|
dh::device_vector<float> d_data(10);
|
||||||
ASSERT_TRUE(ArrayInterfaceHandler::IsCudaPtr(d_data.data().get()));
|
ASSERT_TRUE(ArrayInterfaceHandler::IsCudaPtr(d_data.data().get()));
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaGetLastError());
|
dh::safe_cuda(cudaGetLastError());
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipGetLastError());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ASSERT_FALSE(ArrayInterfaceHandler::IsCudaPtr(nullptr));
|
ASSERT_FALSE(ArrayInterfaceHandler::IsCudaPtr(nullptr));
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaGetLastError());
|
dh::safe_cuda(cudaGetLastError());
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipGetLastError());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} // namespace xgboost
|
} // namespace xgboost
|
||||||
|
|||||||
@ -51,11 +51,7 @@ void TestCudfAdapter()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaDeviceSynchronize());
|
dh::safe_cuda(cudaDeviceSynchronize());
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipDeviceSynchronize());
|
|
||||||
#endif
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -234,11 +234,7 @@ TEST(EllpackPage, Compact) {
|
|||||||
|
|
||||||
dh::LaunchN(kCols, ReadRowFunction(impl->GetDeviceAccessor(FstCU()),
|
dh::LaunchN(kCols, ReadRowFunction(impl->GetDeviceAccessor(FstCU()),
|
||||||
current_row, row_d.data().get()));
|
current_row, row_d.data().get()));
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaDeviceSynchronize());
|
dh::safe_cuda(cudaDeviceSynchronize());
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipDeviceSynchronize());
|
|
||||||
#endif
|
|
||||||
thrust::copy(row_d.begin(), row_d.end(), row.begin());
|
thrust::copy(row_d.begin(), row_d.end(), row.begin());
|
||||||
|
|
||||||
dh::LaunchN(kCols,
|
dh::LaunchN(kCols,
|
||||||
|
|||||||
@ -47,11 +47,7 @@ std::string PrepareData(std::string typestr, thrust::device_vector<T>* out, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(MetaInfo, FromInterface) {
|
TEST(MetaInfo, FromInterface) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
cudaSetDevice(0);
|
cudaSetDevice(0);
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
hipSetDevice(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Context ctx;
|
Context ctx;
|
||||||
thrust::device_vector<float> d_data;
|
thrust::device_vector<float> d_data;
|
||||||
@ -96,11 +92,7 @@ TEST(MetaInfo, GPUStridedData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(MetaInfo, Group) {
|
TEST(MetaInfo, Group) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
cudaSetDevice(0);
|
cudaSetDevice(0);
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
hipSetDevice(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MetaInfo info;
|
MetaInfo info;
|
||||||
Context ctx;
|
Context ctx;
|
||||||
@ -155,11 +147,7 @@ TEST(MetaInfo, GPUQid) {
|
|||||||
|
|
||||||
|
|
||||||
TEST(MetaInfo, DeviceExtend) {
|
TEST(MetaInfo, DeviceExtend) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
size_t const kRows = 100;
|
size_t const kRows = 100;
|
||||||
MetaInfo lhs, rhs;
|
MetaInfo lhs, rhs;
|
||||||
|
|||||||
@ -115,13 +115,8 @@ TEST(SimpleDMatrix, FromColumnarWithEmptyRows) {
|
|||||||
data.resize(kRows);
|
data.resize(kRows);
|
||||||
thrust::sequence(data.begin(), data.end(), 0);
|
thrust::sequence(data.begin(), data.end(), 0);
|
||||||
|
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaDeviceSynchronize());
|
dh::safe_cuda(cudaDeviceSynchronize());
|
||||||
dh::safe_cuda(cudaGetLastError());
|
dh::safe_cuda(cudaGetLastError());
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipDeviceSynchronize());
|
|
||||||
dh::safe_cuda(hipGetLastError());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ASSERT_EQ(data.size(), kRows);
|
ASSERT_EQ(data.size(), kRows);
|
||||||
|
|
||||||
|
|||||||
@ -724,27 +724,14 @@ class RMMAllocator {
|
|||||||
int n_gpu;
|
int n_gpu;
|
||||||
RMMAllocator() : n_gpu(common::AllVisibleGPUs()) {
|
RMMAllocator() : n_gpu(common::AllVisibleGPUs()) {
|
||||||
int current_device;
|
int current_device;
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
CHECK_EQ(cudaGetDevice(¤t_device), cudaSuccess);
|
CHECK_EQ(cudaGetDevice(¤t_device), cudaSuccess);
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
CHECK_EQ(hipGetDevice(¤t_device), hipSuccess);
|
|
||||||
#endif
|
|
||||||
for (int i = 0; i < n_gpu; ++i) {
|
for (int i = 0; i < n_gpu; ++i) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
CHECK_EQ(cudaSetDevice(i), cudaSuccess);
|
CHECK_EQ(cudaSetDevice(i), cudaSuccess);
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
CHECK_EQ(hipSetDevice(i), hipSuccess);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cuda_mr.push_back(std::make_unique<CUDAMemoryResource>());
|
cuda_mr.push_back(std::make_unique<CUDAMemoryResource>());
|
||||||
pool_mr.push_back(std::make_unique<PoolMemoryResource>(cuda_mr[i].get()));
|
pool_mr.push_back(std::make_unique<PoolMemoryResource>(cuda_mr[i].get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
CHECK_EQ(cudaSetDevice(current_device), cudaSuccess);
|
CHECK_EQ(cudaSetDevice(current_device), cudaSuccess);
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
CHECK_EQ(hipSetDevice(current_device), hipSuccess);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
~RMMAllocator() = default;
|
~RMMAllocator() = default;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -218,11 +218,7 @@ TEST_F(MGPUPredictorTest, LesserFeaturesColumnSplit) {
|
|||||||
|
|
||||||
// Very basic test of empty model
|
// Very basic test of empty model
|
||||||
TEST(GPUPredictor, ShapStump) {
|
TEST(GPUPredictor, ShapStump) {
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
cudaSetDevice(0);
|
cudaSetDevice(0);
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
hipSetDevice(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto ctx = MakeCUDACtx(0);
|
auto ctx = MakeCUDACtx(0);
|
||||||
LearnerModelParam mparam{MakeMP(1, .5, 1, ctx.Device())};
|
LearnerModelParam mparam{MakeMP(1, .5, 1, ctx.Device())};
|
||||||
|
|||||||
@ -785,7 +785,7 @@ TEST(ColumnSplitColumnSampler, Approx) { TestColumnSplitColumnSampler("approx",
|
|||||||
|
|
||||||
TEST(ColumnSplitColumnSampler, Hist) { TestColumnSplitColumnSampler("hist", false); }
|
TEST(ColumnSplitColumnSampler, Hist) { TestColumnSplitColumnSampler("hist", false); }
|
||||||
|
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
#if defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP)
|
||||||
TEST(MGPUColumnSplitColumnSampler, GPUApprox) { TestColumnSplitColumnSampler("approx", true); }
|
TEST(MGPUColumnSplitColumnSampler, GPUApprox) { TestColumnSplitColumnSampler("approx", true); }
|
||||||
|
|
||||||
TEST(MGPUColumnSplitColumnSampler, GPUHist) { TestColumnSplitColumnSampler("hist", true); }
|
TEST(MGPUColumnSplitColumnSampler, GPUHist) { TestColumnSplitColumnSampler("hist", true); }
|
||||||
@ -799,7 +799,7 @@ TEST(ColumnSplitInteractionConstraints, Hist) {
|
|||||||
TestColumnSplitInteractionConstraints("hist", false);
|
TestColumnSplitInteractionConstraints("hist", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
#if defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP)
|
||||||
TEST(MGPUColumnSplitInteractionConstraints, GPUApprox) {
|
TEST(MGPUColumnSplitInteractionConstraints, GPUApprox) {
|
||||||
TestColumnSplitInteractionConstraints("approx", true);
|
TestColumnSplitInteractionConstraints("approx", true);
|
||||||
}
|
}
|
||||||
@ -817,7 +817,7 @@ TEST(ColumnSplitMonotoneConstraints, Hist) {
|
|||||||
TestColumnSplitMonotoneConstraints("hist", false);
|
TestColumnSplitMonotoneConstraints("hist", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
#if defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP)
|
||||||
TEST(MGPUColumnSplitMonotoneConstraints, GPUApprox) {
|
TEST(MGPUColumnSplitMonotoneConstraints, GPUApprox) {
|
||||||
TestColumnSplitMonotoneConstraints("approx", true);
|
TestColumnSplitMonotoneConstraints("approx", true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,15 +48,9 @@ void TestDeterministicHistogram(bool is_dense, int shm_size) {
|
|||||||
d_histogram, quantiser);
|
d_histogram, quantiser);
|
||||||
|
|
||||||
std::vector<GradientPairInt64> histogram_h(num_bins);
|
std::vector<GradientPairInt64> histogram_h(num_bins);
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaMemcpy(histogram_h.data(), d_histogram.data(),
|
dh::safe_cuda(cudaMemcpy(histogram_h.data(), d_histogram.data(),
|
||||||
num_bins * sizeof(GradientPairInt64),
|
num_bins * sizeof(GradientPairInt64),
|
||||||
cudaMemcpyDeviceToHost));
|
cudaMemcpyDeviceToHost));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipMemcpy(histogram_h.data(), d_histogram.data(),
|
|
||||||
num_bins * sizeof(GradientPairInt64),
|
|
||||||
hipMemcpyDeviceToHost));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (size_t i = 0; i < kRounds; ++i) {
|
for (size_t i = 0; i < kRounds; ++i) {
|
||||||
dh::device_vector<GradientPairInt64> new_histogram(num_bins);
|
dh::device_vector<GradientPairInt64> new_histogram(num_bins);
|
||||||
@ -68,15 +62,9 @@ void TestDeterministicHistogram(bool is_dense, int shm_size) {
|
|||||||
d_new_histogram, quantiser);
|
d_new_histogram, quantiser);
|
||||||
|
|
||||||
std::vector<GradientPairInt64> new_histogram_h(num_bins);
|
std::vector<GradientPairInt64> new_histogram_h(num_bins);
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaMemcpy(new_histogram_h.data(), d_new_histogram.data(),
|
dh::safe_cuda(cudaMemcpy(new_histogram_h.data(), d_new_histogram.data(),
|
||||||
num_bins * sizeof(GradientPairInt64),
|
num_bins * sizeof(GradientPairInt64),
|
||||||
cudaMemcpyDeviceToHost));
|
cudaMemcpyDeviceToHost));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipMemcpy(new_histogram_h.data(), d_new_histogram.data(),
|
|
||||||
num_bins * sizeof(GradientPairInt64),
|
|
||||||
hipMemcpyDeviceToHost));
|
|
||||||
#endif
|
|
||||||
for (size_t j = 0; j < new_histogram_h.size(); ++j) {
|
for (size_t j = 0; j < new_histogram_h.size(); ++j) {
|
||||||
ASSERT_EQ(new_histogram_h[j].GetQuantisedGrad(), histogram_h[j].GetQuantisedGrad());
|
ASSERT_EQ(new_histogram_h[j].GetQuantisedGrad(), histogram_h[j].GetQuantisedGrad());
|
||||||
ASSERT_EQ(new_histogram_h[j].GetQuantisedHess(), histogram_h[j].GetQuantisedHess());
|
ASSERT_EQ(new_histogram_h[j].GetQuantisedHess(), histogram_h[j].GetQuantisedHess());
|
||||||
@ -96,15 +84,9 @@ void TestDeterministicHistogram(bool is_dense, int shm_size) {
|
|||||||
dh::ToSpan(baseline), quantiser);
|
dh::ToSpan(baseline), quantiser);
|
||||||
|
|
||||||
std::vector<GradientPairInt64> baseline_h(num_bins);
|
std::vector<GradientPairInt64> baseline_h(num_bins);
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaMemcpy(baseline_h.data(), baseline.data().get(),
|
dh::safe_cuda(cudaMemcpy(baseline_h.data(), baseline.data().get(),
|
||||||
num_bins * sizeof(GradientPairInt64),
|
num_bins * sizeof(GradientPairInt64),
|
||||||
cudaMemcpyDeviceToHost));
|
cudaMemcpyDeviceToHost));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipMemcpy(baseline_h.data(), baseline.data().get(),
|
|
||||||
num_bins * sizeof(GradientPairInt64),
|
|
||||||
hipMemcpyDeviceToHost));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (size_t i = 0; i < baseline.size(); ++i) {
|
for (size_t i = 0; i < baseline.size(); ++i) {
|
||||||
EXPECT_NEAR(baseline_h[i].GetQuantisedGrad(), histogram_h[i].GetQuantisedGrad(),
|
EXPECT_NEAR(baseline_h[i].GetQuantisedGrad(), histogram_h[i].GetQuantisedGrad(),
|
||||||
|
|||||||
@ -70,15 +70,9 @@ void TestSortPositionBatch(const std::vector<int>& ridx_in, const std::vector<Se
|
|||||||
total_rows += segments.at(i).Size();
|
total_rows += segments.at(i).Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaMemcpyAsync(d_batch_info.data().get(), h_batch_info.data(),
|
dh::safe_cuda(cudaMemcpyAsync(d_batch_info.data().get(), h_batch_info.data(),
|
||||||
h_batch_info.size() * sizeof(PerNodeData<int>), cudaMemcpyDefault,
|
h_batch_info.size() * sizeof(PerNodeData<int>), cudaMemcpyDefault,
|
||||||
nullptr));
|
nullptr));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipMemcpyAsync(d_batch_info.data().get(), h_batch_info.data(),
|
|
||||||
h_batch_info.size() * sizeof(PerNodeData<int>), hipMemcpyDefault,
|
|
||||||
nullptr));
|
|
||||||
#endif
|
|
||||||
dh::device_vector<int8_t> tmp;
|
dh::device_vector<int8_t> tmp;
|
||||||
SortPositionBatch<uint32_t, decltype(op), int>(dh::ToSpan(d_batch_info), dh::ToSpan(ridx),
|
SortPositionBatch<uint32_t, decltype(op), int>(dh::ToSpan(d_batch_info), dh::ToSpan(ridx),
|
||||||
dh::ToSpan(ridx_tmp), dh::ToSpan(counts),
|
dh::ToSpan(ridx_tmp), dh::ToSpan(counts),
|
||||||
|
|||||||
@ -31,11 +31,7 @@
|
|||||||
namespace xgboost::tree {
|
namespace xgboost::tree {
|
||||||
TEST(GpuHist, DeviceHistogram) {
|
TEST(GpuHist, DeviceHistogram) {
|
||||||
// Ensures that node allocates correctly after reaching `kStopGrowingSize`.
|
// Ensures that node allocates correctly after reaching `kStopGrowingSize`.
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaSetDevice(0));
|
dh::safe_cuda(cudaSetDevice(0));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipSetDevice(0));
|
|
||||||
#endif
|
|
||||||
constexpr size_t kNBins = 128;
|
constexpr size_t kNBins = 128;
|
||||||
constexpr int kNNodes = 4;
|
constexpr int kNNodes = 4;
|
||||||
constexpr size_t kStopGrowing = kNNodes * kNBins * 2u;
|
constexpr size_t kStopGrowing = kNNodes * kNBins * 2u;
|
||||||
@ -138,13 +134,8 @@ void TestBuildHist(bool use_shared_memory_histograms) {
|
|||||||
// d_hist.data stored in float, not gradient pair
|
// d_hist.data stored in float, not gradient pair
|
||||||
thrust::host_vector<GradientPairInt64> h_result (node_histogram.size());
|
thrust::host_vector<GradientPairInt64> h_result (node_histogram.size());
|
||||||
|
|
||||||
#if defined(XGBOOST_USE_CUDA)
|
|
||||||
dh::safe_cuda(cudaMemcpy(h_result.data(), node_histogram.data(), node_histogram.size_bytes(),
|
dh::safe_cuda(cudaMemcpy(h_result.data(), node_histogram.data(), node_histogram.size_bytes(),
|
||||||
cudaMemcpyDeviceToHost));
|
cudaMemcpyDeviceToHost));
|
||||||
#elif defined(XGBOOST_USE_HIP)
|
|
||||||
dh::safe_cuda(hipMemcpy(h_result.data(), node_histogram.data(), node_histogram.size_bytes(),
|
|
||||||
hipMemcpyDeviceToHost));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::vector<GradientPairPrecise> solution = GetHostHistGpair();
|
std::vector<GradientPairPrecise> solution = GetHostHistGpair();
|
||||||
for (size_t i = 0; i < h_result.size(); ++i) {
|
for (size_t i = 0; i < h_result.size(); ++i) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user