You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@fverdugo I think I found some issues for PermutedLocalIndices. See the MWE:
using PartitionedArrays
ranks =with_debug() do distribute
distribute(LinearIndices((2,)))
end
indices =map(ranks) do r
n_global =4if r ==1
local_to_global = [1,2,3]
local_to_owner = [1,1,2]
else
local_to_global = [2,3,4]
local_to_owner = [1,2,2]
endLocalIndices(n_global,r,local_to_global,local_to_owner)
end
perm =map(ranks) do r
if r ==1
[2,1,3]
else
[1,3,2]
endend
perm_indices =map(permute_indices,indices,perm) # Error 1
v =pfill(0.0,perm_indices) # Error 2
ERROR: MethodError: no method matching PartitionedArrays.LocalToOwner(::PartitionedArrays.OwnToOwner, ::SubArray{Int32, 1, Vector{Int32}, Tuple{Vector{Int32}}, false}, ::Vector{Int32})
Closest candidates are:
PartitionedArrays.LocalToOwner(::PartitionedArrays.OwnToOwner, ::Vector{Int32}, ::C) where C
@ PartitionedArrays ~/.julia/packages/PartitionedArrays/py6uo/src/p_range.jl:972
It seems the LocalToGlobal and LocalToOwner structs are enforcing datatypes which PermutedLocalIndices does not support, when created from a LocalIndices object.
I would also think that this is related to the fact that LocalToGlobal assumes we have our indices ordered as [own...,ghost...] like for OwnAndGhostIndices (which is the only type for which permutation is supported). Indeed, if we solve the issue with something like
functionlocal_to_global(a::PermutedLocalIndices)
LocalToGlobal(own_to_global(a),collect(ghost_to_global(a)),a.perm)
end
we can create the object, but the result is wrong:
2-element DebugArray{PartitionedArrays.LocalToGlobal{SubArray{Int64, 1, Vector{Int64}, Tuple{Vector{Int32}}, false}, Vector{Int32}}, 1}:
[1] = [2, 1, 3]
[2] = [3, 4, 2] # This should be still [2,3,4], but it gets reordered as owned then ghost.
All in all, I think something along these lines should be considered to fix this issue while preserving performance and the current API:
Rename PermutedLocalIndices to PermutedOnwAndGhostIndices.
Create a new struct PermutedLocalIndices that works for an arbitrary LocalIndices structure. Since LocalIndices already contains the local_to_global and local_to_owner arrays, it is significantly simpler to reorder the indices.
Dispatch on permute_indices based on the indices type.
Alternatively, we could avoid a new structure by just dispatching to
functionpermute_indices(indices::LocalIndices,perm)
id =part_id(indices)
n_glob =global_length(indices)
l2g =view(local_to_global(indices),perm)
l2o =view(local_to_owner(indices),perm)
returnLocalIndices(n_glob,id,l2g,l2o)
end
Also, and just as a comment, I think it would be nice to add to the documentation in which direction the permutation is going, i.e from the old local indices to the new or vice-versa. I believe it;s meant to be a map new -> old.
The text was updated successfully, but these errors were encountered:
@fverdugo I think I found some issues for
PermutedLocalIndices
. See the MWE:Trace for error 1:
Trace for error 2:
It seems the
LocalToGlobal
andLocalToOwner
structs are enforcing datatypes whichPermutedLocalIndices
does not support, when created from aLocalIndices
object.I would also think that this is related to the fact that
LocalToGlobal
assumes we have our indices ordered as[own...,ghost...]
like forOwnAndGhostIndices
(which is the only type for which permutation is supported). Indeed, if we solve the issue with something likewe can create the object, but the result is wrong:
All in all, I think something along these lines should be considered to fix this issue while preserving performance and the current API:
PermutedLocalIndices
toPermutedOnwAndGhostIndices
.PermutedLocalIndices
that works for an arbitraryLocalIndices
structure. SinceLocalIndices
already contains thelocal_to_global
andlocal_to_owner
arrays, it is significantly simpler to reorder the indices.permute_indices
based on the indices type.Alternatively, we could avoid a new structure by just dispatching to
Also, and just as a comment, I think it would be nice to add to the documentation in which direction the permutation is going, i.e from the old local indices to the new or vice-versa. I believe it;s meant to be a map
new -> old
.The text was updated successfully, but these errors were encountered: