Skip to content

Commit

Permalink
Use environment variable for test nprocs (#392)
Browse files Browse the repository at this point in the history
Provides mechanism for specifying the number of procs used in tests, speed up JuliaGPU tests.
  • Loading branch information
simonbyrne authored May 23, 2020
1 parent 0afeb5e commit 4455c1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ variables:
JULIA_MPI_BINARY: "system"
JULIA_MPI_PATH: "$CI_PROJECT_DIR/mpi"
JULIA_MPI_TEST_ARRAYTYPE: 'CuArray'
JULIA_MPI_TEST_NPROCS: '2'

openmpi:
stage: build
Expand All @@ -30,7 +31,7 @@ openmpi:
- tar xf openmpi.tar.gz
- pushd openmpi-${OPENMPI_VER_FULL}
- ./configure --with-cuda --prefix="${JULIA_MPI_PATH}"
- make -j
- make -j 2
- make install
- popd
script:
Expand Down
12 changes: 9 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ using Test, MPI
using DoubleFloats
if get(ENV,"JULIA_MPI_TEST_ARRAYTYPE","") == "CuArray"
using CuArrays
ArrayType = CuArray
else
ArrayType = Array
end

if Sys.isunix()
Expand All @@ -12,16 +15,19 @@ if Sys.isunix()
include("mpiexecjl.jl")
end

args = Base.shell_split(get(ENV, "JULIA_MPIEXEC_TEST_ARGS", ""))
mpiexec_args = Base.shell_split(get(ENV, "JULIA_MPIEXEC_TEST_ARGS", ""))

nprocs = clamp(Sys.CPU_THREADS, 2, 4)
nprocs_str = get(ENV, "JULIA_MPI_TEST_NPROCS","")
nprocs = nprocs_str == "" ? clamp(Sys.CPU_THREADS, 2, 4) : parse(Int, nprocs_str)
testdir = @__DIR__
istest(f) = endswith(f, ".jl") && startswith(f, "test_")
testfiles = sort(filter(istest, readdir(testdir)))

@info "Running MPI tests" ArrayType nprocs mpiexec_args

@testset "$f" for f in testfiles
mpiexec() do cmd
cmd = `$cmd $args`
cmd = `$cmd $mpiexec_args`
if f == "test_spawn.jl"
run(`$cmd -n 1 $(Base.julia_cmd()) $(joinpath(testdir, f))`)
elseif f == "test_threads.jl"
Expand Down

0 comments on commit 4455c1d

Please sign in to comment.