Use view for SparsePage exclusively. (#6590)
This commit is contained in:
@@ -825,19 +825,20 @@ SparsePage SparsePage::GetTranspose(int num_columns) const {
|
||||
const int nthread = omp_get_max_threads();
|
||||
builder.InitBudget(num_columns, nthread);
|
||||
long batch_size = static_cast<long>(this->Size()); // NOLINT(*)
|
||||
#pragma omp parallel for default(none) shared(batch_size, builder) schedule(static)
|
||||
auto page = this->GetView();
|
||||
#pragma omp parallel for default(none) shared(batch_size, builder, page) schedule(static)
|
||||
for (long i = 0; i < batch_size; ++i) { // NOLINT(*)
|
||||
int tid = omp_get_thread_num();
|
||||
auto inst = (*this)[i];
|
||||
auto inst = page[i];
|
||||
for (const auto& entry : inst) {
|
||||
builder.AddBudget(entry.index, tid);
|
||||
}
|
||||
}
|
||||
builder.InitStorage();
|
||||
#pragma omp parallel for default(none) shared(batch_size, builder) schedule(static)
|
||||
#pragma omp parallel for default(none) shared(batch_size, builder, page) schedule(static)
|
||||
for (long i = 0; i < batch_size; ++i) { // NOLINT(*)
|
||||
int tid = omp_get_thread_num();
|
||||
auto inst = (*this)[i];
|
||||
auto inst = page[i];
|
||||
for (const auto& entry : inst) {
|
||||
builder.Push(
|
||||
entry.index,
|
||||
|
||||
@@ -28,13 +28,12 @@ DMatrix* SimpleDMatrix::Slice(common::Span<int32_t const> ridxs) {
|
||||
auto out = new SimpleDMatrix;
|
||||
SparsePage& out_page = out->sparse_page_;
|
||||
for (auto const &page : this->GetBatches<SparsePage>()) {
|
||||
page.data.HostVector();
|
||||
page.offset.HostVector();
|
||||
auto batch = page.GetView();
|
||||
auto& h_data = out_page.data.HostVector();
|
||||
auto& h_offset = out_page.offset.HostVector();
|
||||
size_t rptr{0};
|
||||
for (auto ridx : ridxs) {
|
||||
auto inst = page[ridx];
|
||||
auto inst = batch[ridx];
|
||||
rptr += inst.size();
|
||||
std::copy(inst.begin(), inst.end(), std::back_inserter(h_data));
|
||||
h_offset.emplace_back(rptr);
|
||||
|
||||
Reference in New Issue
Block a user