Skip to content

Commit 50d5916

Browse files
authored
Define mpiexec variable at build time (#275)
Fixes #274.
1 parent e5ab08c commit 50d5916

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed

.appveyor.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ install:
2525
"https://download.microsoft.com/download/A/E/0/AE002626-9D9D-448D-8197-1EA510E297CE/msmpisetup.exe",
2626
"C:\projects\MSMpiSetup.exe")
2727
- C:\projects\MSMpiSetup.exe -unattend -minimal
28-
- set PATH=C:\Program Files\Microsoft MPI\Bin;%PATH%
28+
# This shouldn't typicallybe needed: the installer adds the directory to
29+
# the PATH. For some reason this doesn't work on Appveyor
30+
- set JULIA_MPIEXEC=C:\Program Files\Microsoft MPI\Bin\mpiexec.exe
2931

3032
build_script:
3133
- echo "%JL_BUILD_SCRIPT%"

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ matrix:
3636
before_install:
3737
- sh ./conf/travis-install-mpi.sh $MPI_IMPL
3838
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export JULIA_MPI_PATH=$HOME/$MPI_IMPL; fi
39-
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export PATH=$HOME/$MPI_IMPL/bin:$PATH; fi
4039
# Work around OpenMPI attempting to create overly long temporary
4140
# file names - and erroring as a result
4241
- export TMPDIR=/tmp

deps/build.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@ end
77
MPI_INCLUDE_PATH = get(ENV, "JULIA_MPI_INCLUDE_PATH") do
88
MPI_PATH !== nothing ? joinpath(MPI_PATH,"include") : nothing
99
end
10-
MPICC = get(ENV, "JULIA_MPICC") do
10+
mpicc = get(ENV, "JULIA_MPICC") do
1111
if MPI_PATH !== nothing
1212
joinpath(MPI_PATH,"bin","mpicc")
1313
else
1414
"mpicc"
1515
end
1616
end
1717

18+
mpiexec = get(ENV, "JULIA_MPIEXEC") do
19+
if MPI_PATH !== nothing
20+
joinpath(MPI_PATH,"bin","mpiexec")
21+
else
22+
"mpiexec"
23+
end
24+
end
25+
1826
if haskey(ENV, "JULIA_MPI_CFLAGS")
1927
CFLAGS = split(ENV["JULIA_MPI_CFLAGS"])
2028
else
@@ -61,6 +69,7 @@ open("deps.jl","w") do f
6169
println(f, :(const libmpi = $libmpi))
6270
println(f, :(const libmpi_size = $libsize))
6371
println(f, :(const MPI_VERSION = $MPI_VERSION))
72+
println(f, :(const mpiexec = $mpiexec))
6473
end
6574

6675
if Sys.iswindows()
@@ -70,7 +79,7 @@ if Sys.iswindows()
7079
else
7180
include("gen_consts.jl")
7281

73-
run(`$MPICC gen_consts.c -o gen_consts $CFLAGS`)
82+
run(`$mpicc gen_consts.c -o gen_consts $CFLAGS`)
7483

7584
open("deps.jl","a") do f
7685
run(pipeline(`./gen_consts`, stdout = f))

docs/src/installing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ controlled with the optional environment variables:
2828
- `JULIA_MPI_INCLUDE_PATH`: the directory containing the MPI header files.
2929
- `JULIA_MPI_CFlAGS`: C flags passed to the constant generation build (default: `-lmpi`)
3030
- `JULIA_MPICC`: MPI C compiler (default: `mpicc`)
31+
- `JULIA_MPIEXEC`: MPI startup command (default: `mpiexec`)
3132

3233
If your MPI installation changes (e.g. it is upgraded by the system, or you switch
3334
libraries), you will need to re-run `build MPI` at the package prompt.

src/cman.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mutable struct MPIManager <: ClusterManager
5555
receiving_done::Channel{Nothing}
5656

5757
function MPIManager(; np::Integer = Sys.CPU_THREADS,
58-
mpirun_cmd::Cmd = `mpiexec -n $np`,
58+
mpirun_cmd::Cmd = `$mpiexec -n $np`,
5959
launch_timeout::Real = 60.0,
6060
mode::TransportMode = MPI_ON_WORKERS,
6161
master_tcp_interface::String="" )

test/runtests.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using MPI
22
using Test
33

4+
import MPI: mpiexec
5+
46
# Code coverage command line options; must correspond to src/julia.h
57
# and src/ui/repl.c
68
const JL_LOG_NONE = 0
@@ -25,7 +27,7 @@ function runtests()
2527

2628
extra_args = []
2729
@static if !Sys.iswindows()
28-
if occursin( "OpenRTE", read(`mpiexec --version`, String))
30+
if occursin( "OpenRTE", read(`$mpiexec --version`, String))
2931
push!(extra_args,"--oversubscribe")
3032
end
3133
end
@@ -35,11 +37,11 @@ function runtests()
3537
for f in testfiles
3638
coverage_opt = coverage_opts[Base.JLOptions().code_coverage]
3739
if f singlefiles
38-
run(`mpiexec $extra_args -n 1 $exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
40+
run(`$mpiexec $extra_args -n 1 $exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
3941
elseif f juliafiles
4042
run(`$exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
4143
else
42-
run(`mpiexec $extra_args -n $nprocs $exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
44+
run(`$mpiexec $extra_args -n $nprocs $exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
4345
end
4446
Base.with_output_color(:green,stdout) do io
4547
println(io,"\tSUCCESS: $f")

test/test_cman_julia.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ using Test
22
using MPI
33
using Distributed
44

5+
import MPI: mpiexec
6+
57
# Start workers via `mpiexec` that communicate among themselves via MPI;
68
# communicate with the workers via TCP
7-
if !Sys.iswindows() && occursin( "OpenRTE", open(f->read(f, String),`mpiexec --version`))
8-
mgr = MPI.MPIManager(np=4, mpirun_cmd=`mpiexec --oversubscribe -n 4`)
9+
if !Sys.iswindows() && occursin( "OpenRTE", open(f->read(f, String),`$mpiexec --version`))
10+
mgr = MPI.MPIManager(np=4, mpirun_cmd=`$mpiexec --oversubscribe -n 4`)
911
else
1012
mgr = MPI.MPIManager(np=4)
1113
end

0 commit comments

Comments
 (0)