[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.1rc2-5-g50161f3

mysql vizuser noreply at mpich.org
Mon Nov 18 21:06:50 CST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".

The branch, master has been updated
       via  50161f32d8406005d590f4f95de80be0d4dd1494 (commit)
       via  c1a3c2292501e17e0f35ac5a0453c0e9cdd2d833 (commit)
       via  84ef4e85691d74e63dec5c1959e6e63b9d8cb0b0 (commit)
       via  02da81ee286769c7089bf911b51934a43fb090d5 (commit)
      from  be7e350efaa610fefe575c1b418b16b60764c892 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/50161f32d8406005d590f4f95de80be0d4dd1494

commit 50161f32d8406005d590f4f95de80be0d4dd1494
Author: Junchao Zhang <jczhang at mcs.anl.gov>
Date:   Fri Nov 15 20:18:00 2013 -0600

    Revise the test to add MPI_T_PVAR_ALL_HANDLES
    
    Signed-off-by: Antonio J. Pena <apenya at mcs.anl.gov>

diff --git a/test/mpi/mpi_t/mpit_vars.c b/test/mpi/mpi_t/mpit_vars.c
index 3efd84e..ced40a7 100644
--- a/test/mpi/mpi_t/mpit_vars.c
+++ b/test/mpi/mpi_t/mpit_vars.c
@@ -518,6 +518,8 @@ int perfvarReadInt(int pvarIndex, int isContinuous, int *found)
     MPI_T_pvar_handle pvarHandle;
     MPI_T_pvar_session_create(&session);
     MPI_T_pvar_handle_alloc(session, pvarIndex, NULL, &pvarHandle, &count);
+    MPI_T_pvar_start(session, MPI_T_PVAR_ALL_HANDLES);
+    MPI_T_pvar_stop(session, MPI_T_PVAR_ALL_HANDLES);
     if (count == 1) {
         *found = 1;
         if (!isContinuous) {
@@ -554,6 +556,8 @@ unsigned int perfvarReadUint(int pvarIndex, int isContinuous, int *found)
     *found = 0;
     MPI_T_pvar_session_create(&session);
     MPI_T_pvar_handle_alloc(session, pvarIndex, NULL, &pvarHandle, &count);
+    MPI_T_pvar_start(session, MPI_T_PVAR_ALL_HANDLES);
+    MPI_T_pvar_stop(session, MPI_T_PVAR_ALL_HANDLES);
     if (count == 1) {
         *found = 1;
         if (!isContinuous) {
@@ -589,6 +593,8 @@ double perfvarReadDouble(int pvarIndex, int isContinuous, int *found)
     *found = 0;
     MPI_T_pvar_session_create(&session);
     MPI_T_pvar_handle_alloc(session, pvarIndex, NULL, &pvarHandle, &count);
+    MPI_T_pvar_start(session, MPI_T_PVAR_ALL_HANDLES);
+    MPI_T_pvar_stop(session, MPI_T_PVAR_ALL_HANDLES);
     if (count == 1) {
         *found = 1;
         if (!isContinuous) {

http://git.mpich.org/mpich.git/commitdiff/c1a3c2292501e17e0f35ac5a0453c0e9cdd2d833

commit c1a3c2292501e17e0f35ac5a0453c0e9cdd2d833
Author: Junchao Zhang <jczhang at mcs.anl.gov>
Date:   Fri Nov 15 20:21:14 2013 -0600

    Improve MPI_T error handling
    
    Move error checking from critical paths. Fixes #1978
    
    Signed-off-by: Antonio J. Pena <apenya at mcs.anl.gov>

diff --git a/src/include/mpitimpl.h b/src/include/mpitimpl.h
index 7feedc0..9763e6f 100644
--- a/src/include/mpitimpl.h
+++ b/src/include/mpitimpl.h
@@ -15,6 +15,16 @@
 #include "mpiu_uthash.h"
 #include "mpiimplthread.h" /* For MPICH_IS_THREADED */
 
+#ifdef HAVE_ERROR_CHECKING
+typedef enum {
+    MPIR_T_OBJECT_INVALID = 0,
+    MPIR_T_ENUM_HANDLE,
+    MPIR_T_CVAR_HANDLE,
+    MPIR_T_PVAR_HANDLE,
+    MPIR_T_PVAR_SESSION
+} MPIR_T_object_kind;
+#endif
+
 /* MPI_T enum
  */
 typedef struct enum_item_s {
@@ -23,6 +33,9 @@ typedef struct enum_item_s {
 } enum_item_t;
 
 typedef struct MPIR_T_enum_s {
+#ifdef HAVE_ERROR_CHECKING
+    MPIR_T_object_kind kind;
+#endif
     const char *name;
     UT_array *items;
 } MPIR_T_enum_t;
@@ -102,6 +115,10 @@ typedef struct cvar_table_entry_s {
 } cvar_table_entry_t;
 
 typedef struct MPIR_T_cvar_handle_s {
+#ifdef HAVE_ERROR_CHECKING
+    MPIR_T_object_kind kind;
+#endif
+
      /* Address and count of the cvar. Set at handle allocation time */
     void *addr;
     int count;
@@ -257,6 +274,10 @@ typedef struct {
 } MPIR_T_pvar_watermark_t;
 
 typedef struct MPIR_T_pvar_handle_s {
+#ifdef HAVE_ERROR_CHECKING
+    MPIR_T_object_kind kind;
+#endif
+
     /* These are cached fields from pvar table. Do so to avoid extra
      * indirection when accessing them through pvar handles.
      */
@@ -315,6 +336,10 @@ typedef struct MPIR_T_pvar_handle_s {
 } MPIR_T_pvar_handle_t;
 
 typedef struct MPIR_T_pvar_session_s {
+#ifdef HAVE_ERROR_CHECKING
+    MPIR_T_object_kind kind;
+#endif
+
     /* A linked list of pvar handles */
     MPIR_T_pvar_handle_t *hlist;
 } MPIR_T_pvar_session_t;
@@ -1393,12 +1418,4 @@ extern MPIU_Thread_mutex_t mpi_t_mutex;
 extern void MPIR_T_env_init(void);
 extern void MPIR_T_env_finalize(void);
 
-#define MPIR_T_FAIL_IF_UNINITIALIZED() \
-    do { \
-        if (!MPIR_T_is_initialized()) { \
-            mpi_errno = MPI_T_ERR_NOT_INITIALIZED; \
-            goto fn_fail; \
-        } \
-    } while (0)
-
 #endif
diff --git a/src/mpi_t/cat_changed.c b/src/mpi_t/cat_changed.c
index 9717d76..27f8746 100644
--- a/src/mpi_t/cat_changed.c
+++ b/src/mpi_t/cat_changed.c
@@ -49,14 +49,24 @@ int MPI_T_category_changed(int *stamp)
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CATEGORY_CHANGED);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_CATEGORY_CHANGED);
 
+    /* Validate parameters */
+#   ifdef HAVE_ERROR_CHECKING
+    {
+        MPID_BEGIN_ERROR_CHECKS
+        {
+            MPIR_ERRTEST_ARGNULL(stamp, "stamp", mpi_errno);
+        }
+        MPID_END_ERROR_CHECKS
+    }
+#   endif /* HAVE_ERROR_CHECKING */
+
     /* ... body of routine ...  */
 
-    if (stamp != NULL)
-        *stamp = cat_stamp;
+    *stamp = cat_stamp;
 
     /* ... end of body of routine ... */
 
diff --git a/src/mpi_t/cat_get_categories.c b/src/mpi_t/cat_get_categories.c
index 743f5cb..fae2981 100644
--- a/src/mpi_t/cat_get_categories.c
+++ b/src/mpi_t/cat_get_categories.c
@@ -76,7 +76,7 @@ int MPI_T_category_get_categories(int cat_index, int len, int indices[])
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CATEGORY_GET_CATEGORIES);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_CATEGORY_GET_CATEGORIES);
 
@@ -85,6 +85,7 @@ int MPI_T_category_get_categories(int cat_index, int len, int indices[])
     {
         MPID_BEGIN_ERROR_CHECKS
         {
+            MPIR_ERRTEST_CAT_INDEX(cat_index, mpi_errno);
             if (len != 0)
                 MPIR_ERRTEST_ARGNULL(indices, "indices", mpi_errno);
         }
@@ -93,10 +94,6 @@ int MPI_T_category_get_categories(int cat_index, int len, int indices[])
 #   endif /* HAVE_ERROR_CHECKING */
 
     /* ... body of routine ...  */
-    if (cat_index < 0 || cat_index >= utarray_len(cat_table)) {
-        mpi_errno = MPI_T_ERR_INVALID_INDEX;
-        goto fn_fail;
-    }
 
     if (len == 0) goto fn_exit;
 
diff --git a/src/mpi_t/cat_get_cvars.c b/src/mpi_t/cat_get_cvars.c
index b1f4f98..61450f4 100644
--- a/src/mpi_t/cat_get_cvars.c
+++ b/src/mpi_t/cat_get_cvars.c
@@ -76,7 +76,7 @@ int MPI_T_category_get_cvars(int cat_index, int len, int indices[])
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CATEGORY_GET_CVARS);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_CATEGORY_GET_CVARS);
 
@@ -85,6 +85,7 @@ int MPI_T_category_get_cvars(int cat_index, int len, int indices[])
     {
         MPID_BEGIN_ERROR_CHECKS
         {
+            MPIR_ERRTEST_CAT_INDEX(cat_index, mpi_errno);
             if (len != 0)
                 MPIR_ERRTEST_ARGNULL(indices, "indices", mpi_errno);
         }
@@ -93,10 +94,6 @@ int MPI_T_category_get_cvars(int cat_index, int len, int indices[])
 #   endif /* HAVE_ERROR_CHECKING */
 
     /* ... body of routine ...  */
-    if (cat_index < 0 || cat_index >= utarray_len(cat_table)) {
-        mpi_errno = MPI_T_ERR_INVALID_INDEX;
-        goto fn_fail;
-    }
 
     if (len == 0) goto fn_exit;
 
diff --git a/src/mpi_t/cat_get_info.c b/src/mpi_t/cat_get_info.c
index a4f05d9..cf31801 100644
--- a/src/mpi_t/cat_get_info.c
+++ b/src/mpi_t/cat_get_info.c
@@ -57,7 +57,7 @@ int MPI_T_category_get_info(int cat_index, char *name, int *name_len, char *desc
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CATEGORY_GET_INFO);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_CATEGORY_GET_INFO);
 
@@ -66,7 +66,8 @@ int MPI_T_category_get_info(int cat_index, char *name, int *name_len, char *desc
     {
         MPID_BEGIN_ERROR_CHECKS
         {
-            /* Do not do _TEST_ARGNULL for any argument, since this is
+            MPIR_ERRTEST_CAT_INDEX(cat_index, mpi_errno);
+            /* Do not do _TEST_ARGNULL for other arguments, since this is
              * allowed or will be allowed by MPI_T standard.
              */
         }
@@ -75,10 +76,6 @@ int MPI_T_category_get_info(int cat_index, char *name, int *name_len, char *desc
 #   endif /* HAVE_ERROR_CHECKING */
 
     /* ... body of routine ...  */
-    if (cat_index < 0 || cat_index >= utarray_len(cat_table)) {
-        mpi_errno = MPI_T_ERR_INVALID_INDEX;
-        goto fn_fail;
-    }
 
     cat_table_entry_t *cat;
     cat = (cat_table_entry_t *)utarray_eltptr(cat_table, cat_index);
diff --git a/src/mpi_t/cat_get_num.c b/src/mpi_t/cat_get_num.c
index 3bad314..8a3efca 100644
--- a/src/mpi_t/cat_get_num.c
+++ b/src/mpi_t/cat_get_num.c
@@ -44,14 +44,24 @@ int MPI_T_category_get_num(int *num_cat)
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CATEGORY_GET_NUM);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_CATEGORY_GET_NUM);
 
+    /* Validate parameters */
+#   ifdef HAVE_ERROR_CHECKING
+    {
+        MPID_BEGIN_ERROR_CHECKS
+        {
+            MPIR_ERRTEST_ARGNULL(num_cat, "num_cat", mpi_errno);
+        }
+        MPID_END_ERROR_CHECKS
+    }
+#   endif /* HAVE_ERROR_CHECKING */
+
     /* ... body of routine ...  */
 
-    if (*num_cat)
-        *num_cat = utarray_len(cat_table);
+    *num_cat = utarray_len(cat_table);
 
     /* ... end of body of routine ... */
 
diff --git a/src/mpi_t/cat_get_pvars.c b/src/mpi_t/cat_get_pvars.c
index 7e8010c..39ed836 100644
--- a/src/mpi_t/cat_get_pvars.c
+++ b/src/mpi_t/cat_get_pvars.c
@@ -76,7 +76,7 @@ int MPI_T_category_get_pvars(int cat_index, int len, int indices[])
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CATEGORY_GET_PVARS);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_CATEGORY_GET_PVARS);
 
@@ -85,6 +85,7 @@ int MPI_T_category_get_pvars(int cat_index, int len, int indices[])
     {
         MPID_BEGIN_ERROR_CHECKS
         {
+            MPIR_ERRTEST_CAT_INDEX(cat_index, mpi_errno);
             if (len != 0)
                 MPIR_ERRTEST_ARGNULL(indices, "indices", mpi_errno);
         }
@@ -93,10 +94,6 @@ int MPI_T_category_get_pvars(int cat_index, int len, int indices[])
 #   endif /* HAVE_ERROR_CHECKING */
 
     /* ... body of routine ...  */
-    if (cat_index < 0 || cat_index >= utarray_len(cat_table)) {
-        mpi_errno = MPI_T_ERR_INVALID_INDEX;
-        goto fn_fail;
-    }
 
     if (len == 0) goto fn_exit;
 
diff --git a/src/mpi_t/cvar_get_info.c b/src/mpi_t/cvar_get_info.c
index 1c5ca38..31ec7b1 100644
--- a/src/mpi_t/cvar_get_info.c
+++ b/src/mpi_t/cvar_get_info.c
@@ -60,7 +60,7 @@ int MPI_T_cvar_get_info(int cvar_index, char *name, int *name_len,
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CVAR_GET_INFO);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_CVAR_GET_INFO);
 
@@ -69,6 +69,7 @@ int MPI_T_cvar_get_info(int cvar_index, char *name, int *name_len,
     {
         MPID_BEGIN_ERROR_CHECKS
         {
+            MPIR_ERRTEST_CVAR_INDEX(cvar_index, mpi_errno);
             /* Do not do *_TEST_ARGNULL for pointer arguments, since this is
              * allowed or will be allowed by MPI_T standard.
              */
@@ -78,10 +79,6 @@ int MPI_T_cvar_get_info(int cvar_index, char *name, int *name_len,
 #   endif /* HAVE_ERROR_CHECKING */
 
     /* ... body of routine ...  */
-    if (cvar_index < 0 || cvar_index >= utarray_len(cvar_table)) {
-        mpi_errno = MPI_T_ERR_INVALID_INDEX;
-        goto fn_fail;
-    }
 
     const cvar_table_entry_t *cvar;
     cvar = (cvar_table_entry_t *)utarray_eltptr(cvar_table, cvar_index);
diff --git a/src/mpi_t/cvar_get_num.c b/src/mpi_t/cvar_get_num.c
index 958f18a..0ff8aab 100644
--- a/src/mpi_t/cvar_get_num.c
+++ b/src/mpi_t/cvar_get_num.c
@@ -44,14 +44,25 @@ int MPI_T_cvar_get_num(int *num_cvar)
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CVAR_GET_NUM);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_CVAR_GET_NUM);
 
+    /* Validate parameters */
+#   ifdef HAVE_ERROR_CHECKING
+    {
+        MPID_BEGIN_ERROR_CHECKS
+        {
+            MPIR_ERRTEST_ARGNULL(num_cvar, "num_cvar", mpi_errno);
+        }
+        MPID_END_ERROR_CHECKS
+    }
+#   endif /* HAVE_ERROR_CHECKING */
+
+
     /* ... body of routine ...  */
 
-    if (num_cvar != NULL)
-        *num_cvar = utarray_len(cvar_table);
+    *num_cvar = utarray_len(cvar_table);
 
     /* ... end of body of routine ... */
 
diff --git a/src/mpi_t/cvar_handle_alloc.c b/src/mpi_t/cvar_handle_alloc.c
index c9ac07d..9232915 100644
--- a/src/mpi_t/cvar_handle_alloc.c
+++ b/src/mpi_t/cvar_handle_alloc.c
@@ -39,6 +39,9 @@ int MPIR_T_cvar_handle_alloc_impl(int cvar_index, void *obj_handle, MPI_T_cvar_h
 
     /* Allocate handle memory */
     MPIU_CHKPMEM_MALLOC(hnd, MPIR_T_cvar_handle_t*, sizeof(*hnd), mpi_errno, "control variable handle");
+#ifdef HAVE_ERROR_CHECKING
+    hnd->kind = MPIR_T_CVAR_HANDLE;
+#endif
 
     /* It is time to fix addr and count if they are unknown */
     if (cvar->get_count != NULL)
@@ -98,7 +101,7 @@ int MPI_T_cvar_handle_alloc(int cvar_index, void *obj_handle, MPI_T_cvar_handle
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CVAR_HANDLE_ALLOC);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_CVAR_HANDLE_ALLOC);
 
@@ -107,6 +110,9 @@ int MPI_T_cvar_handle_alloc(int cvar_index, void *obj_handle, MPI_T_cvar_handle
     {
         MPID_BEGIN_ERROR_CHECKS
         {
+            MPIR_ERRTEST_CVAR_INDEX(cvar_index, mpi_errno);
+            /* obj_handle is ignored if cvar has no binding, so no
+               TEST_ARGNULL for it */
             MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
             MPIR_ERRTEST_ARGNULL(count, "count", mpi_errno);
         }
@@ -115,10 +121,6 @@ int MPI_T_cvar_handle_alloc(int cvar_index, void *obj_handle, MPI_T_cvar_handle
 #   endif /* HAVE_ERROR_CHECKING */
 
     /* ... body of routine ...  */
-    if (cvar_index < 0 || cvar_index >= utarray_len(cvar_table)) {
-        mpi_errno = MPI_T_ERR_INVALID_INDEX;
-        goto fn_fail;
-    }
 
     mpi_errno = MPIR_T_cvar_handle_alloc_impl(cvar_index, obj_handle, handle, count);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
diff --git a/src/mpi_t/cvar_handle_free.c b/src/mpi_t/cvar_handle_free.c
index 9c8a82a..271be20 100644
--- a/src/mpi_t/cvar_handle_free.c
+++ b/src/mpi_t/cvar_handle_free.c
@@ -45,17 +45,26 @@ int MPI_T_cvar_handle_free(MPI_T_cvar_handle *handle)
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CVAR_HANDLE_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_CVAR_HANDLE_FREE);
 
+    /* Validate parameters */
+#   ifdef HAVE_ERROR_CHECKING
+    {
+        MPID_BEGIN_ERROR_CHECKS
+        {
+            MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
+        }
+        MPID_END_ERROR_CHECKS
+    }
+#   endif /* HAVE_ERROR_CHECKING */
+
     /* ... body of routine ...  */
 
-    if (handle != NULL) {
-        MPIR_T_cvar_handle_t *hnd = *handle;
-        MPIU_Free(hnd);
-        *handle = MPI_T_CVAR_HANDLE_NULL;
-    }
+    MPIR_T_cvar_handle_t *hnd = *handle;
+    MPIU_Free(hnd);
+    *handle = MPI_T_CVAR_HANDLE_NULL;
 
     /* ... end of body of routine ... */
 
diff --git a/src/mpi_t/cvar_read.c b/src/mpi_t/cvar_read.c
index e963ef7..c71e524 100644
--- a/src/mpi_t/cvar_read.c
+++ b/src/mpi_t/cvar_read.c
@@ -102,7 +102,7 @@ int MPI_T_cvar_read(MPI_T_cvar_handle handle, void *buf)
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CVAR_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_CVAR_READ);
 
@@ -111,7 +111,7 @@ int MPI_T_cvar_read(MPI_T_cvar_handle handle, void *buf)
     {
         MPID_BEGIN_ERROR_CHECKS
         {
-            MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
+            MPIR_ERRTEST_CVAR_HANDLE(handle, mpi_errno);
             MPIR_ERRTEST_ARGNULL(buf, "buf", mpi_errno);
         }
         MPID_END_ERROR_CHECKS
diff --git a/src/mpi_t/cvar_write.c b/src/mpi_t/cvar_write.c
index 0bfdc5d..d571680 100644
--- a/src/mpi_t/cvar_write.c
+++ b/src/mpi_t/cvar_write.c
@@ -110,7 +110,7 @@ int MPI_T_cvar_write(MPI_T_cvar_handle handle, void *buf)
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_CVAR_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_CVAR_WRITE);
 
@@ -119,7 +119,7 @@ int MPI_T_cvar_write(MPI_T_cvar_handle handle, void *buf)
     {
         MPID_BEGIN_ERROR_CHECKS
         {
-            MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
+            MPIR_ERRTEST_CVAR_HANDLE(handle, mpi_errno);
             MPIR_ERRTEST_ARGNULL(buf, "buf", mpi_errno);
         }
         MPID_END_ERROR_CHECKS
diff --git a/src/mpi_t/enum_get_info.c b/src/mpi_t/enum_get_info.c
index a08cad6..afd134e 100644
--- a/src/mpi_t/enum_get_info.c
+++ b/src/mpi_t/enum_get_info.c
@@ -52,7 +52,7 @@ int MPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *name, int *name_len
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_ENUM_GET_INFO);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_ENUM_GET_INFO);
 
@@ -61,7 +61,7 @@ int MPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *name, int *name_len
     {
         MPID_BEGIN_ERROR_CHECKS
         {
-            MPIR_ERRTEST_ARGNULL(enumtype, "enumtype", mpi_errno);
+            MPIR_ERRTEST_ENUM_HANDLE(enumtype, mpi_errno);
             MPIR_ERRTEST_ARGNULL(num, "num", mpi_errno);
             /* Do not do _TEST_ARGNULL for name or name_len, since this is
              * permitted per MPI_T standard.
diff --git a/src/mpi_t/enum_get_item.c b/src/mpi_t/enum_get_item.c
index aa928c4..dda7433 100644
--- a/src/mpi_t/enum_get_item.c
+++ b/src/mpi_t/enum_get_item.c
@@ -54,7 +54,7 @@ int MPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name,
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_ENUM_GET_ITEM);
-    MPIR_T_FAIL_IF_UNINITIALIZED();
+    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
     MPIR_T_THREAD_CS_ENTER();
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_ENUM_GET_ITEM);
 
@@ -63,7 +63,8 @@ int MPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name,
     {
         MPID_BEGIN_ERROR_CHECKS
         {
-            MPIR_ERRTEST_ARGNULL(enumtype, "enumtype", mpi_errno);
+            MPIR_ERRTEST_ENUM_HANDLE(enumtype, mpi_errno);
+            MPIR_ERRTEST_ENUM_ITEM(enumtype, index, mpi_errno);
             MPIR_ERRTEST_ARGNULL(value, "value", mpi_errno);
             /* Do not do TEST_ARGNULL for name or name_len, since this is
              * permitted per MPI_T standard.
@@ -75,11 +76,6 @@ int MPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name,
 
     /* ... body of routine ...  */
 
-    if (index < 0 || index > utarray_len(enumtype->items) - 1) {
-        mpi_errno = MPI_T_ERR_INVALID_ITEM;
-        goto fn_fail;
-    }
-
     enum_item_t *item = (enum_item_t *)utarray_eltptr(enumtype->items, index);
     *value = item->value;
     MPIR_T_strncpy(name, item->name, name_len);
diff --git a/src/mpi_t/mpit.c b/src/mpi_t/mpit.c
index 7932d34..2d580de 100644
--- a/src/mpi_t/mpit.c
+++ b/src/mpi_t/mpit.c
@@ -44,6 +44,9 @@ void MPIR_T_enum_create(const char *enum_name, MPI_T_enum *handle)
     e = (MPIR_T_enum_t *)utarray_back(enum_table);
     e->name = MPIU_Strdup(enum_name);
     MPIU_Assert(e->name);
+#ifdef HAVE_ERROR_CHECKING
+    e->kind = MPIR_T_ENUM_HANDLE;
+#endif
     utarray_new(e->items, &enum_item_icd);
     (*handle) = e;
 }
diff --git a/src/mpi_t/pvar_get_info.c b/src/mpi_t/pvar_get_info.c
index af56992..3dcd179 100644
--- a/src/mpi_t/pvar_get_info.c
+++ b/src/mpi_t/pvar_get_info.c
@@ -63,7 +63,7 @@ int MPI_T_pvar_get_info(int pvar_index, char *name, int *name_len, int *verbosit
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_GET_INFO);
-    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_GET_INFO);
 
@@ -72,7 +72,8 @@ int MPI_T_pvar_get_info(int pvar_index, char *name, int *name_len, int *verbosit
     {
         MPID_BEGIN_ERROR_CHECKS
         {
-            /* Do not do _TEST_ARGNULL for any argument, since this is
+            MPIR_ERRTEST_PVAR_INDEX(pvar_index, mpi_errno);
+            /* Do not do _TEST_ARGNULL for other arguments, since this is
              * allowed or will be allowed by MPI_T standard.
              */
         }
@@ -83,11 +84,6 @@ int MPI_T_pvar_get_info(int pvar_index, char *name, int *name_len, int *verbosit
     /* ... body of routine ...  */
     const pvar_table_entry_t *entry;
 
-    if (pvar_index < 0 || pvar_index >= utarray_len(pvar_table)) {
-        mpi_errno = MPI_T_ERR_INVALID_INDEX;
-        goto fn_fail;
-    }
-
     entry = (pvar_table_entry_t *) utarray_eltptr(pvar_table, pvar_index);
     if (!entry->active) {
         mpi_errno = MPI_T_ERR_INVALID_INDEX;
diff --git a/src/mpi_t/pvar_get_num.c b/src/mpi_t/pvar_get_num.c
index 1f69872..4e66600 100644
--- a/src/mpi_t/pvar_get_num.c
+++ b/src/mpi_t/pvar_get_num.c
@@ -44,14 +44,24 @@ int MPI_T_pvar_get_num(int *num_pvar)
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_GET_NUM);
-    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_GET_NUM);
 
+    /* Validate parameters */
+#   ifdef HAVE_ERROR_CHECKING
+    {
+        MPID_BEGIN_ERROR_CHECKS
+        {
+            MPIR_ERRTEST_ARGNULL(num_pvar, "num_pvar", mpi_errno);
+        }
+        MPID_END_ERROR_CHECKS
+    }
+#   endif /* HAVE_ERROR_CHECKING */
+
     /* ... body of routine ...  */
 
-    if (num_pvar != NULL)
-        *num_pvar = utarray_len(pvar_table);
+    *num_pvar = utarray_len(pvar_table);
 
     /* ... end of body of routine ... */
 
diff --git a/src/mpi_t/pvar_handle_alloc.c b/src/mpi_t/pvar_handle_alloc.c
index 26ce0b8..e3bdc07 100644
--- a/src/mpi_t/pvar_handle_alloc.c
+++ b/src/mpi_t/pvar_handle_alloc.c
@@ -24,7 +24,13 @@
 #define MPI_T_pvar_handle_alloc PMPI_T_pvar_handle_alloc
 
 /* Define storage for the ALL_HANDLES constant */
-MPIR_T_pvar_handle_t MPIR_T_pvar_all_handles_obj = {0};
+MPIR_T_pvar_handle_t MPIR_T_pvar_all_handles_obj =
+{
+#ifdef HAVE_ERROR_CHECKING
+MPIR_T_PVAR_HANDLE, /* pvar handle tag for error checking */
+#endif
+0
+};
 MPIR_T_pvar_handle_t * const MPI_T_PVAR_ALL_HANDLES = &MPIR_T_pvar_all_handles_obj;
 
 /* any non-MPI functions go here, especially non-static ones */
@@ -74,6 +80,9 @@ int MPIR_T_pvar_handle_alloc_impl(MPI_T_pvar_session session, int pvar_index,
     /* Allocate memory and bzero it */
     MPIU_CHKPMEM_CALLOC(hnd, MPIR_T_pvar_handle_t*, sizeof(*hnd) + extra,
                         mpi_errno, "performance variable handle");
+#ifdef HAVE_ERROR_CHECKING
+    hnd->kind = MPIR_T_PVAR_HANDLE;
+#endif
 
     /* Setup the common fields */
     if (is_sum)
@@ -193,7 +202,7 @@ int MPI_T_pvar_handle_alloc(MPI_T_pvar_session session, int pvar_index,
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_HANDLE_ALLOC);
-    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_HANDLE_ALLOC);
 
@@ -202,6 +211,8 @@ int MPI_T_pvar_handle_alloc(MPI_T_pvar_session session, int pvar_index,
     {
         MPID_BEGIN_ERROR_CHECKS
         {
+            MPIR_ERRTEST_PVAR_SESSION(session, mpi_errno);
+            MPIR_ERRTEST_PVAR_INDEX(pvar_index, mpi_errno);
             MPIR_ERRTEST_ARGNULL(count, "count", mpi_errno);
             MPIR_ERRTEST_ARGNULL(handle, "handle", mpi_errno);
             /* Do not test obj_handle since it may be NULL when no binding */
@@ -212,13 +223,7 @@ int MPI_T_pvar_handle_alloc(MPI_T_pvar_session session, int pvar_index,
 
     /* ... body of routine ...  */
 
-    pvar_table_entry_t *entry;
-    if (pvar_index < 0 || pvar_index >= utarray_len(pvar_table)) {
-        mpi_errno = MPI_T_ERR_INVALID_INDEX;
-        goto fn_fail;
-    }
-
-    entry = (pvar_table_entry_t *) utarray_eltptr(pvar_table, pvar_index);
+    pvar_table_entry_t *entry = (pvar_table_entry_t *) utarray_eltptr(pvar_table, pvar_index);
     if (!entry->active) {
         mpi_errno = MPI_T_ERR_INVALID_INDEX;
         goto fn_fail;
diff --git a/src/mpi_t/pvar_handle_free.c b/src/mpi_t/pvar_handle_free.c
index 6563812..bc7a6de 100644
--- a/src/mpi_t/pvar_handle_free.c
+++ b/src/mpi_t/pvar_handle_free.c
@@ -92,7 +92,7 @@ int MPI_T_pvar_handle_free(MPI_T_pvar_session session, MPI_T_pvar_handle *handle
     int mpi_errno = MPI_SUCCESS;
 
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_PVAR_HANDLE_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_HANDLE_FREE);
 
@@ -101,19 +101,22 @@ int MPI_T_pvar_handle_free(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);
-            if (mpi_errno != MPI_SUCCESS) goto fn_fail;
+            if (*handle == MPI_T_PVAR_HANDLE_NULL) /* free NULL is OK */
+                goto fn_exit;
+            MPIR_ERRTEST_PVAR_SESSION(session, mpi_errno);
+            MPIR_ERRTEST_PVAR_HANDLE(*handle, 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
     }
 #   endif /* HAVE_ERROR_CHECKING */
 
     /* ... body of routine ...  */
-    if ((*handle) == MPI_T_PVAR_ALL_HANDLES || (*handle)->session != session) {
-        mpi_errno = MPI_T_ERR_INVALID_HANDLE;
-        goto fn_fail;
-    }
 
     mpi_errno = MPIR_T_pvar_handle_free_impl(session, handle);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
diff --git a/src/mpi_t/pvar_read.c b/src/mpi_t/pvar_read.c
index ef0f7d5..3c3ba7f 100644
--- a/src/mpi_t/pvar_read.c
+++ b/src/mpi_t/pvar_read.c
@@ -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;
 
diff --git a/src/mpi_t/pvar_readreset.c b/src/mpi_t/pvar_readreset.c
index b01f220..bd87dd4 100644
--- a/src/mpi_t/pvar_readreset.c
+++ b/src/mpi_t/pvar_readreset.c
@@ -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;
 
diff --git a/src/mpi_t/pvar_reset.c b/src/mpi_t/pvar_reset.c
index 00982e8..c835e64 100644
--- a/src/mpi_t/pvar_reset.c
+++ b/src/mpi_t/pvar_reset.c
@@ -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
     }
diff --git a/src/mpi_t/pvar_session_create.c b/src/mpi_t/pvar_session_create.c
index b6f9d07..db59286 100644
--- a/src/mpi_t/pvar_session_create.c
+++ b/src/mpi_t/pvar_session_create.c
@@ -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);
 
diff --git a/src/mpi_t/pvar_session_free.c b/src/mpi_t/pvar_session_free.c
index 6111799..9a2064d 100644
--- a/src/mpi_t/pvar_session_free.c
+++ b/src/mpi_t/pvar_session_free.c
@@ -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);
 
diff --git a/src/mpi_t/pvar_start.c b/src/mpi_t/pvar_start.c
index d94cde9..84ac78c 100644
--- a/src/mpi_t/pvar_start.c
+++ b/src/mpi_t/pvar_start.c
@@ -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
     }
diff --git a/src/mpi_t/pvar_stop.c b/src/mpi_t/pvar_stop.c
index b8e4337..10a2081 100644
--- a/src/mpi_t/pvar_stop.c
+++ b/src/mpi_t/pvar_stop.c
@@ -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
     }
diff --git a/src/mpi_t/pvar_write.c b/src/mpi_t/pvar_write.c
index 9548229..309f7ba 100644
--- a/src/mpi_t/pvar_write.c
+++ b/src/mpi_t/pvar_write.c
@@ -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 {

http://git.mpich.org/mpich.git/commitdiff/84ef4e85691d74e63dec5c1959e6e63b9d8cb0b0

commit 84ef4e85691d74e63dec5c1959e6e63b9d8cb0b0
Author: Junchao Zhang <jczhang at mcs.anl.gov>
Date:   Fri Nov 15 16:53:00 2013 -0600

    Add MPIR_ERRTEST_* macros for MPI_T
    
    Signed-off-by: Antonio J. Pena <apenya at mcs.anl.gov>

diff --git a/src/include/mpierrs.h b/src/include/mpierrs.h
index e9c69e3..082b087 100644
--- a/src/include/mpierrs.h
+++ b/src/include/mpierrs.h
@@ -500,6 +500,97 @@
         }                                                               \
     }
 
+#ifdef HAVE_ERROR_CHECKING
+#define MPIR_ERRTEST_MPIT_INITIALIZED(err_) \
+    do { \
+        if (!MPIR_T_is_initialized()) { \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_NOT_INITIALIZED, goto fn_fail, "**mpitinit"); \
+        } \
+    } while (0)
+#else
+#define MPIR_ERRTEST_MPIT_INITIALIZED(err_)
+#endif
+
+#define MPIR_ERRTEST_CAT_INDEX(index_,err_)  \
+    do {   \
+        if ((index_) < 0 || (index_) >= utarray_len(cat_table)) \
+        {  \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_INDEX, goto fn_fail, "**catindex");  \
+        }  \
+    } while (0)
+
+#define MPIR_ERRTEST_ENUM_HANDLE(handle_, err_)  \
+    do {   \
+        if ((handle_) == MPI_T_ENUM_NULL)  \
+        {  \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_HANDLE, goto fn_fail, "**enumhandlenull");  \
+        }  \
+        else if ((handle_)->kind != MPIR_T_ENUM_HANDLE) \
+        {  \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_HANDLE, goto fn_fail, "**enumhandle"); \
+        }  \
+    } while (0)
+
+#define MPIR_ERRTEST_ENUM_ITEM(enum_, index_, err_)  \
+    do {   \
+        if ((index_) < 0 || (index_) >= utarray_len((enum_)->items)) \
+        {  \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_ITEM, goto fn_fail, "**itemindex");  \
+        }  \
+    } while (0)
+
+#define MPIR_ERRTEST_CVAR_INDEX(index_,err_)  \
+    do {   \
+        if ((index_) < 0 || (index_) >= utarray_len(cvar_table)) \
+        {  \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_INDEX, goto fn_fail, "**cvarindex");  \
+        }  \
+    } while (0)
+
+#define MPIR_ERRTEST_CVAR_HANDLE(handle_, err_)  \
+    do {   \
+        if ((handle_) == MPI_T_CVAR_HANDLE_NULL)  \
+        {  \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_HANDLE, goto fn_fail, "**cvarhandlenull");  \
+        }  \
+        else if ((handle_)->kind != MPIR_T_CVAR_HANDLE) \
+        {  \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_HANDLE, goto fn_fail, "**cvarhandle"); \
+        }  \
+    } while (0)
+
+#define MPIR_ERRTEST_PVAR_INDEX(index_,err_)  \
+    do {   \
+        if ((index_) < 0 || (index_) >= utarray_len(pvar_table)) \
+        {  \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_INDEX, goto fn_fail, "**pvarindex");  \
+        }  \
+    } while (0)
+
+#define MPIR_ERRTEST_PVAR_HANDLE(handle_, err_) \
+    do {   \
+        if (handle_ == MPI_T_PVAR_HANDLE_NULL) \
+        {  \
+            MPIU_ERR_SETANDSTMT(err_,MPI_T_ERR_INVALID_HANDLE, goto fn_fail,"**pvarhandlenull"); \
+        }  \
+        else if ((handle_)->kind != MPIR_T_PVAR_HANDLE)  \
+        {  \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_HANDLE, goto fn_fail, "**pvarhandle");  \
+        }  \
+    } while (0)
+
+#define MPIR_ERRTEST_PVAR_SESSION(session_,err_)  \
+    do {    \
+        if ((session_) == MPI_T_PVAR_SESSION_NULL)  \
+        {   \
+            MPIU_ERR_SETANDSTMT(err_,MPI_T_ERR_INVALID_SESSION, goto fn_fail,"**pvarsessionnull");  \
+        }   \
+        else if ((session_)->kind != MPIR_T_PVAR_SESSION) \
+        {   \
+            MPIU_ERR_SETANDSTMT(err_, MPI_T_ERR_INVALID_SESSION, goto fn_fail, "**pvarsession");  \
+        }   \
+    } while (0)
+
 /* some simple memcpy aliasing checks */
 #define MPIU_ERR_CHKMEMCPYANDSTMT(err_,stmt_,src_,dst_,len_) \
     MPIU_ERR_CHKANDSTMT3(MPIU_MEM_RANGES_OVERLAP((dst_),(len_),(src_),(len_)),err_,MPI_ERR_INTERN,stmt_,"**memcpyalias","**memcpyalias %p %p %L",(src_),(dst_),(long long)(len_))
diff --git a/src/mpi_t/errnames.txt b/src/mpi_t/errnames.txt
index c32d1d7..1d4ba7f 100644
--- a/src/mpi_t/errnames.txt
+++ b/src/mpi_t/errnames.txt
@@ -1,3 +1,16 @@
+**mpitinit: MPI tool information interface is not initialized
+**catindex: Category index is invalid
+**enumhandlenull: Enum handle is NULL
+**enumhandle: Enum handle is invalid
+**itemindex: Enum item index is invalid
+**cvarindex: Control variable index is invalid
+**cvarhandlenull: Control variable handle is NULL
+**cvarhandle: Control variable handle is invalid
+**pvarindex: Performance variable index is invalid
+**pvarhandlenull: Performance variable handle is NULL
+**pvarhandle: Performance variable handle is invalid
+**pvarsessionnull: Performance variable session is NULL
+**pvarsession: Performance variable session is invalid
 **mpi_t_init_thread: MPI_T_init_thread failed
 **mpi_t_init_thread %d %p: MPI_T_init_thread(required=%d, provided=%p)
 **mpi_t_finalize: MPI_T_finalize failed

http://git.mpich.org/mpich.git/commitdiff/02da81ee286769c7089bf911b51934a43fb090d5

commit 02da81ee286769c7089bf911b51934a43fb090d5
Author: Junchao Zhang <jczhang at mcs.anl.gov>
Date:   Fri Nov 15 20:12:35 2013 -0600

    Make extracterrmsgs know MPI_T error codes
    
    Signed-off-by: Antonio J. Pena <apenya at mcs.anl.gov>

diff --git a/maint/extracterrmsgs b/maint/extracterrmsgs
index d2061fb..1735459 100755
--- a/maint/extracterrmsgs
+++ b/maint/extracterrmsgs
@@ -725,6 +725,7 @@ sub ProcessFile
 	    }
 	    if ($errClassLoc >= 0 && $checkErrClass) {
 		if (!($args[$errClassLoc] =~ /^MPI_ERR_/)  &&
+		    !($args[$errClassLoc] =~ /^MPI_T_ERR_/) &&
 		    !($args[$errClassLoc] =~ /^MPIDU_SOCK_ERR_/) &&
 		    !($args[$errClassLoc] =~ /^MPIX_ERR_/) &&
 		    !($args[$errClassLoc] =~ /^errclass/) ) {

-----------------------------------------------------------------------

Summary of changes:
 maint/extracterrmsgs            |    1 +
 src/include/mpierrs.h           |   91 +++++++++++++++++++++++++++++++++++++++
 src/include/mpitimpl.h          |   33 +++++++++++---
 src/mpi_t/cat_changed.c         |   16 ++++++-
 src/mpi_t/cat_get_categories.c  |    7 +--
 src/mpi_t/cat_get_cvars.c       |    7 +--
 src/mpi_t/cat_get_info.c        |    9 +---
 src/mpi_t/cat_get_num.c         |   16 ++++++-
 src/mpi_t/cat_get_pvars.c       |    7 +--
 src/mpi_t/cvar_get_info.c       |    7 +--
 src/mpi_t/cvar_get_num.c        |   17 ++++++-
 src/mpi_t/cvar_handle_alloc.c   |   12 +++--
 src/mpi_t/cvar_handle_free.c    |   21 ++++++---
 src/mpi_t/cvar_read.c           |    4 +-
 src/mpi_t/cvar_write.c          |    4 +-
 src/mpi_t/enum_get_info.c       |    4 +-
 src/mpi_t/enum_get_item.c       |   10 +---
 src/mpi_t/errnames.txt          |   13 ++++++
 src/mpi_t/mpit.c                |    3 +
 src/mpi_t/pvar_get_info.c       |   10 +---
 src/mpi_t/pvar_get_num.c        |   16 ++++++-
 src/mpi_t/pvar_handle_alloc.c   |   23 ++++++----
 src/mpi_t/pvar_handle_free.c    |   17 ++++---
 src/mpi_t/pvar_read.c           |   19 ++++----
 src/mpi_t/pvar_readreset.c      |   30 ++++++------
 src/mpi_t/pvar_reset.c          |    6 +-
 src/mpi_t/pvar_session_create.c |    6 ++-
 src/mpi_t/pvar_session_free.c   |    2 +-
 src/mpi_t/pvar_start.c          |    6 +-
 src/mpi_t/pvar_stop.c           |    6 +-
 src/mpi_t/pvar_write.c          |   15 +++---
 test/mpi/mpi_t/mpit_vars.c      |    6 +++
 32 files changed, 308 insertions(+), 136 deletions(-)


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list