100 if (data_.symbolic_ != NULL) {
101 ::KLU2::klu_free_symbolic<klu2_dtype, local_ordinal_type>
102 (&(data_.symbolic_), &(data_.common_)) ;
106 host_ordinal_type_array host_row_ptr_view;
107 host_ordinal_type_array host_cols_view;
108 this->
matrixA_->returnRowPtr_kokkos_view(host_row_ptr_view);
109 this->
matrixA_->returnColInd_kokkos_view(host_cols_view);
110 data_.symbolic_ = ::KLU2::klu_analyze<klu2_dtype, local_ordinal_type>
111 ((local_ordinal_type)this->
globalNumCols_, host_row_ptr_view.data(),
112 host_cols_view.data(), &(data_.common_)) ;
116 data_.symbolic_ = ::KLU2::klu_analyze<klu2_dtype, local_ordinal_type>
140#ifdef HAVE_AMESOS2_TIMERS
141 Teuchos::TimeMonitor numFactTimer(this->
timers_.numFactTime_);
144 if (data_.numeric_ != NULL) {
145 ::KLU2::klu_free_numeric<klu2_dtype, local_ordinal_type>
146 (&(data_.numeric_), &(data_.common_));
150 host_ordinal_type_array host_row_ptr_view;
151 host_ordinal_type_array host_cols_view;
152 this->
matrixA_->returnRowPtr_kokkos_view(host_row_ptr_view);
153 this->
matrixA_->returnColInd_kokkos_view(host_cols_view);
156 data_.numeric_ = ::KLU2::klu_factor<klu2_dtype, local_ordinal_type>
157 (host_row_ptr_view.data(), host_cols_view.data(), pValues,
158 data_.symbolic_, &(data_.common_));
162 data_.numeric_ = ::KLU2::klu_factor<klu2_dtype, local_ordinal_type>
164 data_.symbolic_, &(data_.common_));
172 if(data_.numeric_ ==
nullptr) {
179 this->
setNnzLU( as<size_t>((data_.numeric_)->lnz) + as<size_t>((data_.numeric_)->unz) );
186 Teuchos::broadcast(*(this->
matrixA_->getComm()), 0, &info);
188 TEUCHOS_TEST_FOR_EXCEPTION(info > 0, std::runtime_error,
189 "KLU2 numeric factorization failed(info="+std::to_string(info)+
")");
203 const global_size_type ld_rhs = this->
root_ ? X->getGlobalLength() : 0;
204 const size_t nrhs = X->getGlobalNumVectors();
208 bool use_gather = use_gather_;
209 use_gather = (use_gather && this->
matrixA_->getComm()->getSize() > 1);
210 use_gather = (use_gather && (std::is_same<scalar_type, float>::value || std::is_same<scalar_type, double>::value));
212#ifdef HAVE_AMESOS2_TIMERS
213 Teuchos::TimeMonitor mvConvTimer(this->
timers_.vecConvTime_);
215 const bool initialize_data =
true;
216 const bool do_not_initialize_data =
false;
219 bDidAssignB = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
220 host_solve_array_t>::do_get(initialize_data, B,
bValues_, as<size_t>(ld_rhs));
222 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
223 host_solve_array_t>::do_get(do_not_initialize_data, X,
xValues_, as<size_t>(ld_rhs));
227 int rval = B->gather(
bValues_, this->perm_g2l, this->recvCountRows, this->recvDisplRows,
230 X->gather(
xValues_, this->perm_g2l, this->recvCountRows, this->recvDisplRows,
239 bDidAssignB = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
240 host_solve_array_t>::do_get(initialize_data, B,
bValues_,
245 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
246 host_solve_array_t>::do_get(do_not_initialize_data, X,
xValues_,
267 klu2_dtype * pxValues = function_map::convert_scalar(
xValues_.data());
268 klu2_dtype * pbValues = function_map::convert_scalar(
bValues_.data());
272 TEUCHOS_TEST_FOR_EXCEPTION(pbValues ==
nullptr,
273 std::runtime_error,
"Amesos2 Runtime Error: b_vector returned null ");
275 TEUCHOS_TEST_FOR_EXCEPTION(pxValues ==
nullptr,
276 std::runtime_error,
"Amesos2 Runtime Error: x_vector returned null ");
280#ifdef HAVE_AMESOS2_TIMERS
281 Teuchos::TimeMonitor solveTimer(this->
timers_.solveTime_);
289 ::KLU2::klu_tsolve2<klu2_dtype, local_ordinal_type>
290 (data_.symbolic_, data_.numeric_,
291 (local_ordinal_type)this->globalNumCols_,
292 (local_ordinal_type)nrhs,
293 pbValues, pxValues, &(data_.common_)) ;
296 ::KLU2::klu_solve2<klu2_dtype, local_ordinal_type>
297 (data_.symbolic_, data_.numeric_,
298 (local_ordinal_type)this->globalNumCols_,
299 (local_ordinal_type)nrhs,
300 pbValues, pxValues, &(data_.common_)) ;
311#ifdef HAVE_AMESOS2_TIMERS
312 Teuchos::TimeMonitor solveTimer(this->
timers_.solveTime_);
320 ::KLU2::klu_tsolve<klu2_dtype, local_ordinal_type>
321 (data_.symbolic_, data_.numeric_,
322 (local_ordinal_type)this->globalNumCols_,
323 (local_ordinal_type)nrhs,
324 pxValues, &(data_.common_)) ;
327 ::KLU2::klu_solve<klu2_dtype, local_ordinal_type>
328 (data_.symbolic_, data_.numeric_,
329 (local_ordinal_type)this->globalNumCols_,
330 (local_ordinal_type)nrhs,
331 pxValues, &(data_.common_)) ;
340 ::KLU2::klu_solve<klu2_dtype, local_ordinal_type>
341 (data_.symbolic_, data_.numeric_,
342 (local_ordinal_type)this->globalNumCols_,
343 (local_ordinal_type)nrhs,
344 pxValues, &(data_.common_)) ;
347 ::KLU2::klu_tsolve<klu2_dtype, local_ordinal_type>
348 (data_.symbolic_, data_.numeric_,
349 (local_ordinal_type)this->globalNumCols_,
350 (local_ordinal_type)nrhs,
351 pxValues, &(data_.common_)) ;
360#ifdef HAVE_AMESOS2_TIMERS
361 Teuchos::TimeMonitor redistTimer( this->
timers_.vecRedistTime_ );
364 int rval = X->scatter(
xValues_, this->perm_g2l, this->recvCountRows, this->recvDisplRows,
366 if (rval != 0) use_gather =
false;
369 Util::put_1d_data_helper_kokkos_view<
458#ifdef HAVE_AMESOS2_TIMERS
459 Teuchos::TimeMonitor convTimer(this->
timers_.mtxConvTime_);
462 if(current_phase == SOLVE)
return(
false);
478 local_ordinal_type nnz_ret = -1;
479 bool use_gather = use_gather_;
480 use_gather = (use_gather && this->
matrixA_->getComm()->getSize() > 1);
481 use_gather = (use_gather && (std::is_same<scalar_type, float>::value || std::is_same<scalar_type, double>::value));
483#ifdef HAVE_AMESOS2_TIMERS
484 Teuchos::TimeMonitor mtxRedistTimer( this->
timers_.mtxRedistTime_ );
487 bool column_major =
true;
488 if (!is_contiguous_) {
489 auto contig_mat = this->
matrixA_->reindex(this->contig_rowmap_, this->contig_colmap_, current_phase);
491 this->transpose_map, this->nzvals_t, column_major, current_phase);
494 this->transpose_map, this->nzvals_t, column_major, current_phase);
498 if (nnz_ret < 0) use_gather =
false;
506 this->rowIndexBase_);
511 if (use_gather || this->
root_) {
512 TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->
globalNumNonZeros_),
514 "Amesos2_KLU2 loadA_impl: Did not get the expected number of non-zero vals("