void ceefit_call_spec FIXTURE::DoRows(PTR<PARSE>& rows) { PTR<PARSE> temp(rows); while (temp != null) { PTR<PARSE> more(temp->More); DoRow(temp); temp = more; } }
CsxMatrix<IndexType, ValueType> * CsxManager<IndexType, ValueType>:: MakeCsx(bool symmetric) { CsxMatrix<IndexType, ValueType> *csx; #if SPX_USE_NUMA NumaAllocator &numa_alloc = NumaAllocator::GetInstance(); int cpu = sched_getcpu(); if (cpu < 0) { LOG_ERROR << "sched_getcpu() failed " << strerror(errno); exit(1); } int node = numa_node_of_cpu(cpu); if (node < 0) { LOG_ERROR << "numa_node_of_cpu() failed " << strerror(errno); exit(1); } csx = new (numa_alloc, node) CsxMatrix<IndexType, ValueType>; values_ = new (numa_alloc, node) ValueType[spm_->GetNrNonzeros()]; rows_info_ = new (numa_alloc, node) row_info_t[spm_->GetNrRows()]; #else csx = new CsxMatrix<IndexType, ValueType>; values_ = new ValueType[spm_->GetNrNonzeros()]; rows_info_ = new row_info_t[spm_->GetNrRows()]; #endif // SPX_USE_NUMA // Be greedy with the initial capacity (equal to CSR col_ind size) // to avoid realloc()'s. csx->nnz = spm_->GetNrNonzeros(); csx->nrows = spm_->GetNrRows(); csx->ncols = spm_->GetNrCols(); csx->row_start = spm_->GetRowStart(); values_idx_ = 0; new_row_ = false; // Do not mark first row. if (!symmetric) { curr_row_ = 0; for (size_t i = 0; i < spm_->GetRowptrSize() - 1; ++i, ++curr_row_) { typename SparsePartition<IndexType, ValueType>::iterator rbegin = spm_->begin(i); typename SparsePartition<IndexType, ValueType>::iterator rend = spm_->end(i); // LOG_DEBUG << "MakeCsx(): row: " << i << "\n"; if (rbegin == rend) { // Check if row is empty. // LOG_DEBUG << "MakeCsx(): row is empty\n"; if (new_row_ == false) { rows_info_[i].rowptr = 0; new_row_ = true; // In case the first row is empty. } else { empty_rows_++; rows_info_[i].rowptr = rows_info_[i-1].rowptr; } rows_info_[i].valptr = 0; rows_info_[i].span = 0; continue; } if (i > 0) rows_info_[i].rowptr = ctl_bld_.GetCtlSize(); else rows_info_[i].rowptr = 0; rows_info_[i].valptr = values_idx_; DoRow(rbegin, rend, i); rows_info_[i].span = span_; new_row_ = true; } for (size_t i = spm_->GetRowptrSize() - 1; i < (size_t) spm_->GetNrRows(); i++) { rows_info_[i].valptr = 0; rows_info_[i].rowptr = rows_info_[i-1].rowptr; rows_info_[i].span = 0; } } else { for (size_t i = 0; i < spm_->GetRowptrSize() - 1; i++) { typename SparsePartition<IndexType, ValueType>::iterator rbegin = spm_->begin(i); typename SparsePartition<IndexType, ValueType>::iterator rend = spm_->end(i); // LOG_DEBUG << "MakeCsx(): row: " << i << "\n"; if (rbegin == rend){ // Check if row is empty. // LOG_DEBUG << "MakeCsx(): row is empty\n"; if (new_row_ == false) { rows_info_[i].rowptr = 0; new_row_ = true; // In case the first row is empty. } else { rows_info_[i].rowptr = rows_info_[i-1].rowptr; empty_rows_++; } rows_info_[i].valptr = 0; rows_info_[i].span = 0; continue; } if (i > 0) rows_info_[i].rowptr = ctl_bld_.GetCtlSize(); else rows_info_[i].rowptr = 0; rows_info_[i].valptr = values_idx_; DoSymRow(rbegin, rend); rows_info_[i].span = span_; new_row_ = true; } for (size_t i = spm_->GetRowptrSize() - 1; i < (size_t) spm_->GetNrRows(); i++) { rows_info_[i].valptr = 0; rows_info_[i].rowptr = rows_info_[i-1].rowptr; rows_info_[i].span = 0; } } #if SPX_DEBUG // LOG_DEBUG << "values_\n"; // for (size_t i = 0; i < spm_->GetNrNonzeros(); ++i) // LOG_DEBUG << values_[i] << "\n"; #endif csx->row_jumps = row_jmps_; csx->ctl_size = ctl_bld_.GetCtlSize(); csx->ctl = ctl_bld_.Finalize(); assert(values_idx_ == spm_->GetNrNonzeros()); csx->values = values_; values_ = NULL; values_idx_ = 0; csx->rows_info = rows_info_; rows_info_ = NULL; AddMappings(csx->id_map); return csx; }