-
Notifications
You must be signed in to change notification settings - Fork 16
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
Missing feature: find_owner
for LocalIndices
#115
Comments
Hi @JordiManyer, It is not implemented since LocalIndides has not enough information to compute the result without communications. Another option is to keep (optionally) a vector of global to owner ids replicated in all procs. This is not scalable of course, but in some cases the user computes such quantity anyway, e.g., when partitioning a serial graph with metis. |
Related with this, I think a new constructor like this would be handy in some situations:
global_to_color (aka global_to_owner) is the output of metis i.e. a sub-domain color per global cell id. If the user uses this constructor, perhaps it is wise to store global_to_owner somewhere and then we can use it to implement find_owner. |
Hi @fverdugo I understand the issue. However, I think something like this would be useful in cases where all function find_owner(indices,global_ids,::Type{<:LocalIndices})
# WARNING: When the global_ids are neither owned nor ghosts, the function will
# return the owner as 0... Should we fetch unknown owners? This would require communications...
map(indices,global_ids) do partition, gids
lids = global_to_local(partition)[gids]
local_to_owner(partition)[lids]
end
end When the gids are not known, the owner would be set to |
For a bit of context, I am currently updating A = PSparseMatrix(I,J,V,ids,ids,ids=:global) for which I want to use the method |
Yes, I've been doing something similar when building mock distributed models for |
I see the problem. I would suggest to building the sparse matrix via the low level constructor instead of psparse!. It looks that your ids already contain the required ghost values, so it should be possible. I am temped to accept your solution above but I find a bit dangerous to return 0s from this function and then seeing the problem somewhere else where it is perhaps more difficult to figure out what went wrong. My preferred option would be to add a new kw-argument in |
See here: PartitionedArrays.jl/src/p_sparse_matrix.jl Line 481 in 74e04a3
|
This works, but you might end up with sub-optimal communications since you are not selecting exactly the gids you need for the specific matrix entries. This is not an issue for small tests, but it's not ideal in the general case. I still think it's a good idea to implement it, and I'll prepare a PR with these changes.
What about something like this: function find_owner(indices,global_ids,::Type{<:LocalIndices})
msg = "Error: LocalIndices does not have enough local information to find owners."
map(indices,global_ids) do partition, gids
lids = global_to_local(partition)[gids]
owners = local_to_owner(partition)[lids]
@assert all(owners .!= 0) msg
return owners
end
end We could even add a kwarg |
Hi @JordiManyer, psparse! adds extra ghost ids if needed, it does not remove unnecessary ones. Even by modifying find_owner you will not fix the issue of having extra ghosts, unnecessary communication, etc. You provably need a new function "remove_ghosts" if not available already then call psparse! with discover_rows = discover_cols = false rather than changing find_owner. |
@fverdugo Ok, nice to know. Then I guess the PR is ready for review, with the new kwarg changes as agreed. |
even better: we can implement a new function |
That would indeed be nice, specially for FEM-related assemblies. I might have time to implement it at some point, same for |
See PR: #120 |
I believe the method
find_owner
is missing for the structureLocalIndices
.Is this correct, or am I missing something?
The text was updated successfully, but these errors were encountered: