Skip to content

Commit 41d607c

Browse files
committed
add MPI_File_fence
1 parent c5b12c1 commit 41d607c

File tree

11 files changed

+146
-0
lines changed

11 files changed

+146
-0
lines changed

src/mpi/romio/adio/ad_lustre/ad_lustre.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct ADIOI_Fns_struct ADIO_LUSTRE_operations = {
3232
ADIOI_GEN_IreadStrided, /* IreadStrided */
3333
ADIOI_GEN_IwriteStrided, /* IwriteStrided */
3434
ADIOI_GEN_Flush, /* Flush */
35+
ADIOI_GEN_Fence, /* Fence */
3536
ADIOI_GEN_Resize, /* Resize */
3637
ADIOI_GEN_Delete, /* Delete */
3738
ADIOI_GEN_Feature, /* Features */

src/mpi/romio/adio/ad_unify/Makefile.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ romio_other_sources += \
1515
adio/ad_unify/ad_unify_close.c \
1616
adio/ad_unify/ad_unify_io.c \
1717
adio/ad_unify/ad_unify_flush.c \
18+
adio/ad_unify/ad_unify_fence.c \
1819
adio/ad_unify/ad_unify_delete.c \
1920
adio/ad_unify/ad_unify_fcntl.c \
2021
adio/ad_unify/ad_unify_resize.c \

src/mpi/romio/adio/ad_unify/ad_unify.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct ADIOI_Fns_struct ADIO_UNIFY_operations = {
3535
ADIOI_FAKE_IreadStrided, /* IreadStrided */
3636
ADIOI_FAKE_IwriteStrided, /* IwriteStrided */
3737
ADIOI_UNIFY_Flush, /* Flush */
38+
ADIOI_UNIFY_Fence, /* Fence */
3839
ADIOI_UNIFY_Resize, /* Resize */
3940
ADIOI_UNIFY_Delete, /* Delete */
4041
ADIOI_UNIFY_Feature,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
#include "ad_unify.h"
3+
#include "ad_unify_common.h"
4+
5+
void ADIOI_UNIFY_Fence(ADIO_File fd, int *error_code)
6+
{
7+
int ret;
8+
*error_code = MPI_SUCCESS;
9+
ADIOI_UNIFY_fs *unifyfs_blob = fd->fs_ptr;
10+
11+
/* Synchronize with file system to flush writes
12+
* to make data visible to other processes. */
13+
unifyfs_io_request sync_req = {
14+
.op = UNIFYFS_IOREQ_OP_SYNC_META,
15+
.gfid = unifyfs_blob->gfid,
16+
.result.error = 0,
17+
};
18+
ret = unifyfs_dispatch_io(unifyfs_blob->fshdl, 1, &sync_req);
19+
if (ret == UNIFYFS_SUCCESS) {
20+
ret = unifyfs_wait_io(unifyfs_blob->fshdl, 1, &sync_req, 1);
21+
if (ret == UNIFYFS_SUCCESS)
22+
if (sync_req.result.error != 0) {
23+
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
24+
MPIR_ERR_RECOVERABLE, __func__, __LINE__,
25+
MPI_ERR_IO, "**io", "**io %s",
26+
strerror(sync_req.result.error));
27+
}
28+
}
29+
30+
/* Synchronize processes so that upon returning from fence,
31+
* all procs know that all other procs have completed their flush. */
32+
MPI_Barrier(fd->comm);
33+
34+
return;
35+
}

src/mpi/romio/adio/common/Makefile.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ romio_other_sources += \
1717
adio/common/ad_fcntl.c \
1818
adio/common/ad_features.c \
1919
adio/common/ad_flush.c \
20+
adio/common/ad_fence.c \
2021
adio/common/ad_fstype.c \
2122
adio/common/ad_get_sh_fp.c \
2223
adio/common/ad_hints.c \
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (C) by Argonne National Laboratory
3+
* See COPYRIGHT in top-level directory
4+
*/
5+
6+
#include "adio.h"
7+
8+
#ifdef HAVE_UNISTD_H
9+
#include <unistd.h>
10+
#endif
11+
12+
void ADIOI_GEN_Fence(ADIO_File fd, int *error_code)
13+
{
14+
int err;
15+
static char myname[] = "ADIOI_GEN_FENCE";
16+
17+
/* For the general (common) case, we assume that the underlying
18+
* file system implements a POSIX-style write,
19+
* meaning that written data becomes visible immediately after
20+
* returning from a successful write call.
21+
*
22+
* For such file systems, there is no need to explicitly flush
23+
* data or to synchronize with the file system to expose those writes. */
24+
25+
/* Even though the data flush step is a NOP,
26+
* fence semantics still require that we synchronize processes. */
27+
MPI_Barrier(fd->comm);
28+
29+
*error_code = MPI_SUCCESS;
30+
}

src/mpi/romio/adio/include/adio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ void ADIO_IwriteStridedColl(ADIO_File fd, void *buf, int count,
396396
ADIO_Offset ADIO_SeekIndividual(ADIO_File fd, ADIO_Offset offset, int whence, int *error_code);
397397
void ADIO_Delete(char *filename, int *error_code);
398398
void ADIO_Flush(ADIO_File fd, int *error_code);
399+
void ADIO_Fence(ADIO_File fd, int *error_code);
399400
void ADIO_Resize(ADIO_File fd, ADIO_Offset size, int *error_code);
400401
void ADIO_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code);
401402
void ADIO_ResolveFileType(MPI_Comm comm, const char *filename, int *fstype,

src/mpi/romio/adio/include/adioi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ struct ADIOI_Fns_struct {
332332

333333
#define ADIO_Flush(fd,error_code) (*(fd->fns->ADIOI_xxx_Flush))(fd,error_code)
334334

335+
#define ADIO_Fence(fd,error_code) (*(fd->fns->ADIOI_xxx_Fence))(fd,error_code)
336+
335337
#define ADIO_Resize(fd,size,error_code) \
336338
(*(fd->fns->ADIOI_xxx_Resize))(fd,size,error_code)
337339

src/mpi/romio/include/mpio.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ int MPI_Register_datarep(const char *datarep, MPI_Datarep_conversion_function *r
246246
int MPI_File_set_atomicity(MPI_File fh, int flag) ROMIO_API_PUBLIC;
247247
int MPI_File_get_atomicity(MPI_File fh, int *flag) ROMIO_API_PUBLIC;
248248
int MPI_File_sync(MPI_File fh) ROMIO_API_PUBLIC;
249+
int MPI_File_fence(MPI_File fh) ROMIO_API_PUBLIC;
249250

250251
/* Section 4.13.3 */
251252
#ifndef MPICH
@@ -549,6 +550,7 @@ int PMPI_Register_datarep(const char *,
549550
int PMPI_File_set_atomicity(MPI_File, int) ROMIO_API_PUBLIC;
550551
int PMPI_File_get_atomicity(MPI_File, int *) ROMIO_API_PUBLIC;
551552
int PMPI_File_sync(MPI_File) ROMIO_API_PUBLIC;
553+
int PMPI_File_fence(MPI_File) ROMIO_API_PUBLIC;
552554

553555
/* Section 4.13.3 */
554556
#ifndef MPICH

src/mpi/romio/mpi-io/Makefile.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ romio_mpi_sources += \
1515
mpi-io/file_c2f.c \
1616
mpi-io/file_f2c.c \
1717
mpi-io/fsync.c \
18+
mpi-io/fence.c \
1819
mpi-io/get_amode.c \
1920
mpi-io/get_atom.c \
2021
mpi-io/get_bytoff.c \

0 commit comments

Comments
 (0)