Data partition
Partitioners
PartitionedArrays.uniform_partition
— Functionuniform_partition(ranks,np,n[,ghost[,periodic]])
Generate an N
dimensional block partition of the indices in LinearIndices(np)
with a (roughly) constant block size. The output is a vector of vectors containing the indices in each component of the partition. The eltype
of the result implements the AbstractLocalIndices
interface.
Arguments
ranks
: Array containing the distribution of ranks.np::NTuple{N}
: Number of parts per direction.n::NTuple{N}
: Number of global indices per direction.ghost::NTuple{N}=ntuple(i->false,N)
: Number of ghost indices per direction.periodic::NTuple{N}=ntuple(i->false,N)
: Use or not periodic boundaries per direction.
For convenience, one can also provide scalar inputs instead tuples to create 1D block partitions. In this case, the argument np
can be omitted and it will be computed as np=length(ranks)
. At the moment, it's only possible to use this syntax for zero (with ghost=false
) or one (with ghost=true
) layer(s) of ghost indices. If you wish to have more ghost indices, use tuples instead.
Examples
2D partition of 4x4 indices into 2x2 parts without ghost
julia> using PartitionedArrays
julia> rank = LinearIndices((4,));
julia> uniform_partition(rank,10)
4-element Vector{PartitionedArrays.LocalIndicesWithConstantBlockSize{1}}:
[1, 2]
[3, 4]
[5, 6, 7]
[8, 9, 10]
julia> uniform_partition(rank,(2,2),(4,4))
4-element Vector{PartitionedArrays.LocalIndicesWithConstantBlockSize{2}}:
[1, 2, 5, 6]
[3, 4, 7, 8]
[9, 10, 13, 14]
[11, 12, 15, 16]
PartitionedArrays.variable_partition
— Functionvariable_partition(n_own,n_global[;start])
Build a 1D variable-size block partition of the range 1:n
. The output is a vector of vectors containing the indices in each component of the partition. The eltype
of the result implements the AbstractLocalIndices
interface.
Arguments
n_own::AbstractArray{<:Integer}
: Array containing the block size for each part.n_global::Integer
: Number of global indices. It should be equal tosum(n_own)
.start::AbstractArray{Int}=scan(+,n_own,type=:exclusive,init=1)
: First global index in each part.
We ask the user to provide n_global
and (optionally) start
since discovering them requires communications.
Examples
julia> using PartitionedArrays
julia> rank = LinearIndices((4,));
julia> n_own = [3,2,2,3];
julia> variable_partition(n_own,sum(n_own))
4-element Vector{PartitionedArrays.LocalIndicesWithVariableBlockSize{1}}:
[1, 2, 3]
[4, 5]
[6, 7]
[8, 9, 10]
PartitionedArrays.trivial_partition
— Functiontrivial_partition(ranks,n;destination=MAIN)
Document me!
PartitionedArrays.partition_from_color
— Functionpartition_from_color(ranks,global_to_color;multicast=false,source=MAIN)
Build an arbitrary 1d partition by defining the parts via the argument global_to_color
(see below). The output is a vector of vectors containing the indices in each component of the partition. The eltype
of the result implements the AbstractLocalIndices
interface.
Arguments
ranks
: Array containing the distribution of ranks.global_to_color
: Ifmulticast==false
,global_to_color[gid]
contains the part id that owns the global idgid
. Ifmulticast==true
, thenglobal_to_color[source][gid]
contains the part id that owns the global idgid
.
Key-word arguments
multicast=false
source=MAIN
This function is useful when generating a partition using a graph partitioner such as METIS. The argument global_to_color
is the usual output of such tools.
AbstractLocalIndices
PartitionedArrays.AbstractLocalIndices
— Typeabstract type AbstractLocalIndices
Abstract type representing the local, own, and ghost indices in a part of a partition of a range 1:n
with length n
.
Notation
Let 1:n
be an integer range with length n
. We denote the indices in 1:n
as the global indices. Let us consider a partition of 1:n
. The indices in a part in the partition are called the own indices of this part. I.e., each part owns a subset of 1:n
. All these subsets are disjoint. Let us assume that each part is equipped with a second set of indices called the ghost indices. The set of ghost indices in a given part is an arbitrary subset of the global indices 1:n
that are owned by other parts. The union of the own and ghost indices is referred to as the local indices of this part. The sets of local indices might overlap between the different parts.
The sets of own, ghost, and local indices are stored using vector-like containers in concrete implementations of AbstractLocalIndices
. This equips them with a certain order. The i
-th own index in a part is defined as the one being stored at index i
in the array that contains the own indices in this part (idem for ghost and local indices). The map between indices in these ordered index sets are given by functions such as local_to_global
, own_to_local
etc.
Supertype hierarchy
AbstractLocalIndices <: AbstractVector{Int}
PartitionedArrays.local_to_global
— Functionlocal_to_global(indices)
Return an array with the global indices of the local indices in indices
.
PartitionedArrays.own_to_global
— Functionown_to_global(indices)
Return an array with the global indices of the own indices in indices
.
PartitionedArrays.ghost_to_global
— Functionghost_to_global(indices)
Return an array with the global indices of the ghost indices in indices
.
PartitionedArrays.local_to_owner
— Functionlocal_to_owner(indices)
Return an array with the owners of the local indices in indices
.
PartitionedArrays.own_to_owner
— Functionown_to_owner(indices)
Return an array with the owners of the own indices in indices
.
PartitionedArrays.ghost_to_owner
— Functionghost_to_owner(indices)
Return an array with the owners of the ghost indices in indices
.
PartitionedArrays.global_to_local
— Functionglobal_to_local(indices)
Return an array with the inverse index map of local_to_global(indices)
.
PartitionedArrays.global_to_own
— Functionglobal_to_own(indices)
Return an array with the inverse index map of own_to_global(indices)
.
PartitionedArrays.global_to_ghost
— Functionglobal_to_ghost(indices)
Return an array with the inverse index map of ghost_to_global(indices)
.
PartitionedArrays.own_to_local
— Functionown_to_local(indices)
Return an array with the local ids of the own indices in indices
.
PartitionedArrays.ghost_to_local
— Functionghost_to_local(indices)
Return an array with the local ids of the ghost indices in indices
.
PartitionedArrays.local_to_own
— Functionlocal_to_own(indices)
Return an array with the inverse index map of own_to_local(indices)
.
PartitionedArrays.local_to_ghost
— Functionlocal_to_ghost(indices)
Return an array with the inverse index map of ghost_to_local(indices)
.
PartitionedArrays.local_length
— Functionlocal_length(indices)
Get number of local ids in indices
.
PartitionedArrays.own_length
— Functionown_length(indices)
Get number of own ids in indices
.
PartitionedArrays.ghost_length
— Functionghost_length(indices)
Get number of ghost ids in indices
.
PartitionedArrays.global_length
— Functionglobal_length(indices)
Get number of global ids associated with indices
.
PartitionedArrays.part_id
— Functionpart_id(indices)
Return the id of the part that is storing indices
.
PRange
PartitionedArrays.PRange
— Typestruct PRange{A}
PRange
(partitioned range) is a type representing a range of indices 1:n
partitioned into several parts. This type is used to represent the axes of instances of PVector
and PSparseMatrix
.
Properties
partition::A
The item partition[i]
is an object that contains information about the own, ghost, and local indices of part number i
. typeof(partition[i])
is a type that implements the methods of the AbstractLocalIndices
interface. Use this interface to access the underlying information about own, ghost, and local indices.
Supertype hierarchy
PRange{A} <: AbstractUnitRange{Int}
PartitionedArrays.partition
— Methodpartition(a::PRange)
Get a.partition
.