more tests
This commit is contained in:
@@ -22,8 +22,13 @@ TEST(ArrayInterface, Stream) {
|
||||
HostDeviceVector<float> storage;
|
||||
auto arr_str = RandomDataGenerator{kRows, kCols, 0}.GenerateArrayInterface(&storage);
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
cudaStream_t stream;
|
||||
cudaStreamCreate(&stream);
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
hipStream_t stream;
|
||||
hipStreamCreate(&stream);
|
||||
#endif
|
||||
|
||||
auto j_arr =Json::Load(StringView{arr_str});
|
||||
j_arr["stream"] = Integer(reinterpret_cast<int64_t>(stream));
|
||||
@@ -37,19 +42,35 @@ TEST(ArrayInterface, Stream) {
|
||||
auto t = out[0];
|
||||
CHECK_GE(t, dur);
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
cudaStreamDestroy(stream);
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
hipStreamDestroy(stream);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(ArrayInterface, Ptr) {
|
||||
std::vector<float> h_data(10);
|
||||
ASSERT_FALSE(ArrayInterfaceHandler::IsCudaPtr(h_data.data()));
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
dh::safe_cuda(cudaGetLastError());
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
dh::safe_cuda(hipGetLastError());
|
||||
#endif
|
||||
|
||||
dh::device_vector<float> d_data(10);
|
||||
ASSERT_TRUE(ArrayInterfaceHandler::IsCudaPtr(d_data.data().get()));
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
dh::safe_cuda(cudaGetLastError());
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
dh::safe_cuda(hipGetLastError());
|
||||
#endif
|
||||
|
||||
ASSERT_FALSE(ArrayInterfaceHandler::IsCudaPtr(nullptr));
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
dh::safe_cuda(cudaGetLastError());
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
dh::safe_cuda(hipGetLastError());
|
||||
#endif
|
||||
}
|
||||
} // namespace xgboost
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
#if defined(XGBOOST_USE_HIP)
|
||||
#include "test_array_interface.cu"
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,13 @@
|
||||
#include "../../../src/common/timer.h"
|
||||
#include "../helpers.h"
|
||||
#include <thrust/device_vector.h>
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
#include "../../../src/data/device_adapter.cuh"
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
#include "../../../src/data/device_adapter.hip.h"
|
||||
#endif
|
||||
|
||||
#include "test_array_interface.h"
|
||||
using namespace xgboost; // NOLINT
|
||||
|
||||
@@ -44,7 +50,12 @@ void TestCudfAdapter()
|
||||
KERNEL_CHECK(element.value == element.row_idx * 2.0f);
|
||||
}
|
||||
});
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
dh::safe_cuda(cudaDeviceSynchronize());
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
dh::safe_cuda(hipDeviceSynchronize());
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
#if defined(XGBOOST_USE_HIP)
|
||||
#include "test_device_adapter.cu"
|
||||
#endif
|
||||
|
||||
@@ -223,7 +223,11 @@ TEST(EllpackPage, Compact) {
|
||||
|
||||
dh::LaunchN(kCols, ReadRowFunction(impl->GetDeviceAccessor(0),
|
||||
current_row, row_d.data().get()));
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
dh::safe_cuda(cudaDeviceSynchronize());
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
dh::safe_cuda(hipDeviceSynchronize());
|
||||
#endif
|
||||
thrust::copy(row_d.begin(), row_d.end(), row.begin());
|
||||
|
||||
dh::LaunchN(kCols,
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
#if defined(XGBOOST_USE_HIP)
|
||||
#include "test_ellpack_page.cu"
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
#if defined(XGBOOST_USE_HIP)
|
||||
#include "test_ellpack_page_raw_format.cu"
|
||||
#endif
|
||||
|
||||
@@ -133,7 +133,7 @@ TEST(GradientIndex, PushBatch) {
|
||||
test(0.9f);
|
||||
}
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
#if defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP)
|
||||
|
||||
namespace {
|
||||
class GHistIndexMatrixTest : public testing::TestWithParam<std::tuple<float, float>> {
|
||||
@@ -207,6 +207,6 @@ INSTANTIATE_TEST_SUITE_P(GHistIndexMatrix, GHistIndexMatrixTest,
|
||||
std::make_tuple(.5f, .6), // sparse columns
|
||||
std::make_tuple(.6f, .4))); // dense columns
|
||||
|
||||
#endif // defined(XGBOOST_USE_CUDA)
|
||||
#endif // defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP)
|
||||
} // namespace data
|
||||
} // namespace xgboost
|
||||
|
||||
@@ -3,7 +3,12 @@
|
||||
*/
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
#include "../../../src/data/device_adapter.cuh"
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
#include "../../../src/data/device_adapter.hip.h"
|
||||
#endif
|
||||
|
||||
#include "../../../src/data/ellpack_page.cuh"
|
||||
#include "../../../src/data/iterative_dmatrix.h"
|
||||
#include "../helpers.h"
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
#if defined(XGBOOST_USE_HIP)
|
||||
#include "test_iterative_dmatrix.cu"
|
||||
#endif
|
||||
|
||||
@@ -258,7 +258,7 @@ TEST(MetaInfo, Validate) {
|
||||
EXPECT_THROW(info.SetInfo(ctx, "group", groups.data(), xgboost::DataType::kUInt32, groups.size()),
|
||||
dmlc::Error);
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
#if defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP)
|
||||
info.group_ptr_.clear();
|
||||
labels.resize(info.num_row_);
|
||||
info.SetInfo(ctx, "label", labels.data(), xgboost::DataType::kFloat32, info.num_row_);
|
||||
@@ -271,7 +271,7 @@ TEST(MetaInfo, Validate) {
|
||||
std::string arr_interface_str{ArrayInterfaceStr(
|
||||
xgboost::linalg::MakeVec(d_groups.ConstDevicePointer(), d_groups.Size(), 0))};
|
||||
EXPECT_THROW(info.SetInfo(ctx, "group", xgboost::StringView{arr_interface_str}), dmlc::Error);
|
||||
#endif // defined(XGBOOST_USE_CUDA)
|
||||
#endif // defined(XGBOOST_USE_CUDA) || defined(XGBOOST_USE_HIP)
|
||||
}
|
||||
|
||||
TEST(MetaInfo, HostExtend) {
|
||||
|
||||
@@ -6,7 +6,12 @@
|
||||
#include <xgboost/data.h>
|
||||
#include <xgboost/json.h>
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
#include "../../../src/common/device_helpers.cuh"
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
#include "../../../src/common/device_helpers.hip.h"
|
||||
#endif
|
||||
|
||||
#include "test_array_interface.h"
|
||||
#include "test_metainfo.h"
|
||||
|
||||
@@ -43,7 +48,12 @@ std::string PrepareData(std::string typestr, thrust::device_vector<T>* out, cons
|
||||
}
|
||||
|
||||
TEST(MetaInfo, FromInterface) {
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
cudaSetDevice(0);
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
hipSetDevice(0);
|
||||
#endif
|
||||
|
||||
Context ctx;
|
||||
thrust::device_vector<float> d_data;
|
||||
|
||||
@@ -87,7 +97,12 @@ TEST(MetaInfo, GPUStridedData) {
|
||||
}
|
||||
|
||||
TEST(MetaInfo, Group) {
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
cudaSetDevice(0);
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
hipSetDevice(0);
|
||||
#endif
|
||||
|
||||
MetaInfo info;
|
||||
Context ctx;
|
||||
|
||||
@@ -141,7 +156,12 @@ TEST(MetaInfo, GPUQid) {
|
||||
|
||||
|
||||
TEST(MetaInfo, DeviceExtend) {
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
dh::safe_cuda(cudaSetDevice(0));
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
dh::safe_cuda(hipSetDevice(0));
|
||||
#endif
|
||||
|
||||
size_t const kRows = 100;
|
||||
MetaInfo lhs, rhs;
|
||||
Context ctx;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
#if defined(XGBOOST_USE_HIP)
|
||||
#include "test_metainfo.cu"
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
#include <xgboost/host_device_vector.h>
|
||||
#include <memory>
|
||||
#include "../helpers.h"
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
#include "../../../src/data/device_adapter.cuh"
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
#include "../../../src/data/device_adapter.hip.h"
|
||||
#endif
|
||||
|
||||
#include "../../../src/data/proxy_dmatrix.h"
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
#if defined(XGBOOST_USE_HIP)
|
||||
#include "test_proxy_dmatrix.cu"
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,13 @@
|
||||
#include "../../../src/data/simple_dmatrix.h"
|
||||
|
||||
#include <thrust/sequence.h>
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
#include "../../../src/data/device_adapter.cuh"
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
#include "../../../src/data/device_adapter.hip.h"
|
||||
#endif
|
||||
|
||||
#include "../helpers.h"
|
||||
#include "test_array_interface.h"
|
||||
#include "../../../src/data/array_interface.h"
|
||||
@@ -109,8 +115,14 @@ TEST(SimpleDMatrix, FromColumnarWithEmptyRows) {
|
||||
auto& data = columns_data[i];
|
||||
data.resize(kRows);
|
||||
thrust::sequence(data.begin(), data.end(), 0);
|
||||
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
dh::safe_cuda(cudaDeviceSynchronize());
|
||||
dh::safe_cuda(cudaGetLastError());
|
||||
#elif defined(XGBOOST_USE_HIP)
|
||||
dh::safe_cuda(hipDeviceSynchronize());
|
||||
dh::safe_cuda(hipGetLastError());
|
||||
#endif
|
||||
|
||||
ASSERT_EQ(data.size(), kRows);
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
#if defined(XGBOOST_USE_HIP)
|
||||
#include "test_simple_dmatrix.cu"
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
#if defined(XGBOOST_USE_HIP)
|
||||
#include "test_sparse_page_dmatrix.cu"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user