Skip to content

Commit 4455c1d

Browse files
authored
Use environment variable for test nprocs (#392)
Provides mechanism for specifying the number of procs used in tests, speed up JuliaGPU tests.
1 parent 0afeb5e commit 4455c1d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ variables:
1212
JULIA_MPI_BINARY: "system"
1313
JULIA_MPI_PATH: "$CI_PROJECT_DIR/mpi"
1414
JULIA_MPI_TEST_ARRAYTYPE: 'CuArray'
15+
JULIA_MPI_TEST_NPROCS: '2'
1516

1617
openmpi:
1718
stage: build
@@ -30,7 +31,7 @@ openmpi:
3031
- tar xf openmpi.tar.gz
3132
- pushd openmpi-${OPENMPI_VER_FULL}
3233
- ./configure --with-cuda --prefix="${JULIA_MPI_PATH}"
33-
- make -j
34+
- make -j 2
3435
- make install
3536
- popd
3637
script:

test/runtests.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ using Test, MPI
44
using DoubleFloats
55
if get(ENV,"JULIA_MPI_TEST_ARRAYTYPE","") == "CuArray"
66
using CuArrays
7+
ArrayType = CuArray
8+
else
9+
ArrayType = Array
710
end
811

912
if Sys.isunix()
@@ -12,16 +15,19 @@ if Sys.isunix()
1215
include("mpiexecjl.jl")
1316
end
1417

15-
args = Base.shell_split(get(ENV, "JULIA_MPIEXEC_TEST_ARGS", ""))
18+
mpiexec_args = Base.shell_split(get(ENV, "JULIA_MPIEXEC_TEST_ARGS", ""))
1619

17-
nprocs = clamp(Sys.CPU_THREADS, 2, 4)
20+
nprocs_str = get(ENV, "JULIA_MPI_TEST_NPROCS","")
21+
nprocs = nprocs_str == "" ? clamp(Sys.CPU_THREADS, 2, 4) : parse(Int, nprocs_str)
1822
testdir = @__DIR__
1923
istest(f) = endswith(f, ".jl") && startswith(f, "test_")
2024
testfiles = sort(filter(istest, readdir(testdir)))
2125

26+
@info "Running MPI tests" ArrayType nprocs mpiexec_args
27+
2228
@testset "$f" for f in testfiles
2329
mpiexec() do cmd
24-
cmd = `$cmd $args`
30+
cmd = `$cmd $mpiexec_args`
2531
if f == "test_spawn.jl"
2632
run(`$cmd -n 1 $(Base.julia_cmd()) $(joinpath(testdir, f))`)
2733
elseif f == "test_threads.jl"

0 commit comments

Comments
 (0)