Skip to content

Commit

Permalink
further development of async code
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed May 17, 2016
1 parent 68c3068 commit 5f597a8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/clib/pio_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ typedef struct pio_swapm_defaults
void flush_buffer(int ncid, wmulti_buffer *wmb, bool flushtodisk);
void piomemerror(iosystem_desc_t ios, size_t req, char *fname, const int line);
void compute_maxaggregate_bytes(const iosystem_desc_t ios, io_desc_t *iodesc);
void check_mpi(file_desc_t *file, const int mpierr, const char *filename,
const int line);
int check_mpi(file_desc_t *file, const int mpierr, const char *filename,
const int line);

#ifdef BGQ
void identity(MPI_Comm comm, int *iotask);
Expand Down
42 changes: 16 additions & 26 deletions src/clib/pio_nc_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ int PIOc_inq(int ncid, int *ndimsp, int *nvarsp, int *ngattsp,
mpierr = MPI_Bcast(&ngatts_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm);
if (!mpierr)
mpierr = MPI_Bcast(&unlimdimid_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm);
LOG((2, "PIOc_inq netcdf Bcast unlimdimid_present = %d", unlimdimid_present));
}

/* Handle MPI errors. */
if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr2, __FILE__, __LINE__);
return check_mpi(file, mpierr2, __FILE__, __LINE__);
check_mpi(file, mpierr, __FILE__, __LINE__);
}

Expand Down Expand Up @@ -114,30 +113,27 @@ int PIOc_inq(int ncid, int *ndimsp, int *nvarsp, int *ngattsp,

/* Broadcast and check the return code. */
if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
{
check_mpi(file, mpierr, __FILE__, __LINE__);
return PIO_EIO;
}
return check_mpi(file, mpierr, __FILE__, __LINE__);
check_netcdf(file, ierr, __FILE__, __LINE__);

/* Broadcast results to all tasks. Ignore NULL parameters. */
if (!ierr)
{
if (ndimsp)
if ((mpierr = MPI_Bcast(ndimsp, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
return check_mpi(file, mpierr, __FILE__, __LINE__);

if (nvarsp)
if ((mpierr = MPI_Bcast(nvarsp, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
return check_mpi(file, mpierr, __FILE__, __LINE__);

if (ngattsp)
if ((mpierr = MPI_Bcast(ngattsp, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
return check_mpi(file, mpierr, __FILE__, __LINE__);

if (unlimdimidp)
if ((mpierr = MPI_Bcast(unlimdimidp, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
return check_mpi(file, mpierr, __FILE__, __LINE__);
}

return ierr;
Expand Down Expand Up @@ -225,7 +221,6 @@ int pioc_pnetcdf_inq_type(int ncid, nc_type xtype, char *name,
*/
int PIOc_inq_type(int ncid, nc_type xtype, char *name, PIO_Offset *sizep)
{
int msg = PIO_MSG_INQ_TYPE; /** Message for async notification. */
iosystem_desc_t *ios; /** Pointer to io system information. */
file_desc_t *file; /** Pointer to file information. */
int ierr = PIO_NOERR; /** Return code from function calls. */
Expand All @@ -244,6 +239,7 @@ int PIOc_inq_type(int ncid, nc_type xtype, char *name, PIO_Offset *sizep)
{
if (!ios->ioproc)
{
int msg = PIO_MSG_INQ_TYPE; /** Message for async notification. */
char name_present = name ? true : false;
char size_present = sizep ? true : false;

Expand All @@ -262,7 +258,7 @@ int PIOc_inq_type(int ncid, nc_type xtype, char *name, PIO_Offset *sizep)

/* Handle MPI errors. */
if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr2, __FILE__, __LINE__);
return check_mpi(file, mpierr2, __FILE__, __LINE__);
check_mpi(file, mpierr, __FILE__, __LINE__);
}

Expand All @@ -282,10 +278,7 @@ int PIOc_inq_type(int ncid, nc_type xtype, char *name, PIO_Offset *sizep)

/* Broadcast and check the return code. */
if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
{
check_mpi(file, mpierr, __FILE__, __LINE__);
return PIO_EIO;
}
return check_mpi(file, mpierr, __FILE__, __LINE__);
check_netcdf(file, ierr, __FILE__, __LINE__);

/* Broadcast results to all tasks. Ignore NULL parameters. */
Expand All @@ -297,13 +290,13 @@ int PIOc_inq_type(int ncid, nc_type xtype, char *name, PIO_Offset *sizep)
if (ios->iomaster)
slen = strlen(name);
if ((mpierr = MPI_Bcast(&slen, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
return check_mpi(file, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast((void *)name, slen + 1, MPI_CHAR, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
return check_mpi(file, mpierr, __FILE__, __LINE__);
}
if (sizep)
if ((mpierr = MPI_Bcast(sizep , 1, MPI_OFFSET, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
return check_mpi(file, mpierr, __FILE__, __LINE__);
}

return ierr;
Expand Down Expand Up @@ -339,14 +332,14 @@ int PIOc_inq_format (int ncid, int *formatp)
mpierr = MPI_Send(&msg, 1,MPI_INT, ios->ioroot, 1, ios->union_comm);

if (!mpierr)
mpierr = MPI_Bcast(&(file->fh),1, MPI_INT, ios->compmaster, ios->intercomm);
mpierr = MPI_Bcast(&file->fh, 1, MPI_INT, ios->compmaster, ios->intercomm);
if (!mpierr)
mpierr = MPI_Bcast(&format_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm);
}

/* Handle MPI errors. */
if ((mpierr2 = MPI_Bcast(&mpierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr2, __FILE__, __LINE__);
return check_mpi(file, mpierr2, __FILE__, __LINE__);
check_mpi(file, mpierr, __FILE__, __LINE__);
}

Expand All @@ -366,18 +359,15 @@ int PIOc_inq_format (int ncid, int *formatp)

/* Broadcast and check the return code. */
if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
{
check_mpi(file, mpierr, __FILE__, __LINE__);
return PIO_EIO;
}
return check_mpi(file, mpierr, __FILE__, __LINE__);
check_netcdf(file, ierr, __FILE__, __LINE__);

/* Broadcast results to all tasks. Ignore NULL parameters. */
if (!ierr)
{
if (formatp)
if ((mpierr = MPI_Bcast(formatp , 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
return check_mpi(file, mpierr, __FILE__, __LINE__);
}

return ierr;
Expand Down
5 changes: 4 additions & 1 deletion src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ void pioassert(_Bool expression, const char *msg, const char *fname, const int l
@param mpierr the MPI return code to handle
@param filename the name of the code file where error occured.
@param line the line of code where error occured.
@return PIO_NOERR for no error, otherwise PIO_EIO.
*/
void check_mpi(file_desc_t *file, const int mpierr, const char *filename,
int check_mpi(file_desc_t *file, const int mpierr, const char *filename,
const int line)
{
if (mpierr)
Expand All @@ -209,7 +210,9 @@ void check_mpi(file_desc_t *file, const int mpierr, const char *filename,

/* Handle all MPI errors as PIO_EIO. */
check_netcdf(file, PIO_EIO, filename, line);
return PIO_EIO;
}
return PIO_NOERR;
}

/** Check the result of a netCDF API call.
Expand Down

0 comments on commit 5f597a8

Please sign in to comment.