Skip to content

Commit

Permalink
Make output of MPI test visible
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed May 27, 2020
1 parent 1078849 commit 7175c8c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
19 changes: 17 additions & 2 deletions test/mpi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,33 @@ FFTW.set_num_threads(1)
# Initialise MPI
MPI.Init()

# Define a convenience method to easily replace some parametres
function (p::TDAC.tdac_params)(; kwargs...)
# Extract parameters of the input instance
fields = Dict(name => getfield(p, name) for name in fieldnames(typeof(p)))
for (k, v) in kwargs
# Replace the fields with the new values
fields[k] = v
end
# Return the new instance
return TDAC.tdac_params(; fields...)
end

# Get the number or ranks, so that we can set a number of particle as an integer
# multiple of them.
my_size = MPI.Comm_size(MPI.COMM_WORLD)

params = TDAC.tdac_params(; nprt = my_size, nobs = 4, padding = 0, enable_timers = true,
verbose = true, n_time_step = 5, nx = 20, ny = 20)

# Warmup
rm("tdac.h5"; force = true)
tdac(TDAC.tdac_params(; nprt = my_size, nobs = 4, padding = 0, enable_timers = true, verbose = true))
tdac(params)
# Flush a newline
println()

# Run the command
rm("tdac.h5"; force = true)
tdac(TDAC.tdac_params(; nprt = 2 * my_size, nobs = 36, padding = 0, enable_timers = true, verbose = true))
tdac(params(; nprt = 2 * my_size, nobs = 36))
# Flush a newline
println()
13 changes: 12 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,18 @@ end
mktempdir() do dir
cd(dir) do
mpiexec() do cmd
@test success(`$(cmd) -n 2 $(Base.julia_cmd()) $(script)`)
run(`$(cmd) -n 2 $(Base.julia_cmd()) $(script)`)
# This is a dummy test. If `run` exitsts successfully, this
# testset will be successful as well, if `run` errors out this
# testset will error out as well, and the next `@test` will not
# be executed. The advantage over doing something like
# @test success(`...`)
# is that with
# run(`...`)
# @test true
# we can directly see the output of the spawned command, which
# would be suppressed if using `success`.
@test true
end
end
end
Expand Down

0 comments on commit 7175c8c

Please sign in to comment.