Skip to content

Commit 29ea596

Browse files
authored
Merge pull request #17 from JuliaParallel/sb/mpiexec
use MPI.mpiexec function
2 parents b6f5a55 + ed92070 commit 29ea596

File tree

7 files changed

+27
-93
lines changed

7 files changed

+27
-93
lines changed

.appveyor.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
environment:
22
matrix:
3-
- julia_version: 1.0
4-
- julia_version: 1.1
5-
- julia_version: 1.2
3+
- julia_version: 1.3
4+
- julia_version: 1.4
65
- julia_version: nightly
76

87
platform:
@@ -26,14 +25,6 @@ notifications:
2625

2726
install:
2827
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
29-
- ps: (new-object net.webclient).DownloadFile(
30-
"https://download.microsoft.com/download/A/E/0/AE002626-9D9D-448D-8197-1EA510E297CE/msmpisetup.exe",
31-
"C:\projects\MSMpiSetup.exe")
32-
- C:\projects\MSMpiSetup.exe -unattend -minimal
33-
- set PATH=C:\Program Files\Microsoft MPI\Bin;%PATH% # can be removed in new MPI.jl
34-
# This shouldn't typicallybe needed: the installer adds the directory to
35-
# the PATH. For some reason this doesn't work on Appveyor
36-
- set JULIA_MPIEXEC=C:\Program Files\Microsoft MPI\Bin\mpiexec.exe
3728

3829
build_script:
3930
- echo "%JL_BUILD_SCRIPT%"

.travis.yml

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
language: julia
2-
sudo: required
32
dist: trusty
43

54
os:
65
- linux
76
- osx
87

98
julia:
10-
- 1.0
11-
- 1.1
12-
- 1.2
9+
- 1.3
10+
- 1.4
1311
- nightly
1412

1513
branches:
@@ -25,41 +23,9 @@ cache:
2523
- $HOME/.ccache
2624
- $HOME/.julia/registries # can we cache all of .julia?
2725

28-
env:
29-
- MPI_IMPL=mpich
30-
- MPI_IMPL=openmpi
31-
# - MPI_IMPL=intelmpi
32-
3326
matrix:
3427
allow_failures:
3528
- julia: nightly
36-
- os: osx # MPI.jl issue 262
37-
env: MPI_IMPL=openmpi
38-
exclude:
39-
- os: osx
40-
env: MPI_IMPL=intelmpi
41-
42-
before_install:
43-
- sh ./conf/travis-install-mpi.sh $MPI_IMPL
44-
- |
45-
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
46-
if [ "$MPI_IMPL" == "intelmpi" ]; then
47-
source $HOME/intel/compilers_and_libraries/linux/mpi/intel64/bin/mpivars.sh release
48-
else
49-
export JULIA_MPI_PATH=$HOME/$MPI_IMPL;
50-
fi
51-
fi
52-
# following can be removed with next MPI.jl release.
53-
- export PATH=$HOME/$MPI_IMPL/bin:$PATH
54-
- export CC=mpicc
55-
- export FC=mpif90
56-
# Work around OpenMPI attempting to create overly long temporary
57-
# file names - and erroring as a result
58-
- export TMPDIR=/tmp
59-
# Work around MacOS/OpenMPI issue:
60-
# https://github.com/open-mpi/ompi/issues/6518
61-
# https://github.com/open-mpi/ompi/issues/5798
62-
- export OMPI_MCA_btl=self,tcp
6329

6430
jobs:
6531
include:

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
1010
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
1111

1212
[compat]
13+
MPI = "0.14"
1314
julia = "1"
1415

1516
[extras]

src/MPIClusterManagers.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export MPIManager, launch, manage, kill, procs, connect, mpiprocs, @mpi_do, Tran
44

55
using Distributed, Serialization
66
import MPI
7-
const mpiexec = isdefined(MPI, :mpiexec_path) ? MPI.mpiexec_path : "mpiexec"
87

98
include("mpimanager.jl")
109

src/mpimanager.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ mutable struct MPIManager <: ClusterManager
2929
mode::TransportMode
3030

3131
launched::Bool # Are the MPI processes running?
32-
mpirun_cmd::Cmd # How to start MPI processes
3332
launch_timeout::Int # seconds
3433

3534
initialized::Bool # All workers registered with us
@@ -51,10 +50,9 @@ mutable struct MPIManager <: ClusterManager
5150
receiving_done::Channel{Nothing}
5251

5352
function MPIManager(; np::Integer = Sys.CPU_THREADS,
54-
mpirun_cmd::Cmd = `$mpiexec -n $np`,
5553
launch_timeout::Real = 60.0,
5654
mode::TransportMode = MPI_ON_WORKERS,
57-
master_tcp_interface::String="" )
55+
master_tcp_interface::String="" )
5856
mgr = new()
5957
mgr.np = np
6058
mgr.mpi2j = Dict{Int,Int}()
@@ -64,7 +62,6 @@ mutable struct MPIManager <: ClusterManager
6462
# Only start MPI processes for MPI_ON_WORKERS
6563
mgr.launched = mode != MPI_ON_WORKERS
6664
@assert MPI.Initialized() == mgr.launched
67-
mgr.mpirun_cmd = mpirun_cmd
6865
mgr.launch_timeout = launch_timeout
6966

7067
mgr.initialized = false
@@ -141,8 +138,10 @@ function Distributed.launch(mgr::MPIManager, params::Dict,
141138
end
142139
cookie = string(":cookie_",Distributed.cluster_cookie())
143140
setup_cmds = `import MPIClusterManagers\;MPIClusterManagers.setup_worker'('$(mgr.ip),$(mgr.port),$cookie')'`
144-
mpi_cmd = `$(mgr.mpirun_cmd) $(params[:exename]) -e $(Base.shell_escape(setup_cmds))`
145-
open(detach(mpi_cmd))
141+
MPI.mpiexec() do mpiexec_cmd
142+
mpi_cmd = `$mpiexec_cmd -n $(mgr.np) $(params[:exename]) -e $(Base.shell_escape(setup_cmds))`
143+
open(detach(mpi_cmd))
144+
end
146145
mgr.launched = true
147146
end
148147

test/runtests.jl

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,23 @@
11
using Pkg
22
pkg"precompile"
33

4-
using MPIClusterManagers: mpiexec
5-
using Test
4+
using Test, MPI
65

7-
# Code coverage command line options; must correspond to src/julia.h
8-
# and src/ui/repl.c
9-
const JL_LOG_NONE = 0
10-
const JL_LOG_USER = 1
11-
const JL_LOG_ALL = 2
12-
const coverage_opts =
13-
Dict{Int, String}(JL_LOG_NONE => "none",
14-
JL_LOG_USER => "user",
15-
JL_LOG_ALL => "all")
6+
nprocs = clamp(Sys.CPU_THREADS, 2, 4)
167

17-
function runtests()
18-
nprocs = clamp(Sys.CPU_THREADS, 2, 4)
19-
exename = joinpath(Sys.BINDIR, Base.julia_exename())
20-
extra_args = []
21-
@static if !Sys.iswindows()
22-
if occursin( "OpenRTE", read(`$mpiexec --version`, String))
23-
push!(extra_args,"--oversubscribe")
24-
end
25-
end
26-
27-
coverage_opt = coverage_opts[Base.JLOptions().code_coverage]
28-
29-
jlexec = `$exename --code-coverage=$coverage_opt`
30-
mpijlexec = `$mpiexec $extra_args -n $nprocs $jlexec`
31-
32-
@info "Testing: test_cman_julia.jl"
33-
run(`$jlexec $(joinpath(@__DIR__, "test_cman_julia.jl"))`)
8+
@info "Testing: test_cman_julia.jl"
9+
run(`$(Base.julia_cmd()) $(joinpath(@__DIR__, "test_cman_julia.jl")) $nprocs`)
3410

11+
if VERSION >= v"1.5"
3512
@info "Testing: test_cman_mpi.jl"
36-
run(`$mpijlexec $(joinpath(@__DIR__, "test_cman_mpi.jl"))`)
37-
38-
@info "Testing: test_cman_tcp.jl"
39-
run(`$mpijlexec $(joinpath(@__DIR__, "test_cman_tcp.jl"))`)
13+
mpiexec() do cmd
14+
run(`$cmd -n $nprocs $(Base.julia_cmd()) $(joinpath(@__DIR__, "test_cman_mpi.jl"))`)
15+
end
16+
else
17+
@warn "MPI_TRANSPORT_ALL broken on Julia versions < 1.5\nSee https://github.com/JuliaParallel/MPIClusterManagers.jl/issues/9"
4018
end
4119

42-
runtests()
20+
@info "Testing: test_cman_tcp.jl"
21+
mpiexec() do cmd
22+
run(`$cmd -n $nprocs $(Base.julia_cmd()) $(joinpath(@__DIR__, "test_cman_tcp.jl"))`)
23+
end

test/test_cman_julia.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ using Test
22
using MPIClusterManagers
33
using Distributed
44

5-
using MPIClusterManagers: mpiexec
65
import MPI
76

87
# Start workers via `mpiexec` that communicate among themselves via MPI;
98
# communicate with the workers via TCP
10-
if !Sys.iswindows() && occursin( "OpenRTE", open(f->read(f, String),`$mpiexec --version`))
11-
mgr = MPIManager(np=4, mpirun_cmd=`$mpiexec --oversubscribe -n 4`)
12-
else
13-
mgr = MPIManager(np=4)
14-
end
9+
nprocs = parse(Int, ARGS[1])
10+
11+
mgr = MPIManager(np=nprocs)
1512
addprocs(mgr)
1613

1714
refs = []

0 commit comments

Comments
 (0)