Skip to content

Commit 61cf8ef

Browse files
committed
simplify MPIsafe write and read for InfiniteMPS
1 parent e35765a commit 61cf8ef

File tree

11 files changed

+146
-247
lines changed

11 files changed

+146
-247
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
struct MPIPropertyWrapper{A<:AbstractVector}
2+
property::A
3+
end
4+
5+
Base.parent(wrapper::MPIPropertyWrapper) = wrapper.property
6+
function Base.setindex!(wrapper::MPIPropertyWrapper{B}, A::C, i::Int) where {B<:AbstractVector, C}
7+
A_shared = MPI.bcast(A, MPI.COMM_WORLD) ## TODO: Write own chunked version
8+
wrapper.property[i] = A_shared
9+
return parent(wrapper)
10+
end
11+
12+
Base.getindex(wrapper::MPIPropertyWrapper, i::Int) = parent(wrapper)[i]
13+
Base.getindex(wrapper::MPIPropertyWrapper, I) = parent(wrapper)[I]
14+
15+
function Base.show(io::IO, ::MIME"text/plain", op::MPIPropertyWrapper)
16+
show(io, MIME"text/plain"(), parent(op))
17+
end
18+
Base.show(io::IO, op::MPIOperator) = show(convert(IOContext, io), op)
19+
function Base.show(io::IOContext, op::MPIOperator)
20+
show(io, parent(op))
21+
end

src/SharedMPS/sharedmps.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function Base.getproperty::InfiniteMPS, prop::Symbol)
2+
return MPIPropertyWrapper(getfield(ψ, prop))
3+
end
4+
5+
## Issue: Base.getproperty is already overloaded for MultilineMPS, QP, MultilineQP, WindowMPS, FiniteMPS

src/SharedState/finitemps.jl

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/SharedState/infinitemps.jl

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/SharedState/mpipropertywrapper.jl

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/SharedState/sharedstate.jl

Lines changed: 0 additions & 97 deletions
This file was deleted.

src/includes.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ include("MPIOperator/environments.jl")
77
include("MPIOperator/ortho.jl")
88
include("MPIOperator/transfermatrix.jl")
99

10-
include("multiprocessing/mpi/helper.jl")
11-
include("multiprocessing/mpi/mailbox.jl")
10+
include("multiprocessing/mpi/helper.jl")

src/multiprocessing/mpi/helper.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ function mpi_rank()
2222
return 0
2323
end
2424
end
25-
function mpi_is_root()
26-
return mpi_rank() == 0
25+
function mpi_is_root(root=Cint(0))
26+
return mpi_rank() == root
2727
end
2828

2929
function mpi_execute_on_root(F::Function, args...; blocking::Bool, kwargs...)

src/multiprocessing/mpi/mailbox.jl

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)