Skip to content

Commit 23c2f7e

Browse files
committed
add atomicity get and set to io_shared
1 parent 9af96c6 commit 23c2f7e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/io.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,4 +486,35 @@ function get_position_shared(file::FileHandle)
486486
return r[]
487487
end
488488

489+
"""
490+
MPI.File.get_atomicity(file::FileHandle)
491+
492+
Get the consistency option for the `fh`. If `false` it is non-atomic.
493+
494+
# External links
495+
$(_doc_external("MPI_File_get_atomicity"))
496+
"""
497+
function get_atomicity(file::FileHandle)
498+
r = Ref{Cint}()
499+
# int MPI_File_get_atomicity(MPI_File fh, Int *flag)
500+
@mpichk ccall((:MPI_File_get_atomicity, libmpi), Cint,
501+
(MPI_File, Ptr{Cint}), file, r)
502+
return r[] == 1
503+
end
504+
505+
"""
506+
MPI.File.set_atomicity(file::FileHandle, flag::Bool)
507+
508+
Set the consitency option for the `fh`.
509+
510+
# External links
511+
$(_doc_external("MPI_File_get_atomicity"))
512+
"""
513+
function set_atomicity(file::FileHandle, flag::Bool)
514+
# int MPI_File_set_atomicity(MPI_File fh, Int flag)
515+
@mpichk ccall((:MPI_File_set_atomicity, libmpi), Cint,
516+
(MPI_File, Cint), file, flag)
517+
return nothing
518+
end
519+
489520
end # module

test/test_io_shared.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ MPI.Barrier(comm)
2020
fh = MPI.File.open(comm, filename, read=true, write=true, create=true)
2121
@test MPI.File.get_position_shared(fh) == 0
2222

23+
if !MPI.File.get_atomicity(fh)
24+
MPI.File.set_atomicity(fh, true)
25+
end
26+
27+
@test MPI.File.get_atomicity(fh)
28+
2329
MPI.Barrier(comm)
2430
MPI.File.sync(fh)
2531

0 commit comments

Comments
 (0)