diff --git a/src/c_api/c_api.cc b/src/c_api/c_api.cc index 49b03731ad07..ff61531a535f 100644 --- a/src/c_api/c_api.cc +++ b/src/c_api/c_api.cc @@ -322,12 +322,7 @@ XGB_DLL int XGDMatrixCreateFromCallback(DataIterHandle iter, DMatrixHandle proxy xgboost_CHECK_C_ARG_PTR(reset); xgboost_CHECK_C_ARG_PTR(out); - ExtMemConfig config{.cache = cache, - .on_host = on_host, - .min_cache_page_bytes = min_cache_page_bytes, - .missing = missing, - .n_threads = n_threads}; - + auto config = ExtMemConfig{cache, on_host, min_cache_page_bytes, missing, n_threads}; *out = new std::shared_ptr{ xgboost::DMatrix::Create(iter, proxy, reset, next, config)}; API_END(); @@ -403,11 +398,7 @@ XGB_DLL int XGExtMemQuantileDMatrixCreateFromCallback(DataIterHandle iter, DMatr xgboost_CHECK_C_ARG_PTR(reset); xgboost_CHECK_C_ARG_PTR(out); - ExtMemConfig config{.cache = cache, - .on_host = on_host, - .min_cache_page_bytes = min_cache_page_bytes, - .missing = missing, - .n_threads = n_threads}; + auto config = ExtMemConfig{cache, on_host, min_cache_page_bytes, missing, n_threads}; *out = new std::shared_ptr{ xgboost::DMatrix::Create(iter, proxy, p_ref, reset, next, max_bin, config)}; API_END(); diff --git a/src/data/data.cc b/src/data/data.cc index 14d056fe2c62..9405cbbf2496 100644 --- a/src/data/data.cc +++ b/src/data/data.cc @@ -915,11 +915,8 @@ DMatrix* DMatrix::Load(const std::string& uri, bool silent, DataSplitMode data_s CHECK(data_split_mode != DataSplitMode::kCol) << "Column-wise data split is not supported for external memory."; data::FileIterator iter{fname, static_cast(partid), static_cast(npart)}; - auto config = ExtMemConfig{.cache = cache_file, - .on_host = false, - .min_cache_page_bytes = cuda_impl::MatchingPageBytes(), - .missing = std::numeric_limits::quiet_NaN(), - .n_threads = 1}; + auto config = ExtMemConfig{cache_file, false, cuda_impl::MatchingPageBytes(), + std::numeric_limits::quiet_NaN(), 1}; dmat = new data::SparsePageDMatrix{&iter, iter.Proxy(), data::fileiter::Reset, data::fileiter::Next, config}; } diff --git a/tests/cpp/c_api/test_c_api.cc b/tests/cpp/c_api/test_c_api.cc index 9c5d601e8a42..50fc076fd298 100644 --- a/tests/cpp/c_api/test_c_api.cc +++ b/tests/cpp/c_api/test_c_api.cc @@ -496,11 +496,8 @@ auto MakeExtMemForTest(bst_idx_t n_samples, bst_feature_t n_features, Json dconf 0); NumpyArrayIterForTest iter_1{0.0f, n_samples, n_features, n_batches}; - auto config = ExtMemConfig{.cache = "", - .on_host = false, - .min_cache_page_bytes = cuda_impl::MatchingPageBytes(), - .missing = std::numeric_limits::quiet_NaN(), - .n_threads = 0}; + auto config = ExtMemConfig{"", false, cuda_impl::MatchingPageBytes(), + std::numeric_limits::quiet_NaN(), 0}; auto Xy = std::make_shared(&iter_1, iter_1.Proxy(), Reset, Next, config); MakeLabelForTest(Xy, p_fmat); return std::pair{p_fmat, Xy}; diff --git a/tests/cpp/data/test_sparse_page_dmatrix.cc b/tests/cpp/data/test_sparse_page_dmatrix.cc index 4b71bb989f66..6a8ddbecec6f 100644 --- a/tests/cpp/data/test_sparse_page_dmatrix.cc +++ b/tests/cpp/data/test_sparse_page_dmatrix.cc @@ -32,11 +32,8 @@ void TestSparseDMatrixLoadFile(Context const* ctx) { opath += "?indexing_mode=1&format=libsvm"; data::FileIterator iter{opath, 0, 1}; auto n_threads = 0; - auto config = ExtMemConfig{.cache = tmpdir.path + "cache", - .on_host = false, - .min_cache_page_bytes = cuda_impl::MatchingPageBytes(), - .missing = std::numeric_limits::quiet_NaN(), - .n_threads = n_threads}; + auto config = ExtMemConfig{tmpdir.path + "cache", false, cuda_impl::MatchingPageBytes(), + std::numeric_limits::quiet_NaN(), n_threads}; data::SparsePageDMatrix m{&iter, iter.Proxy(), data::fileiter::Reset, data::fileiter::Next, config}; ASSERT_EQ(AllThreadsForTest(), m.Ctx()->Threads()); @@ -365,11 +362,8 @@ auto TestSparsePageDMatrixDeterminism(int32_t threads) { CreateBigTestData(filename, 1 << 16); data::FileIterator iter(filename + "?format=libsvm", 0, 1); - auto config = ExtMemConfig{.cache = filename, - .on_host = false, - .min_cache_page_bytes = cuda_impl::MatchingPageBytes(), - .missing = std::numeric_limits::quiet_NaN(), - .n_threads = threads}; + auto config = ExtMemConfig{filename, false, cuda_impl::MatchingPageBytes(), + std::numeric_limits::quiet_NaN(), threads}; std::unique_ptr sparse{new data::SparsePageDMatrix{ &iter, iter.Proxy(), data::fileiter::Reset, data::fileiter::Next, config}}; CHECK(sparse->Ctx()->Threads() == threads || sparse->Ctx()->Threads() == AllThreadsForTest()); diff --git a/tests/cpp/helpers.cc b/tests/cpp/helpers.cc index 05d8fb0c8221..8e53210b29ab 100644 --- a/tests/cpp/helpers.cc +++ b/tests/cpp/helpers.cc @@ -448,12 +448,12 @@ void MakeLabels(DeviceOrd device, bst_idx_t n_samples, bst_target_t n_classes, #endif // defined(XGBOOST_USE_CUDA) } - ExtMemConfig config{ - .cache = prefix, - .on_host = this->on_host_, - .min_cache_page_bytes = this->min_cache_page_bytes_, - .missing = std::numeric_limits::quiet_NaN(), - .n_threads = Context{}.Threads(), + auto config = ExtMemConfig{ + prefix, + this->on_host_, + this->min_cache_page_bytes_, + std::numeric_limits::quiet_NaN(), + Context{}.Threads(), }; std::shared_ptr p_fmat{ DMatrix::Create(static_cast(iter.get()), iter->Proxy(), Reset, Next, config)}; @@ -497,12 +497,12 @@ void MakeLabels(DeviceOrd device, bst_idx_t n_samples, bst_target_t n_classes, } CHECK(iter); - ExtMemConfig config{ - .cache = prefix, - .on_host = this->on_host_, - .min_cache_page_bytes = this->min_cache_page_bytes_, - .missing = std::numeric_limits::quiet_NaN(), - .n_threads = Context{}.Threads(), + auto config = ExtMemConfig{ + prefix, + this->on_host_, + this->min_cache_page_bytes_, + std::numeric_limits::quiet_NaN(), + Context{}.Threads(), }; std::shared_ptr p_fmat{DMatrix::Create(static_cast(iter.get()), iter->Proxy(), nullptr, Reset, Next, this->bins_,