133 if (data_.symbolic_ != NULL) {
134 ::KLU2::klu_free_symbolic<klu2_dtype, local_ordinal_type>
135 (&(data_.symbolic_), &(data_.common_)) ;
138 if ( single_proc_optimization() ) {
139 host_ordinal_type_array host_row_ptr_view;
140 host_ordinal_type_array host_cols_view;
141 this->matrixA_->returnRowPtr_kokkos_view(host_row_ptr_view);
142 this->matrixA_->returnColInd_kokkos_view(host_cols_view);
143 data_.symbolic_ = ::KLU2::klu_analyze<klu2_dtype, local_ordinal_type>
144 ((local_ordinal_type)this->globalNumCols_, host_row_ptr_view.data(),
145 host_cols_view.data(), &(data_.common_)) ;
149 data_.symbolic_ = ::KLU2::klu_analyze<klu2_dtype, local_ordinal_type>
150 ((local_ordinal_type)this->globalNumCols_, host_col_ptr_view_.data(),
151 host_rows_view_.data(), &(data_.common_)) ;
173#ifdef HAVE_AMESOS2_TIMERS
174 Teuchos::TimeMonitor numFactTimer(this->timers_.numFactTime_);
177 if (data_.numeric_ != NULL) {
178 ::KLU2::klu_free_numeric<klu2_dtype, local_ordinal_type>
179 (&(data_.numeric_), &(data_.common_));
182 if ( single_proc_optimization() ) {
183 host_ordinal_type_array host_row_ptr_view;
184 host_ordinal_type_array host_cols_view;
185 this->matrixA_->returnRowPtr_kokkos_view(host_row_ptr_view);
186 this->matrixA_->returnColInd_kokkos_view(host_cols_view);
187 this->matrixA_->returnValues_kokkos_view(host_nzvals_view_);
188 klu2_dtype * pValues = function_map::convert_scalar(host_nzvals_view_.data());
189 data_.numeric_ = ::KLU2::klu_factor<klu2_dtype, local_ordinal_type>
190 (host_row_ptr_view.data(), host_cols_view.data(), pValues,
191 data_.symbolic_, &(data_.common_));
194 klu2_dtype * pValues = function_map::convert_scalar(host_nzvals_view_.data());
195 data_.numeric_ = ::KLU2::klu_factor<klu2_dtype, local_ordinal_type>
196 (host_col_ptr_view_.data(), host_rows_view_.data(), pValues,
197 data_.symbolic_, &(data_.common_));
205 if(data_.numeric_ ==
nullptr) {
212 this->setNnzLU( as<size_t>((data_.numeric_)->lnz) + as<size_t>((data_.numeric_)->unz) );
219 Teuchos::broadcast(*(this->matrixA_->getComm()), 0, &info);
221 TEUCHOS_TEST_FOR_EXCEPTION(info > 0, std::runtime_error,
222 "KLU2 numeric factorization failed");
230 const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
231 const Teuchos::Ptr<
const MultiVecAdapter<Vector> > B)
const
236 const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
237 const size_t nrhs = X->getGlobalNumVectors();
242#ifdef HAVE_AMESOS2_TIMERS
243 Teuchos::TimeMonitor mvConvTimer(this->timers_.vecConvTime_);
244 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
246 const bool initialize_data =
true;
247 const bool do_not_initialize_data =
false;
248 if ( single_proc_optimization() && nrhs == 1 ) {
250 bDidAssignB = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
251 host_solve_array_t>::do_get(initialize_data, B, bValues_, as<size_t>(ld_rhs));
253 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
254 host_solve_array_t>::do_get(do_not_initialize_data, X, xValues_, as<size_t>(ld_rhs));
257 if ( is_contiguous_ ==
true ) {
258 bDidAssignB = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
259 host_solve_array_t>::do_get(initialize_data, B, bValues_,
261 ROOTED, this->rowIndexBase_);
264 bDidAssignB = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
265 host_solve_array_t>::do_get(initialize_data, B, bValues_,
271 if ( is_contiguous_ ==
true ) {
272 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
273 host_solve_array_t>::do_get(do_not_initialize_data, X, xValues_,
275 ROOTED, this->rowIndexBase_);
278 bDidAssignX = Util::get_1d_copy_helper_kokkos_view<MultiVecAdapter<Vector>,
279 host_solve_array_t>::do_get(do_not_initialize_data, X, xValues_,
291 Kokkos::deep_copy(xValues_, bValues_);
299 klu2_dtype * pxValues = function_map::convert_scalar(xValues_.data());
300 klu2_dtype * pbValues = function_map::convert_scalar(bValues_.data());
304 TEUCHOS_TEST_FOR_EXCEPTION(pbValues ==
nullptr,
305 std::runtime_error,
"Amesos2 Runtime Error: b_vector returned null ");
307 TEUCHOS_TEST_FOR_EXCEPTION(pxValues ==
nullptr,
308 std::runtime_error,
"Amesos2 Runtime Error: x_vector returned null ");
311 if ( single_proc_optimization() && nrhs == 1 ) {
312#ifdef HAVE_AMESOS2_TIMERS
313 Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
321 ::KLU2::klu_tsolve2<klu2_dtype, local_ordinal_type>
322 (data_.symbolic_, data_.numeric_,
323 (local_ordinal_type)this->globalNumCols_,
324 (local_ordinal_type)nrhs,
325 pbValues, pxValues, &(data_.common_)) ;
328 ::KLU2::klu_solve2<klu2_dtype, local_ordinal_type>
329 (data_.symbolic_, data_.numeric_,
330 (local_ordinal_type)this->globalNumCols_,
331 (local_ordinal_type)nrhs,
332 pbValues, pxValues, &(data_.common_)) ;
343#ifdef HAVE_AMESOS2_TIMERS
344 Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
351 if ( single_proc_optimization() ) {
352 ::KLU2::klu_tsolve<klu2_dtype, local_ordinal_type>
353 (data_.symbolic_, data_.numeric_,
354 (local_ordinal_type)this->globalNumCols_,
355 (local_ordinal_type)nrhs,
356 pxValues, &(data_.common_)) ;
359 ::KLU2::klu_solve<klu2_dtype, local_ordinal_type>
360 (data_.symbolic_, data_.numeric_,
361 (local_ordinal_type)this->globalNumCols_,
362 (local_ordinal_type)nrhs,
363 pxValues, &(data_.common_)) ;
371 if ( single_proc_optimization() ) {
372 ::KLU2::klu_solve<klu2_dtype, local_ordinal_type>
373 (data_.symbolic_, data_.numeric_,
374 (local_ordinal_type)this->globalNumCols_,
375 (local_ordinal_type)nrhs,
376 pxValues, &(data_.common_)) ;
379 ::KLU2::klu_tsolve<klu2_dtype, local_ordinal_type>
380 (data_.symbolic_, data_.numeric_,
381 (local_ordinal_type)this->globalNumCols_,
382 (local_ordinal_type)nrhs,
383 pxValues, &(data_.common_)) ;
392#ifdef HAVE_AMESOS2_TIMERS
393 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
396 if ( is_contiguous_ ==
true ) {
397 Util::put_1d_data_helper_kokkos_view<
398 MultiVecAdapter<Vector>,host_solve_array_t>::do_put(X, xValues_,
400 ROOTED, this->rowIndexBase_);
403 Util::put_1d_data_helper_kokkos_view<
404 MultiVecAdapter<Vector>,host_solve_array_t>::do_put(X, xValues_,
489 if(current_phase == SOLVE)
return(
false);
491 if ( single_proc_optimization() ) {
497#ifdef HAVE_AMESOS2_TIMERS
498 Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
503 host_nzvals_view_ = host_value_type_array(
504 Kokkos::ViewAllocateWithoutInitializing(
"host_nzvals_view_"), this->globalNumNonZeros_);
505 host_rows_view_ = host_ordinal_type_array(
506 Kokkos::ViewAllocateWithoutInitializing(
"host_rows_view_"), this->globalNumNonZeros_);
507 host_col_ptr_view_ = host_ordinal_type_array(
508 Kokkos::ViewAllocateWithoutInitializing(
"host_col_ptr_view_"), this->globalNumRows_ + 1);
511 local_ordinal_type nnz_ret = 0;
513#ifdef HAVE_AMESOS2_TIMERS
514 Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
517 if ( is_contiguous_ ==
true ) {
519 MatrixAdapter<Matrix>,host_value_type_array,host_ordinal_type_array,host_ordinal_type_array>
520 ::do_get(this->matrixA_.ptr(), host_nzvals_view_, host_rows_view_, host_col_ptr_view_,
525 MatrixAdapter<Matrix>,host_value_type_array,host_ordinal_type_array,host_ordinal_type_array>
526 ::do_get(this->matrixA_.ptr(), host_nzvals_view_, host_rows_view_, host_col_ptr_view_,
532 TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->globalNumNonZeros_),
534 "Did not get the expected number of non-zero vals");