Skip to content

Commit 941e0fe

Browse files
committed
add show method for MPIManager
1 parent e83adaa commit 941e0fe

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

src/cman.jl

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const MPI_TRANSPORT_ALL = 1
77
const TCP_TRANSPORT_ALL = 2
88

99
type MPIManager <: ClusterManager
10-
np::Integer
10+
np::Int
1111
mpi2j::Dict
1212
j2mpi::Dict
1313
mode::Int
@@ -28,17 +28,24 @@ type MPIManager <: ClusterManager
2828
ranks::Array
2929

3030

31-
function MPIManager(;np=Sys.CPU_CORES, mpi_cmd=false, launch_timeout=60.0, mode=MPI_ON_WORKERS)
31+
function MPIManager(;np=Sys.CPU_CORES,
32+
mpi_cmd=`mpirun -np $np`,
33+
launch_timeout=60.0,
34+
mode=MPI_ON_WORKERS)
3235
launched = false
33-
3436
if mode != MPI_ON_WORKERS
3537
launched = true
3638
mpi_cmd = ``
37-
elseif mpi_cmd == false
38-
mpi_cmd = `mpirun -np $np`
3939
end
40-
41-
mgr = new(np, Dict{Int, Int}(), Dict{Int, Int}(), mode, mpi_cmd, launch_timeout, false, Condition(), launched)
40+
mgr = new(Int(np),
41+
Dict{Int,Int}(),
42+
Dict{Int,Int}(),
43+
mode,
44+
mpi_cmd,
45+
launch_timeout,
46+
false,
47+
Condition(),
48+
launched)
4249

4350
if mode != MPI_TRANSPORT_ALL
4451
# Start a listener for capturing stdout's from the workers
@@ -56,11 +63,23 @@ type MPIManager <: ClusterManager
5663
comm, comm_size, rank = comm_info()
5764
mgr.ranks = [i for i in 1:(comm_size-1)]
5865
end
59-
6066
return mgr
6167
end
6268
end
6369

70+
function Base.show(io::IO, man::MPIManager)
71+
mode = if man.mode == 0
72+
"MPI_ON_WORKERS"
73+
elseif man.mode == 1
74+
"MPI_TRANSPORT_ALL"
75+
elseif man.mode == 2
76+
"TCP_TRANSPORT_ALL"
77+
else
78+
error("invalid MPIManager mode: $(man.mode)")
79+
end
80+
print(io, "MPI.MPIManager(np=$(man.np),launched=$(man.launched),mode=$(mode))")
81+
end
82+
6483
function launch(manager::MPIManager, params::Dict, instances_arr::Array, c::Condition)
6584
try
6685
if manager.mode == MPI_ON_WORKERS

0 commit comments

Comments
 (0)