11include (" common.jl" )
22
3+ # Syncing parallel MPI I/O is a bit involved:
4+ function sync (comm, fh)
5+ # First ensure that all local changes are flushed ...
6+ MPI. File. sync (fh)
7+ # ... then wait for all other process to finish doing that ...
8+ MPI. Barrier (comm)
9+ # ... then make sure we see all changes that the other processes made.
10+ MPI. File. sync (fh)
11+ end
12+
313# Find MPI vendor
414library_version = MPI. Get_library_version ()
515# Peel off MPItrampoline if present
@@ -25,66 +35,57 @@ filename = MPI.bcast(tempname(), 0, comm)
2535fh = MPI. File. open (comm, filename, read= true , write= true , create= true )
2636@test MPI. File. get_position_shared (fh) == 0
2737
28- function sync ()
29- # First ensure that all local changes are flushed ...
30- MPI. File. sync (fh)
31- # ... then wait for all other process to finish doing that ...
32- MPI. Barrier (comm)
33- # ... then make sure we see all changes that the other processes made.
34- MPI. File. sync (fh)
35- end
36-
3738if ! MPI. File. get_atomicity (fh)
3839 MPI. File. set_atomicity (fh, true )
3940end
4041@test MPI. File. get_atomicity (fh)
41- sync ()
42+ sync (comm, fh )
4243
4344header = " my header"
4445
4546if rank == 0
4647 MPI. File. write_shared (fh, header)
4748end
48- sync ()
49+ sync (comm, fh )
4950
5051offset = MPI. File. get_position_shared (fh)
5152@test offset == sizeof (header)
5253byte_offset = MPI. File. get_byte_offset (fh, offset)
5354@test byte_offset == offset
5455
5556MPI. File. set_view! (fh, byte_offset, MPI. Datatype (Int64), MPI. Datatype (Int64))
56- sync ()
57+ sync (comm, fh )
5758@test MPI. File. get_position_shared (fh) == 0
5859
5960MPI. File. write_ordered (fh, fill (Int64 (rank), rank+ 1 ))
60- sync ()
61+ sync (comm, fh )
6162# https://github.com/JuliaParallel/MPI.jl/issues/879
6263@test MPI. File. get_position_shared (fh) == sum (1 : sz) skip = (vendor == :MPICH && Sys. isapple ())
6364
6465MPI. File. seek_shared (fh, 0 )
6566@test MPI. File. get_position_shared (fh) == 0
66- sync ()
67+ sync (comm, fh )
6768
6869buf = zeros (Int64, rank+ 1 )
6970MPI. File. read_ordered! (fh, buf)
7071@test buf == fill (Int64 (rank), rank+ 1 )
71- sync ()
72+ sync (comm, fh )
7273
7374# https://github.com/JuliaParallel/MPI.jl/issues/555
7475@test MPI. File. get_position_shared (fh) == sum (1 : sz) skip = Sys. iswindows ()
7576
7677MPI. File. set_view! (fh, 0 , MPI. Datatype (UInt8), MPI. Datatype (UInt8))
77- sync ()
78+ sync (comm, fh )
7879MPI. File. seek_shared (fh, 0 )
7980@test MPI. File. get_position_shared (fh) == 0
80- sync ()
81+ sync (comm, fh )
8182
8283if rank == sz- 1
8384 buf = Array {UInt8} (undef, sizeof (header))
8485 MPI. File. read_shared! (fh, buf)
8586 @test String (buf) == header
8687end
87- sync ()
88+ sync (comm, fh )
8889
8990@test MPI. File. get_position_shared (fh) == sizeof (header)
9091
0 commit comments