Skip to content

Commit

Permalink
[precond] move csol to a VectorCache
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikvn committed Jan 31, 2025
1 parent af4b75e commit e988e0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions core/distributed/preconditioner/schwarz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,19 @@ void Schwarz<ValueType, LocalIndexType, GlobalIndexType>::apply_dense_impl(
->get_prolong_op();
GKO_ASSERT(this->half_ != nullptr);

restrict->apply(dense_b, this->csol_);
this->coarse_solver_->apply(this->csol_, this->csol_);
prolong->apply(this->half_, this->csol_, this->half_, dense_x);
// Coarse solve vector cache init
// Should allocare only in the first apply call.
auto cs_ncols = dense_x->get_size()[1];
auto cs_local_nrows = coarse->get_local_matrix()->get_size()[0];
auto cs_global_nrows = coarse->get_size()[0];
auto cs_local_size = dim<2>(cs_local_nrows, cs_ncols);
auto cs_global_size = dim<2>(cs_global_nrows, cs_ncols);
auto comm = coarse->get_communicator();
csol_cache_.init(exec, comm, cs_global_size, cs_local_size);

restrict->apply(dense_b, csol_cache_);
this->coarse_solver_->apply(csol_cache_, csol_cache_);
prolong->apply(this->half_, csol_cache_, this->half_, dense_x);
}
}

Expand Down Expand Up @@ -181,16 +191,6 @@ void Schwarz<ValueType, LocalIndexType, GlobalIndexType>::generate(
auto comm = coarse->get_communicator();
this->coarse_solver_ =
share(parameters_.coarse_solver->generate(coarse));
// TODO: Set correct rhs and stride.
auto cs_ncols = 1; // dense_x->get_size()[1];
auto cs_local_nrows = coarse->get_local_matrix()->get_size()[0];
auto cs_global_nrows = coarse->get_size()[0];
auto cs_local_size = dim<2>(cs_local_nrows, cs_ncols);
auto cs_global_size = dim<2>(cs_global_nrows, cs_ncols);
this->csol_ = gko::share(
dist_vec::create(exec, comm, cs_global_size, cs_local_size,
1 /*dense_x->get_stride()*/));
// this->temp_ = this->csol->clone();
this->half_ = gko::share(gko::initialize<Vector>({0.5}, exec));
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/ginkgo/core/distributed/preconditioner/schwarz.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

Expand Down Expand Up @@ -179,10 +179,10 @@ class Schwarz
std::shared_ptr<const LinOp> local_solver_;

detail::VectorCache<ValueType> cache_;
detail::VectorCache<ValueType> csol_cache_;

std::shared_ptr<const LinOp> galerkin_ops_;
std::shared_ptr<const LinOp> coarse_solver_;
std::shared_ptr<LinOp> csol_;
std::shared_ptr<const LinOp> half_;
};

Expand Down

0 comments on commit e988e0e

Please sign in to comment.