PVector
Type signature
PartitionedArrays.PVector — Typestruct 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::Aindex_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).
Accessors
PartitionedArrays.local_values — Methodlocal_values(a::PVector)Get a vector of vectors containing the local values in each part of a.
The indices of the returned vectors can be mapped to global indices, own indices, ghost indices, and owner by using local_to_global, local_to_own, local_to_ghost, and local_to_owner, respectively.
PartitionedArrays.own_values — Methodown_values(a::PVector)Get a vector of vectors containing the own values in each part of a.
The indices of the returned vectors can be mapped to global indices, local indices, and owner by using own_to_global, own_to_local, and own_to_owner, respectively.
PartitionedArrays.ghost_values — Methodghost_values(a::PVector)Get a vector of vectors containing the ghost values in each part of a.
The indices of the returned matrices can be mapped to global indices, local indices, and owner by using ghost_to_global, ghost_to_local, and ghost_to_owner, respectively.
Constructors
PartitionedArrays.PVector — MethodPVector(vector_partition,index_partition)Create an instance of PVector from the underlying properties vector_partition and index_partition.
PartitionedArrays.PVector — MethodPVector{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}).
PartitionedArrays.pvector — Methodpvector(f,index_partition)Equivalent to
vector_partition = map(f,index_partition)
PVector(vector_partition,index_partition)PartitionedArrays.pvector — Methodpvector([f,]I,V,index_partition;kwargs...) -> TaskCrate 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.
PartitionedArrays.pvector! — Functionpvector!(B::PVector,V,cache)PartitionedArrays.pfill — Functionpfill(v,index_partition)PartitionedArrays.pzeros — Functionpzeros([T,]index_partition)Equivalent to
pfill(zero(T),index_partition)PartitionedArrays.pones — Functionpones([T,]index_partition)Equivalent to
pfill(one(T),index_partition)PartitionedArrays.prand — Functionprand([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.
PartitionedArrays.prandn — Functionprandn([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.
Assembly
PartitionedArrays.assemble! — Methodassemble!([op,] a::PVector) -> TaskTransfer 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]PartitionedArrays.assemble — Methodassemble(v::PVector[,rows];reuse=false)PartitionedArrays.assemble! — Methodassemble!(w::PVector,v::PVector,cache)PartitionedArrays.consistent! — Methodconsistent!(a::PVector) -> TaskMake 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]PartitionedArrays.consistent — Methodconsistent(v::PVector,rows;reuse=false)PartitionedArrays.consistent! — Methodconsistent!(w::PVector,v::PVector,cache)Re-partition
PartitionedArrays.repartition — Methodrepartition(v::PVector,new_partition;reuse=false)PartitionedArrays.repartition! — Methodrepartition!(w::PVector,v::PVector[,cache];reversed=false)