Commit 011f107a authored by David Goodell's avatar David Goodell
Browse files

[svn-r10799] ROMIO: check whether datatypes are committed

This only works when ROMIO is built with MPICH.

Based on patch 0001 from the second round of IBM's error checking
patches.  Replaces 0008 from the first round.
parent 6aab201f
......@@ -49,4 +49,30 @@ void MPIR_Ext_cs_exit_allfunc(void)
MPIU_THREAD_CS_EXIT(ALLFUNC,);
}
/* will consider MPI_DATATYPE_NULL to be an error */
#undef FUNCNAME
#define FUNCNAME MPIR_Ext_datatype_iscommitted
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIR_Ext_datatype_iscommitted(MPI_Datatype datatype)
{
int mpi_errno = MPI_SUCCESS;
MPIR_ERRTEST_DATATYPE(datatype, "datatype", mpi_errno);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
if (HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN) {
MPID_Datatype *datatype_ptr = NULL;
MPID_Datatype_get_ptr(datatype, datatype_ptr);
MPID_Datatype_valid_ptr(datatype_ptr, mpi_errno);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPID_Datatype_committed_ptr(datatype_ptr, mpi_errno);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
fn_fail:
return mpi_errno;
}
......@@ -53,6 +53,9 @@ int MPIR_Ext_init(void);
void MPIR_Ext_cs_enter_allfunc(void);
void MPIR_Ext_cs_exit_allfunc(void);
/* to facilitate error checking */
int MPIR_Ext_datatype_iscommitted(MPI_Datatype datatype);
/* prototypes for the mem tracing routines */
void *MPIU_trmalloc(size_t a, int lineno, const char fname[]);
void MPIU_trfree(void *a_ptr, int line, const char fname[]);
......
......@@ -324,3 +324,4 @@ void MPIR_DatatypeAttrFinalize( void )
MPIR_FINALIZE_CALLBACK_PRIO-1);
}
}
......@@ -58,16 +58,23 @@ if (count*datatype_size != (ADIO_Offset)(unsigned)count*(ADIO_Offset)(unsigned)d
goto fn_exit; \
}
#define MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code) \
if (datatype == MPI_DATATYPE_NULL) { \
error_code = MPIO_Err_create_code(MPI_SUCCESS, \
MPIR_ERR_RECOVERABLE, \
myname, __LINE__, \
MPI_ERR_TYPE, \
"**dtypenull", 0); \
error_code = MPIO_Err_return_file(fh, error_code); \
goto fn_exit; \
}
#define MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code) \
do { \
if (datatype == MPI_DATATYPE_NULL) { \
error_code = MPIO_Err_create_code(MPI_SUCCESS, \
MPIR_ERR_RECOVERABLE, \
myname, __LINE__, \
MPI_ERR_TYPE, \
"**dtypenull", 0); \
} \
else { \
MPIO_DATATYPE_ISCOMMITTED(datatype, error_code); \
} \
if (error_code != MPI_SUCCESS) { \
error_code = MPIO_Err_return_file(fh, error_code); \
goto fn_exit; \
} \
} while (0)
#define MPIO_CHECK_READABLE(fh, myname, error_code) \
if (fh->access_mode & ADIO_WRONLY) { \
......
......@@ -24,6 +24,12 @@
#define MPIU_THREAD_CS_ENTER_ALLFUNC(ctx_) MPIR_Ext_cs_enter_allfunc()
#define MPIU_THREAD_CS_EXIT_ALLFUNC(ctx_) MPIR_Ext_cs_exit_allfunc()
/* committed datatype checking support in ROMIO */
#define MPIO_DATATYPE_ISCOMMITTED(dtype_, err_) \
do { \
err_ = MPIR_Ext_datatype_iscommitted(dtype_); \
} while (0)
#else /* not ROMIO_INSIDE_MPICH */
/* Any MPI implementation that wishes to follow the thread-safety and
error reporting features provided by MPICH must implement these
......@@ -31,6 +37,7 @@
of correct programs */
#define MPIU_THREAD_CS_ENTER(x,y)
#define MPIU_THREAD_CS_EXIT(x,y)
#define MPIO_DATATYPE_ISCOMMITTED(dtype_, err_) do {} while (0)
#ifdef HAVE_WINDOWS_H
#define MPIU_UNREFERENCED_ARG(a) a
#else
......
......@@ -68,6 +68,11 @@ int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype,
error_code = MPIO_Err_return_file(adio_fh, error_code);
goto fn_exit;
}
MPIO_DATATYPE_ISCOMMITTED(etype, error_code);
if (error_code != MPI_SUCCESS) {
error_code = MPIO_Err_return_file(adio_fh, error_code);
goto fn_exit;
}
if (filetype == MPI_DATATYPE_NULL) {
error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
......@@ -76,6 +81,11 @@ int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype,
error_code = MPIO_Err_return_file(adio_fh, error_code);
goto fn_exit;
}
MPIO_DATATYPE_ISCOMMITTED(filetype, error_code);
if (error_code != MPI_SUCCESS) {
error_code = MPIO_Err_return_file(adio_fh, error_code);
goto fn_exit;
}
if ((adio_fh->access_mode & MPI_MODE_SEQUENTIAL) &&
(disp != MPI_DISPLACEMENT_CURRENT))
......@@ -102,7 +112,7 @@ int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype,
MPI_Type_size(etype, &etype_size);
/* --BEGIN ERROR HANDLING-- */
if (filetype_size % etype_size != 0)
if (etype_size != 0 && filetype_size % etype_size != 0)
{
error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
myname, __LINE__, MPI_ERR_ARG,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment