PVector

Type signature

PartitionedArrays.PVectorType
struct PVector{V,A,B,...}

PVector (partitioned vector) is a type representing a vector whose entries are distributed (a.k.a. partitioned) over different parts for distributed-memory parallel computations.

This type overloads numerous array-like operations with corresponding parallel implementations.

Properties

  • vector_partition::A
  • index_partition::B

vector_partition[i] contains the vector of local values of the i-th part in the data distribution. The first type parameter V corresponds to typeof(values[i]) i.e. the vector type used to store the local values. The item index_partition[i] implements the AbstractLocalIndices interface providing information about the local, own, and ghost indices in the i-th part.

The rest of fields of this struct and type parameters are private.

Supertype hierarchy

PVector{V,A,B,...} <: AbstractVector{T}

with T=eltype(V).

source

Accessors

Constructors

PartitionedArrays.PVectorMethod
PVector{V}(undef,index_partition)
PVector(undef,index_partition)

Create an instance of PVector with local uninitialized values stored in a vector of type V (which defaults to V=Vector{Float64}).

source
PartitionedArrays.pvectorMethod
pvector(f,index_partition)

Equivalent to

vector_partition = map(f,index_partition)
PVector(vector_partition,index_partition)
source
PartitionedArrays.pvectorMethod
pvector([f,]I,V,index_partition;kwargs...) -> Task

Crate an instance of PVector by setting arbitrary entries from each of the underlying parts. It returns a task that produces the instance of PVector allowing latency hiding while performing the communications needed in its setup.

source
PartitionedArrays.prandFunction
prand([rng,][s,]index_partition)

Create a PVector object with uniform random values and the data partition in index_partition. The optional arguments have the same meaning and default values as in rand.

source
PartitionedArrays.prandnFunction
prandn([rng,][s,]index_partition)

Create a PVector object with normally distributed random values and the data partition in index_partition. The optional arguments have the same meaning and default values as in randn.

source

Assembly

PartitionedArrays.assemble!Method
assemble!([op,] a::PVector) -> Task

Transfer the ghost values to their owner part and insert them according with the insertion operation op (+ by default). It returns a task that produces a with updated values. After the transfer, the source ghost values are set to zero.

Examples

julia> using PartitionedArrays

julia> rank = LinearIndices((2,));

julia> row_partition = uniform_partition(rank,6,true);

julia> map(local_to_global,row_partition)
2-element Vector{PartitionedArrays.BlockPartitionLocalToGlobal{1, Vector{Int32}}}:
 [1, 2, 3, 4]
 [3, 4, 5, 6]

julia> a = pones(row_partition)
6-element PVector partitioned into 2 parts of type Vector{Float64}

julia> local_values(a)
2-element Vector{Vector{Float64}}:
 [1.0, 1.0, 1.0, 1.0]
 [1.0, 1.0, 1.0, 1.0]

julia> assemble!(a) |> wait

julia> local_values(a)
2-element Vector{Vector{Float64}}:
 [1.0, 1.0, 2.0, 0.0]
 [0.0, 2.0, 1.0, 1.0]
source
PartitionedArrays.consistent!Method
consistent!(a::PVector) -> Task

Make the local values of a globally consistent. I.e., the ghost values are updated with the corresponding own value in the part that owns the associated global global id.

Examples

julia> using PartitionedArrays

julia> rank = LinearIndices((2,));

julia> row_partition = uniform_partition(rank,6,true);

julia> map(local_to_global,row_partition)
2-element Vector{PartitionedArrays.BlockPartitionLocalToGlobal{1, Vector{Int32}}}:
 [1, 2, 3, 4]
 [3, 4, 5, 6]

julia> a = pvector(inds->fill(part_id(inds),length(inds)),row_partition)
6-element PVector partitioned into 2 parts of type Vector{Int32}

julia> local_values(a)
2-element Vector{Vector{Int32}}:
 [1, 1, 1, 1]
 [2, 2, 2, 2]

julia> consistent!(a) |> wait

julia> local_values(a)
2-element Vector{Vector{Int32}}:
 [1, 1, 1, 2]
 [1, 2, 2, 2]
source

Re-partition