@@ -97,6 +97,26 @@ function set_view!(file::FileHandle, disp::Integer, etype::Datatype, filetype::D
97
97
set_view! (file, disp, etype, filetype, datarep, Info (infokwargs... ))
98
98
end
99
99
100
+ """
101
+ MPI.File.get_byte_offset(file::FileHandle, offset::Integer)
102
+
103
+ Converts a view-relative offset into an absolute byte position. Returns the absolute byte
104
+ position (from the beginning of the file) of `offset` relative to the current view of
105
+ `file`.
106
+
107
+ # External links
108
+ $(_doc_external (" MPI_File_get_byte_offset" ))
109
+ """
110
+ function get_byte_offset (file:: FileHandle , offset:: Integer )
111
+ r_displ = Ref {MPI_Offset} ()
112
+ # int MPI_File_get_byte_offset(MPI_File fh, MPI_Offset offset,
113
+ # MPI_Offset *disp)
114
+ @mpichk ccall ((:MPI_File_get_byte_offset , libmpi), Cint,
115
+ (MPI_File, MPI_Offset, Ptr{MPI_Offset}),
116
+ file, offset, r_displ)
117
+ r_displ[]
118
+ end
119
+
100
120
"""
101
121
MPI.File.sync(fh::FileHandle)
102
122
@@ -212,6 +232,148 @@ end
212
232
write_at_all (file:: FileHandle , offset:: Integer , data) = write_at_all (file, offset, Buffer_send (data))
213
233
214
234
235
+ # Shared file pointer
236
+ """
237
+ MPI.File.read_shared!(file::FileHandle, data)
238
+
239
+ Reads from `file` using the shared file pointer into `data`. `data` can be a
240
+ [`Buffer`](@ref), or any object for which `Buffer(data)` is defined.
241
+
242
+ # See also
243
+ - [`MPI.File.read_ordered!`](@ref) for the collective operation
244
+
245
+ # External links
246
+ $(_doc_external (" MPI_File_read_shared" ))
247
+ """
248
+ function read_shared! (file:: FileHandle , buf:: Buffer )
249
+ stat_ref = Ref {Status} (MPI. STATUS_EMPTY)
250
+ # int MPI_File_read_shared(MPI_File fh, void *buf, int count,
251
+ # MPI_Datatype datatype, MPI_Status *status)
252
+ @mpichk ccall ((:MPI_File_read_shared , libmpi), Cint,
253
+ (MPI_File, MPIPtr, Cint, MPI_Datatype, Ptr{Status}),
254
+ file, buf. data, buf. count, buf. datatype, stat_ref)
255
+ return stat_ref[]
256
+ end
257
+ read_shared! (file:: FileHandle , data) = read_shared! (file, Buffer (data))
258
+
259
+ """
260
+ MPI.File.write_shared(file::FileHandle, data)
261
+
262
+ Writes to `file` using the shared file pointer from `data`. `data` can be a
263
+ [`Buffer`](@ref), or any object for which `Buffer(data)` is defined.
264
+
265
+ # See also
266
+ - [`MPI.File.write_ordered`](@ref) for the noncollective operation
267
+
268
+ # External links
269
+ $(_doc_external (" MPI_File_write_shared" ))
270
+ """
271
+ function write_shared (file:: FileHandle , buf:: Buffer )
272
+ stat_ref = Ref {Status} (MPI. STATUS_EMPTY)
273
+ # int MPI_File_write_shared(MPI_File fh, const void *buf, int count,
274
+ # MPI_Datatype datatype, MPI_Status *status)
275
+ @mpichk ccall ((:MPI_File_write_shared , libmpi), Cint,
276
+ (MPI_File, MPIPtr, Cint, MPI_Datatype, Ptr{Status}),
277
+ file, buf. data, buf. count, buf. datatype, stat_ref)
278
+ return stat_ref[]
279
+ end
280
+ write_shared (file:: FileHandle , buf) = write_shared (file, Buffer_send (buf))
281
+
282
+ # Shared collective operations
283
+ """
284
+ MPI.File.read_ordered!(file::FileHandle, data)
285
+
286
+ Collectively reads in rank order from `file` using the shared file pointer into `data`.
287
+ `data` can be a [`Buffer`](@ref), or any object for which `Buffer(data)` is defined. This
288
+ is a collective operation, so must be called on all ranks in the communicator on which
289
+ `file` was opened.
290
+
291
+ # See also
292
+ - [`MPI.File.read_shared!`](@ref) for the non-collective operation
293
+
294
+ # External links
295
+ $(_doc_external (" MPI_File_read_ordered" ))
296
+ """
297
+ function read_ordered! (file:: FileHandle , buf:: Buffer )
298
+ stat_ref = Ref {Status} (MPI. STATUS_EMPTY)
299
+ # int MPI_File_read_ordered(MPI_File fh, void *buf, int count,
300
+ # MPI_Datatype datatype, MPI_Status *status)
301
+ @mpichk ccall ((:MPI_File_read_ordered , libmpi), Cint,
302
+ (MPI_File, MPIPtr, Cint, MPI_Datatype, Ptr{Status}),
303
+ file, buf. data, buf. count, buf. datatype, stat_ref)
304
+ return stat_ref[]
305
+ end
306
+ read_ordered! (file:: FileHandle , data) = read_ordered! (file, Buffer (data))
307
+
308
+ """
309
+ MPI.File.write_ordered(file::FileHandle, data)
310
+
311
+ Collectively writes in rank order to `file` using the shared file pointer from `data`.
312
+ `data` can be a [`Buffer`](@ref), or any object for which `Buffer(data)` is defined. This
313
+ is a collective operation, so must be called on all ranks in the communicator on which
314
+ `file` was opened.
315
+
316
+ # See also
317
+ - [`MPI.File.write_shared`](@ref) for the noncollective operation
318
+
319
+ # External links
320
+ $(_doc_external (" MPI_File_write_ordered" ))
321
+ """
322
+ function write_ordered (file:: FileHandle , buf:: Buffer )
323
+ stat_ref = Ref {Status} (MPI. STATUS_EMPTY)
324
+ # int MPI_File_write_ordered(MPI_File fh, const void *buf, int count,
325
+ # MPI_Datatype datatype, MPI_Status *status)
326
+ @mpichk ccall ((:MPI_File_write_ordered , libmpi), Cint,
327
+ (MPI_File, MPIPtr, Cint, MPI_Datatype, Ptr{Status}),
328
+ file, buf. data, buf. count, buf. datatype, stat_ref)
329
+ return stat_ref[]
330
+ end
331
+ write_ordered (file:: FileHandle , buf) = write_ordered (file, Buffer_send (buf))
215
332
333
+ # seek
334
+ @enum Seek begin
335
+ SEEK_SET = MPI. MPI_SEEK_SET
336
+ SEEK_CUR = MPI. MPI_SEEK_CUR
337
+ SEEK_END = MPI. MPI_SEEK_END
338
+ end
339
+
340
+ """
341
+ MPI.File.seek_shared(file::FileHandle, offset::Integer, whence::Seek=SEEK_SET)
342
+
343
+ Updates the shared file pointer according to `whence`, which has the following possible
344
+ values:
345
+
346
+ - `MPI.File.SEEK_SET` (default): the pointer is set to `offset`
347
+ - `MPI.File.SEEK_CUR`: the pointer is set to the current pointer position plus `offset`
348
+ - `MPI.File.SEEK_END`: the pointer is set to the end of file plus `offset`
349
+
350
+ This is a collective operation, and must be called with the same value on all processes in
351
+ the communicator.
352
+
353
+ # External links
354
+ $(_doc_external (" MPI_File_seek_shared" ))
355
+ """
356
+ function seek_shared (file:: FileHandle , offset:: Integer , whence:: Seek = SEEK_SET)
357
+ # int MPI_File_seek_shared(MPI_File fh, MPI_Offset offset, int whence)
358
+ @mpichk ccall ((:MPI_File_seek_shared , libmpi), Cint,
359
+ (MPI_File, MPI_Offset, Cint),
360
+ file, offset, whence)
361
+ end
362
+
363
+ """
364
+ MPI.File.get_position_shared(file::FileHandle)
365
+
366
+ The current position of the shared file pointer (in `etype` units) relative to the current view.
367
+
368
+ # External links
369
+ $(_doc_external (" MPI_File_get_position_shared" ))
370
+ """
371
+ function get_position_shared (file:: FileHandle )
372
+ r = Ref {MPI_Offset} ()
373
+ # int MPI_File_get_position_shared(MPI_File fh, MPI_Offset *offset)
374
+ @mpichk ccall ((:MPI_File_get_position_shared , libmpi), Cint,
375
+ (MPI_File, Ptr{MPI_Offset}), file, r)
376
+ return r[]
377
+ end
216
378
217
379
end # module
0 commit comments