Data partition

Partitioners

PartitionedArrays.uniform_partitionFunction
uniform_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): Use or not 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).

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]
source
PartitionedArrays.variable_partitionFunction
variable_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 to sum(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]
source
PartitionedArrays.partition_from_colorFunction
partition_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: If multicast==false, global_to_color[gid] contains the part id that owns the global id gid. If multicast==true, then global_to_color[source][gid] contains the part id that owns the global id gid.

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.

source

AbstractLocalIndices

PartitionedArrays.AbstractLocalIndicesType
abstract 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}
source

PRange

PartitionedArrays.PRangeType
struct 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}
source