Commit c1a3c229 authored by Junchao Zhang's avatar Junchao Zhang
Browse files

Improve MPI_T error handling



Move error checking from critical paths. Fixes #1978
Signed-off-by: default avatarAntonio J. Pena <apenya@mcs.anl.gov>
parent 84ef4e85
......@@ -241,7 +241,7 @@ int MPI_T_pvar_read(MPI_T_pvar_session session, MPI_T_pvar_handle handle, void *
int mpi_errno = MPI_SUCCESS;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_READ);
MPIR_T_FAIL_IF_UNINITIALIZED();
MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
MPIR_T_THREAD_CS_ENTER();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_PVAR_READ);
......@@ -250,9 +250,15 @@ int MPI_T_pvar_read(MPI_T_pvar_session session, MPI_T_pvar_handle handle, void *
{
MPID_BEGIN_ERROR_CHECKS
{
MPIR_ERRTEST_ARGNULL(session, "session", mpi_errno);
MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
MPIR_ERRTEST_PVAR_SESSION(session, mpi_errno);
MPIR_ERRTEST_PVAR_HANDLE(handle, mpi_errno);
MPIR_ERRTEST_ARGNULL(buf, "buf", mpi_errno);
if (handle == MPI_T_PVAR_ALL_HANDLES || session != handle->session
|| !MPIR_T_pvar_is_oncestarted(handle))
{
mpi_errno = MPI_T_ERR_INVALID_HANDLE;
goto fn_fail;
}
}
MPID_END_ERROR_CHECKS
}
......@@ -260,13 +266,6 @@ int MPI_T_pvar_read(MPI_T_pvar_session session, MPI_T_pvar_handle handle, void *
/* ... body of routine ... */
if (handle == MPI_T_PVAR_ALL_HANDLES || session != handle->session
|| !MPIR_T_pvar_is_oncestarted(handle))
{
mpi_errno = MPI_T_ERR_INVALID_HANDLE;
goto fn_fail;
}
mpi_errno = MPIR_T_pvar_read_impl(session, handle, buf);
if (mpi_errno) goto fn_fail;
......
......@@ -75,7 +75,7 @@ int MPI_T_pvar_readreset(MPI_T_pvar_session session, MPI_T_pvar_handle handle, v
int mpi_errno = MPI_SUCCESS;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_READRESET);
MPIR_T_FAIL_IF_UNINITIALIZED();
MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
MPIR_T_THREAD_CS_ENTER();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_PVAR_READRESET);
......@@ -84,9 +84,21 @@ int MPI_T_pvar_readreset(MPI_T_pvar_session session, MPI_T_pvar_handle handle, v
{
MPID_BEGIN_ERROR_CHECKS
{
MPIR_ERRTEST_ARGNULL(session, "session", mpi_errno);
MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
MPIR_ERRTEST_PVAR_SESSION(session, mpi_errno);
MPIR_ERRTEST_PVAR_HANDLE(handle, mpi_errno);
MPIR_ERRTEST_ARGNULL(buf, "buf", mpi_errno);
if (handle == MPI_T_PVAR_ALL_HANDLES || session != handle->session
|| !MPIR_T_pvar_is_oncestarted(handle))
{
mpi_errno = MPI_T_ERR_INVALID_HANDLE;
goto fn_fail;
}
if (!MPIR_T_pvar_is_atomic(handle))
{
mpi_errno = MPI_T_ERR_PVAR_NO_ATOMIC;
goto fn_fail;
}
}
MPID_END_ERROR_CHECKS
}
......@@ -94,18 +106,6 @@ int MPI_T_pvar_readreset(MPI_T_pvar_session session, MPI_T_pvar_handle handle, v
/* ... body of routine ... */
if (handle == MPI_T_PVAR_ALL_HANDLES || session != handle->session
|| !MPIR_T_pvar_is_oncestarted(handle))
{
mpi_errno = MPI_T_ERR_INVALID_HANDLE;
goto fn_fail;
}
if (!MPIR_T_pvar_is_atomic(handle)) {
mpi_errno = MPI_T_ERR_PVAR_NO_ATOMIC;
goto fn_fail;
}
mpi_errno = MPIR_T_pvar_readreset_impl(session, handle, buf);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
......
......@@ -108,7 +108,7 @@ int MPI_T_pvar_reset(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
int mpi_errno = MPI_SUCCESS;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_RESET);
MPIR_T_FAIL_IF_UNINITIALIZED();
MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
MPIR_T_THREAD_CS_ENTER();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_PVAR_RESET);
......@@ -117,8 +117,8 @@ int MPI_T_pvar_reset(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
{
MPID_BEGIN_ERROR_CHECKS
{
MPIR_ERRTEST_ARGNULL(session, "session", mpi_errno);
MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
MPIR_ERRTEST_PVAR_SESSION(session, mpi_errno);
MPIR_ERRTEST_PVAR_HANDLE(handle, mpi_errno);
}
MPID_END_ERROR_CHECKS
}
......
......@@ -40,6 +40,10 @@ int MPIR_T_pvar_session_create_impl(MPI_T_pvar_session *session)
/* essential for utlist to work */
(*session)->hlist = NULL;
#ifdef HAVE_ERROR_CHECKING
(*session)->kind = MPIR_T_PVAR_SESSION;
#endif
MPIU_CHKPMEM_COMMIT();
fn_exit:
return mpi_errno;
......@@ -72,7 +76,7 @@ int MPI_T_pvar_session_create(MPI_T_pvar_session *session)
int mpi_errno = MPI_SUCCESS;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_SESSION_CREATE);
MPIR_T_FAIL_IF_UNINITIALIZED();
MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
MPIR_T_THREAD_CS_ENTER();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_PVAR_SESSION_CREATE);
......
......@@ -82,7 +82,7 @@ int MPI_T_pvar_session_free(MPI_T_pvar_session *session)
int mpi_errno = MPI_SUCCESS;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_SESSION_FREE);
MPIR_T_FAIL_IF_UNINITIALIZED();
MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
MPIR_T_THREAD_CS_ENTER();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_PVAR_SESSION_FREE);
......
......@@ -106,7 +106,7 @@ int MPI_T_pvar_start(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
int mpi_errno = MPI_SUCCESS;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_START);
MPIR_T_FAIL_IF_UNINITIALIZED();
MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
MPIR_T_THREAD_CS_ENTER();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_PVAR_START);
......@@ -115,8 +115,8 @@ int MPI_T_pvar_start(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
{
MPID_BEGIN_ERROR_CHECKS
{
MPIR_ERRTEST_ARGNULL(session, "session", mpi_errno);
MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
MPIR_ERRTEST_PVAR_SESSION(session, mpi_errno);
MPIR_ERRTEST_PVAR_HANDLE(handle, mpi_errno);
}
MPID_END_ERROR_CHECKS
}
......
......@@ -135,7 +135,7 @@ int MPI_T_pvar_stop(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
int mpi_errno = MPI_SUCCESS;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_STOP);
MPIR_T_FAIL_IF_UNINITIALIZED();
MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
MPIR_T_THREAD_CS_ENTER();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_PVAR_STOP);
......@@ -144,8 +144,8 @@ int MPI_T_pvar_stop(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
{
MPID_BEGIN_ERROR_CHECKS
{
MPIR_ERRTEST_ARGNULL(session, "session", mpi_errno);
MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
MPIR_ERRTEST_PVAR_SESSION(session, mpi_errno);
MPIR_ERRTEST_PVAR_HANDLE(handle, mpi_errno);
}
MPID_END_ERROR_CHECKS
}
......
......@@ -73,7 +73,7 @@ int MPI_T_pvar_write(MPI_T_pvar_session session, MPI_T_pvar_handle handle, void
int mpi_errno = MPI_SUCCESS;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_WRITE);
MPIR_T_FAIL_IF_UNINITIALIZED();
MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
MPIR_T_THREAD_CS_ENTER();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_PVAR_WRITE);
......@@ -82,9 +82,13 @@ int MPI_T_pvar_write(MPI_T_pvar_session session, MPI_T_pvar_handle handle, void
{
MPID_BEGIN_ERROR_CHECKS
{
MPIR_ERRTEST_ARGNULL(session, "session", mpi_errno);
MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
MPIR_ERRTEST_PVAR_SESSION(session, mpi_errno);
MPIR_ERRTEST_PVAR_HANDLE(handle, mpi_errno);
MPIR_ERRTEST_ARGNULL(buf, "buf", mpi_errno);
if (handle == MPI_T_PVAR_ALL_HANDLES || handle->session != session) {
mpi_errno = MPI_T_ERR_INVALID_HANDLE;
goto fn_fail;
}
}
MPID_END_ERROR_CHECKS
}
......@@ -92,10 +96,7 @@ int MPI_T_pvar_write(MPI_T_pvar_session session, MPI_T_pvar_handle handle, void
/* ... body of routine ... */
if (handle == MPI_T_PVAR_ALL_HANDLES || handle->session != session) {
mpi_errno = MPI_T_ERR_INVALID_HANDLE;
goto fn_fail;
} if (MPIR_T_pvar_is_readonly(handle)) {
if (MPIR_T_pvar_is_readonly(handle)) {
mpi_errno = MPI_T_ERR_PVAR_NO_WRITE;
goto fn_fail;
} else {
......
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