Skip to content

Commit

Permalink
fall back to ILU/IC sparselib algorithm with CPU executors
Browse files Browse the repository at this point in the history
This issue was found when running the custom multigrid example with OpenMP
  • Loading branch information
upsj committed Feb 16, 2025
1 parent eca15d0 commit 2bbe81b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions core/factorization/ic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ std::unique_ptr<Composition<ValueType>> Ic<ValueType, IndexType>::generate(

std::shared_ptr<const matrix_type> ic;
// Compute LC factorization
if (parameters_.algorithm == incomplete_algorithm::syncfree) {
if (parameters_.algorithm == incomplete_algorithm::syncfree ||
exec == exec->get_master()) {
std::unique_ptr<gko::factorization::elimination_forest<IndexType>>
forest;
const auto nnz = local_system_matrix->get_num_stored_elements();
Expand Down Expand Up @@ -143,11 +144,6 @@ std::unique_ptr<Composition<ValueType>> Ic<ValueType, IndexType>::generate(
diag_idxs.get_const_data(), transpose_idxs.get_const_data(),
*forest, factors.get(), false, tmp));
ic = factors;
} else if (std::dynamic_pointer_cast<const OmpExecutor>(exec) &&
!std::dynamic_pointer_cast<const ReferenceExecutor>(exec)) {
GKO_INVALID_STATE(
"OmpExecutor does not support sparselib algorithm. Please use "
"syncfree algorithm.");
} else {
exec->run(
ic_factorization::make_sparselib_ic(local_system_matrix.get()));
Expand Down
8 changes: 2 additions & 6 deletions core/factorization/ilu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ std::unique_ptr<Composition<ValueType>> Ilu<ValueType, IndexType>::generate_l_u(

std::shared_ptr<const matrix_type> ilu;
// Compute LU factorization
if (parameters_.algorithm == incomplete_algorithm::syncfree) {
if (parameters_.algorithm == incomplete_algorithm::syncfree ||
exec == exec->get_master()) {
const auto nnz = local_system_matrix->get_num_stored_elements();
const auto num_rows = local_system_matrix->get_size()[0];
auto factors = share(
Expand All @@ -126,11 +127,6 @@ std::unique_ptr<Composition<ValueType>> Ilu<ValueType, IndexType>::generate_l_u(
lookup.row_descs.get_const_data(), lookup.storage.get_const_data(),
diag_idxs.get_const_data(), factors.get(), false, tmp));
ilu = factors;
} else if (std::dynamic_pointer_cast<const OmpExecutor>(exec) &&
!std::dynamic_pointer_cast<const ReferenceExecutor>(exec)) {
GKO_INVALID_STATE(
"OmpExecutor does not support sparselib algorithm. Please use "
"syncfree algorithm.");
} else {
exec->run(
ilu_factorization::make_sparselib_ilu(local_system_matrix.get()));
Expand Down

0 comments on commit 2bbe81b

Please sign in to comment.