Skip to content

Commit

Permalink
Skip MPI communication for error code checking when PnetCDF is used
Browse files Browse the repository at this point in the history
Note PnetCDF always keeps metadata consistent among all MPI ranks.
  • Loading branch information
wkliao committed Jul 19, 2024
1 parent 02e865e commit af98ceb
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/clib/pio_nc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,17 @@ int PIOc_inq_unlimdims_impl(int ncid, int *nunlimdimsp, int *unlimdimidsp)
#endif

/* A failure to inquire is not fatal */
mpierr = MPI_Allreduce(MPI_IN_PLACE, &ierr, 1, MPI_INT, MPI_BOR, ios->my_comm);
if (file->iotype != PIO_IOTYPE_PNETCDF) {
/* Skip MPI communication for checking error code, because PnetCDF
* always keeps metadata consistent among all ranks.
*/
mpierr = MPI_Allreduce(MPI_IN_PLACE, &ierr, 1, MPI_INT, MPI_BOR, ios->my_comm);

if(mpierr != MPI_SUCCESS){
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
if(mpierr != MPI_SUCCESS){
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
}
}

if(ierr != PIO_NOERR){
Expand All @@ -484,6 +489,12 @@ int PIOc_inq_unlimdims_impl(int ncid, int *nunlimdimsp, int *unlimdimidsp)
return ierr;
}

/* Skip MPI communications below, because PnetCDF always keeps metadata
* consistent among all ranks.
*/
if (file->iotype == PIO_IOTYPE_PNETCDF)
goto fn_exit;

/* Broadcast results to all tasks. Ignore NULL parameters. */
if ((mpierr = MPI_Bcast(&tmp_nunlimdims, 1, MPI_INT, ios->ioroot, ios->my_comm)))
{
Expand All @@ -508,6 +519,7 @@ int PIOc_inq_unlimdims_impl(int ncid, int *nunlimdimsp, int *unlimdimidsp)
return check_mpi(NULL, file, mpierr, __FILE__, __LINE__);
}

fn_exit:
spio_ltimer_stop(ios->io_fstats->tot_timer_name);
spio_ltimer_stop(file->io_fstats->tot_timer_name);
return PIO_NOERR;
Expand Down

0 comments on commit af98ceb

Please sign in to comment.