| 343 | } |
| 344 | |
| 345 | auto TestSparsePageDMatrixDeterminism(std::int32_t n_threads) { |
| 346 | std::vector<float> sparse_data; |
| 347 | std::vector<size_t> sparse_rptr; |
| 348 | std::vector<bst_feature_t> sparse_cids; |
| 349 | |
| 350 | common::TemporaryDirectory tmpdir; |
| 351 | auto prefix = (tmpdir.Path() / "temp").string(); |
| 352 | auto dmat = RandomDataGenerator{4096, 64, 0.0}.Batches(4).GenerateSparsePageDMatrix(prefix, true); |
| 353 | |
| 354 | auto config = ExtMemConfig{prefix, |
| 355 | false, |
| 356 | ::xgboost::cuda_impl::AutoHostRatio(), |
| 357 | cuda_impl::MatchingPageBytes(), |
| 358 | std::numeric_limits<float>::quiet_NaN(), |
| 359 | n_threads}; |
| 360 | CHECK(dmat->Ctx()->Threads() == n_threads || dmat->Ctx()->Threads() == AllThreadsForTest()); |
| 361 | |
| 362 | DMatrixToCSR(dmat.get(), &sparse_data, &sparse_rptr, &sparse_cids); |
| 363 | |
| 364 | auto cache_name = |
| 365 | data::MakeId(prefix, dynamic_cast<data::SparsePageDMatrix *>(dmat.get())) + ".row.page"; |
| 366 | auto cache = common::LoadSequentialFile(cache_name); |
| 367 | return cache; |
| 368 | } |
| 369 | |
| 370 | TEST(SparsePageDMatrix, Determinism) { |
| 371 | #if defined(_MSC_VER) |
no test coverage detected