-
Notifications
You must be signed in to change notification settings - Fork 99
Add Distributed VectorCache and use it for intermediate vector in and adapt apply_uses_initial_guess
in Schwarz
#1688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
template <typename ValueType, typename LocalIndexType, typename GlobalIndexType> | ||
template <typename VectorType> | ||
void Schwarz<ValueType, LocalIndexType, GlobalIndexType>::set_cache_to( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You only need this function once, right? Then I would prefer to just add this directly, it's not that much IMO.
* (could also be done with writing `operator=` and copy | ||
* constructor of the enclosing class by hand) | ||
*/ | ||
mutable struct cache_struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a DenseCache
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does not support distributed::Vector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right. Perhaps it would make sense to add VectorCache
, instead of using the cache construct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the Marcel that it can be a DenseCache
instead of cache_struct
. But otherwise looks good to me. I approve it as Marcel has already requested that change.
8948a5d
to
4ed9711
Compare
include/ginkgo/core/matrix/dense.hpp
Outdated
friend class SparsityCsr<ValueType, int64>; | ||
friend class Dense<to_complex<ValueType>>; | ||
friend class experimental::distributed::Vector<ValueType>; | ||
friend class gko::detail::VectorCache<ValueType>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because distributed::Vector
holds the Dense
object not Dense
pointer, I need the constructor to construct the object directly and then use the move_to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I might use the unique_ptr.release
from create function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it's fine, I just got confused. I thought this was in the distributed::Matrix
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! LGTM!
// handle locally to eliminate the mpi call | ||
std::cout << "local diff" << comm.rank() << std::endl; | ||
vec->local_ = | ||
std::move(gko::matrix::Dense<ValueType>(exec, local_size)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use the create function instead ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We hold the object not the pointer.
However, I can create the unique pointer and release the object out actually, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think it is neccessary to do unique_ptr through the create function?
I slightly prefer the constructor to avoid calling release from unique_ptr, but it requires the friend declration in dense such that VectorCache can use Dense constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, It is a only a nit from my side. Using the constructor should also be okay.
} else if (vec->get_local_vector()->get_size() != | ||
template_vec->get_local_vector()->get_size()) { | ||
// handle locally to eliminate the mpi call | ||
vec->local_ = std::move(gko::matrix::Dense<ValueType>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use the create function instead ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some fixes needed
#if GINKGO_BUILD_MPI | ||
|
||
|
||
namespace gko { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might make sense to put this into the experimental
and distributed
namespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I move it into gko::experimental::distributed::detail
4ed9711
to
030bc70
Compare
fc33d21
to
f8b9f57
Compare
Co-authored-by: Pratik Nayak <pratikvn@protonmail.com>
f8b9f57
to
8be4221
Compare
apply_uses_initial_guess
in Schwarz apply_uses_initial_guess
in Schwarz
|
…intermediate vector in and adapt `apply_uses_initial_guess` in Schwarz This PR adds distributed VectorCache and uses it as the workspace in Schwarz to avoid alloc/free memory operation. Related PR: ginkgo-project#1688
This adds a cache/workspace for the intermediate vector in advanced_apply of Schwarz.
Also, it makes apply_uses_initial_guess rely on the
local_solver->apply_uses_initial_guess()
.We might need to revisit this function after adding refining step in Schwarz.