Skip to content

Commit

Permalink
UnifyFS requires a stronger file consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
wkliao committed Feb 11, 2024
1 parent 88438f0 commit ae502a9
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/F90/f90tst_parallel2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ program f90tst_parallel
! With classic model netCDF-4 file, enddef must be called.
call handle_err(nf90mpi_enddef(ncid))

! UnifyFS requires a stronger file consistency
call handle_err(nf90mpi_sync(ncid))
call MPI_Barrier(MPI_COMM_WORLD, ierr)
call handle_err(nf90mpi_sync(ncid))

! Determine what part of the variable will be written for this
! processor. It's a checkerboard decomposition.
count = (/ NX / 4, NY / 4 /)
Expand Down
5 changes: 5 additions & 0 deletions test/F90/f90tst_parallel3.f90
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ program f90tst_parallel3
! This will be the last collective operation.
call check(nf90mpi_enddef(ncid))

! UnifyFS requires a stronger file consistency
call check(nf90mpi_sync(ncid))
call MPI_Barrier(MPI_COMM_WORLD, ierr)
call check(nf90mpi_sync(ncid))

! Determine what part of the variable will be written/read for this
! processor. It's a checkerboard decomposition.
count = (/ HALF_NX, HALF_NY /)
Expand Down
18 changes: 18 additions & 0 deletions test/largefile/high_dim_var.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ int main(int argc, char** argv) {
err = ncmpi_enddef(ncid); CHECK_ERR
if (err != NC_NOERR) goto fn_exit;

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

nelms = (NRECS > DIMLEN) ? NRECS : DIMLEN;
for (i=1; i<NDIMS; i++) nelms *= DIMLEN;
buffer = (short*) malloc(nelms * sizeof(short));
Expand All @@ -96,6 +102,12 @@ int main(int argc, char** argv) {
}
}

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

for (i=0; i<nelms; i++) buffer[i] = i % 32768;

for (i=0; i<NDIMS; i++) {
Expand All @@ -115,6 +127,12 @@ int main(int argc, char** argv) {
buffer); CHECK_ERR
}

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

/* all processes read and verify */
if (rank > 0) for (i=0; i<NDIMS; i++) count[i] = 2;
for (nelms=1,i=0; i<NDIMS; i++) nelms *= count[i];
Expand Down
48 changes: 48 additions & 0 deletions test/nonblocking/i_varn_indef.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,24 @@ int main(int argc, char** argv)

err = ncmpi_enddef(ncid); CHECK_ERR

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

/* clear the file contents using a blocking API, before commit the
* nonblocking requests posted in define mode */
if (!bb_enabled) {
nerrs += clear_file_contents(ncid, varid);
}

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

nerrs += check_num_pending_reqs(ncid, nreqs, __LINE__);
err = ncmpi_wait_all(ncid, nreqs, reqs, sts);
CHECK_ERR
Expand Down Expand Up @@ -393,12 +405,24 @@ int main(int argc, char** argv)
}
err = ncmpi_enddef(ncid); CHECK_ERR

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

/* clear the file contents using a blocking API, before commit the
* nonblocking requests posted in define mode */
if (!bb_enabled) {
nerrs += clear_file_contents(ncid, varid);
}

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

nerrs += check_num_pending_reqs(ncid, nreqs, __LINE__);
err = ncmpi_wait_all(ncid, nreqs, reqs, sts);
CHECK_ERR
Expand Down Expand Up @@ -457,12 +481,24 @@ int main(int argc, char** argv)

err = ncmpi_enddef(ncid); CHECK_ERR

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

/* clear the file contents using a blocking API, before commit the
* nonblocking requests posted in define mode */
if (!bb_enabled) {
nerrs += clear_file_contents(ncid, varid);
}

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

nerrs += check_num_pending_reqs(ncid, nreqs*2, __LINE__);
err = ncmpi_wait_all(ncid, nreqs, reqs, sts);
CHECK_ERR
Expand Down Expand Up @@ -555,12 +591,24 @@ int main(int argc, char** argv)

err = ncmpi_enddef(ncid); CHECK_ERR

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

/* clear the file contents using a blocking API, before commit the
* nonblocking requests posted in define mode */
if (!bb_enabled) {
nerrs += clear_file_contents(ncid, varid);
}

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

nerrs += check_num_pending_reqs(ncid, nreqs*3, __LINE__);

/* flush nonblocking write requests */
Expand Down
12 changes: 12 additions & 0 deletions test/nonblocking/mcoll_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,12 @@ int main(int argc, char **argv)
err = ncmpi_enddef(ncid);
CHECK_ERR

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

if (k == 0) {
if (rank == 0 && verbose)
printf("*** Testing to write 2 non-record variables and 2 record variables by using ncmpi_put_vara_all() ...");
Expand All @@ -522,6 +528,12 @@ int main(int argc, char **argv)
CHECK_ERR
}
}
#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

for (i=0; i<nvars; i++){
err = ncmpi_put_vara_all(ncid, varid[i], starts[i], counts[i], buf[i], bufcounts[i], MPI_INT);
CHECK_ERR
Expand Down
12 changes: 12 additions & 0 deletions test/testcases/flexible.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ int main(int argc, char **argv) {
err = ncmpi_set_fill(ncid, NC_FILL, NULL); CHECK_ERR /* enable fill mode */
err = ncmpi_enddef(ncid); CHECK_ERR

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

/* fill 2 records with default fill values */
err = ncmpi_fill_var_rec(ncid, varid1, 0); CHECK_ERR
err = ncmpi_fill_var_rec(ncid, varid1, 1); CHECK_ERR
Expand All @@ -96,6 +102,12 @@ int main(int argc, char **argv) {
err = ncmpi_fill_var_rec(ncid, varid3, 0); CHECK_ERR
err = ncmpi_fill_var_rec(ncid, varid3, 1); CHECK_ERR

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

/* initialize the contents of the array */
for (j=0; j<NY; j++) for (i=0; i<NX; i++) buf[j][i] = j+10;

Expand Down
12 changes: 12 additions & 0 deletions test/testcases/ivarn.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ int main(int argc, char** argv)
}
err = ncmpi_enddef(ncid); CHECK_ERR

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

if (nprocs < 4) { /* need 4 processes to fill the variables */
err = ncmpi_fill_var_rec(ncid, vari0001, 0); CHECK_ERR
err = ncmpi_fill_var_rec(ncid, varr0001, 0); CHECK_ERR
Expand All @@ -217,6 +223,12 @@ int main(int argc, char** argv)
err = ncmpi_fill_var_rec(ncid, vard0002, 0); CHECK_ERR
}

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

starts = (MPI_Offset**) malloc(2 * sizeof(MPI_Offset*));
counts = (MPI_Offset**) malloc(2 * sizeof(MPI_Offset*));
starts[0] = (MPI_Offset*) calloc(2 * 2, sizeof(MPI_Offset));
Expand Down
6 changes: 6 additions & 0 deletions test/testcases/mix_collectives.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ int main(int argc, char **argv)
err = ncmpi_set_fill(ncid, NC_FILL, NULL); CHECK_ERR
err = ncmpi_enddef(ncid); CHECK_ERR

#ifdef STRONGER_CONSISTENCY
ncmpi_sync(ncid);
MPI_Barrier(MPI_COMM_WORLD);
ncmpi_sync(ncid);
#endif

for (j=0; j<6; j++) for (i=0; i<4; i++) buf[j][i] = j*4+i + rank*100;

/* now, each of 4 processes makes a call to different kinds of put APIs */
Expand Down
12 changes: 12 additions & 0 deletions test/testcases/test_vardf.F
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ program main
err = nfmpi_enddef(ncid)
call check(err, 'In nfmpi_enddef: ')

#ifdef STRONGER_CONSISTENCY
err = nfmpi_sync(ncid)
call MPI_Barrier(MPI_COMM_WORLD, ierr)
err = nfmpi_sync(ncid)
#endif

! now we are in data mode

! fill 2 records with default fill values
Expand All @@ -324,6 +330,12 @@ program main
err = nfmpi_fill_var_rec(ncid, varid2, recno)
call check(err, 'In nfmpi_fill_var_rec: varid2, 2 ')

#ifdef STRONGER_CONSISTENCY
err = nfmpi_sync(ncid)
call MPI_Barrier(MPI_COMM_WORLD, ierr)
err = nfmpi_sync(ncid)
#endif

! create a file type for the record variable */
err = nfmpi_inq_recsize(ncid, recsize)
call check(err, 'In nfmpi_inq_recsize: ')
Expand Down
10 changes: 10 additions & 0 deletions test/testcases/test_vardf90.f90
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ program main
err = nf90mpi_enddef(ncid)
call check(err, 'In nf90mpi_enddef: ')

! UnifyFS requires a stronger file consistency
err = nf90mpi_sync(ncid)
call MPI_Barrier(MPI_COMM_WORLD, err)
err = nf90mpi_sync(ncid)

! now we are in data mode

! fill 2 records with default fill values
Expand All @@ -306,6 +311,11 @@ program main
err = nf90mpi_fill_var_rec(ncid, varid2, recno)
call check(err, 'In nf90mpi_fill_var_rec: varid2, 2 ')

! UnifyFS requires a stronger file consistency
err = nf90mpi_sync(ncid)
call MPI_Barrier(MPI_COMM_WORLD, err)
err = nf90mpi_sync(ncid)

! create a file type for the record variable */
err = nf90mpi_inq_recsize(ncid, recsize)
call check(err, 'In nf90mpi_inq_recsize: ')
Expand Down
6 changes: 6 additions & 0 deletions test/testcases/tst_def_var_fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ tst_fmt(char *filename, int cmode)

err = ncmpi_enddef(ncid); CHECK_ERR

#ifdef STRONGER_CONSISTENCY
err = ncmpi_sync(ncid); CHECK_ERR
MPI_Barrier(MPI_COMM_WORLD);
err = ncmpi_sync(ncid); CHECK_ERR
#endif

/* initialize I/O buffer */
for (i=0; i<NY*NX; i++) buf[i] = rank+5;

Expand Down
10 changes: 10 additions & 0 deletions test/testcases/varn_real.f90
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ program main
err = nf90mpi_enddef(ncid)
call check(err, 'In nf90mpi_enddef: ')

! UnifyFS requires a stronger file consistency
err = nf90mpi_sync(ncid)
call MPI_Barrier(MPI_COMM_WORLD, err)
err = nf90mpi_sync(ncid)

! pick arbitrary numbers of requests for 4 processes
num_reqs = 0
if (rank .EQ. 0) then
Expand Down Expand Up @@ -231,6 +236,11 @@ program main

if (nprocs .GT. 4) call MPI_Barrier(MPI_COMM_WORLD, err)

! UnifyFS requires a stronger file consistency
err = nf90mpi_sync(ncid)
call MPI_Barrier(MPI_COMM_WORLD, err)
err = nf90mpi_sync(ncid)

! read a scalar back and check the content
oneReal = -1.0 ! a scalar
if (rank .GE. 4) starts = 1_MPI_OFFSET_KIND
Expand Down

0 comments on commit ae502a9

Please sign in to comment.