You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/J1J2_mpi.jl
+9-2Lines changed: 9 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ using MPIHelper
8
8
using MPI
9
9
MPSKit.Defaults.set_scheduler!(:serial)
10
10
11
-
MPI.Init()
11
+
MPI.Init(;threadlevel=:multiple)
12
12
mpi_rank() = MPI.Comm_rank(MPI.COMM_WORLD)
13
13
mpi_size() = MPI.Comm_size(MPI.COMM_WORLD)
14
14
@@ -35,13 +35,20 @@ else
35
35
end
36
36
H_mpi =MPIOperator(H_mpi)
37
37
38
-
39
38
println("Hey, I am rank=$(mpi_rank()) out of $(mpi_size()) processes.")
40
39
41
40
ψ_infmpi, envs_infmpi, delta_infmpi =find_groundstate(state, H_mpi, verbosity=1); ## This tests VUMPS and GradientGrassmann
42
41
43
42
println("Hey, I am rank=$(mpi_rank()) out of $(mpi_size()) processes. abs(dot(ψ_inf, ψ_infmpi)) = $(abs(dot(ψ_inf, ψ_infmpi)))")
44
43
44
+
MPSKit.Defaults.set_scheduler!(:dynamic)
45
+
46
+
ψ_infmpi, envs_infmpi, delta_infmpi =find_groundstate(state, H_mpi, verbosity=1); ## This tests VUMPS and GradientGrassmann with unit cell parallelization
47
+
48
+
println("Hey, I am rank=$(mpi_rank()) out of $(mpi_size()) processes. abs(dot(ψ_inf, ψ_infmpi)) = $(abs(dot(ψ_inf, ψ_infmpi)))")
# In case the scheduler is parallel, we create new communicators for each site to separate the communication. Therefore, the MPIOperator has a Vector{MPI.Comm}, which we parse to the MPO derivatives here.
5
+
# In that case, it is crucial that MPI.ThreadLevel(3) is used, otherwise the communication will deadlock or fail!
6
+
7
+
function MPSKit.C_hamiltonian(site::Int, below, operator::MPIOperator{O, F}, above, envs) where {O, F}
Copy file name to clipboardExpand all lines: src/MPIOperator/mpioperator.jl
+12-13Lines changed: 12 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -1,36 +1,35 @@
1
1
## This shallow struct is used to indicate that each LazyMIPOperator should be evaluated on each rank and the result is to be reduced across all ranks using MPI.Allreduce
2
2
## This is the MPI-parallelized version of a linear operator
3
-
## If one added the flexibilty of choosing the reduction, one could also parallelize over products of functions etc...
4
-
struct MPIOperator{O}
3
+
struct MPIOperator{O, F, C}
5
4
parent::O
6
-
functionMPIOperator(parent::O) where {O}
7
-
if!MPI.Initialized()
8
-
@warn"MPI is currently not initialized. Please initialize MPI by running \n `using MPI; MPI.Init()` \n before creating an MPIOperator." maxlog=1
0 commit comments