[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.2a2-128-g1526244

Service Account noreply at mpich.org
Fri Jan 30 16:45:14 CST 2015


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  15262441d4010de06a50c4aba877e26154187665 (commit)
       via  18b18311514deadcfc66dc357d58e837c4ed2545 (commit)
       via  48d797a9bdb58adcaaad4361743756f5e0f7dd61 (commit)
       via  67ec0ab1c7606ef5749797c93192a4b02d879c57 (commit)
       via  3dae695980abe2580f98e82a08121756cceaf06f (commit)
       via  6556f351cc454a2c858280d7a94ce83b124f6480 (commit)
       via  54362c008ee413b40d5e4f654b72ee45091f1c33 (commit)
       via  c04f08514fddfd16996e913e3d18d32aaed460f2 (commit)
      from  85727524ca0fc264a455627e293f758f5c2a7708 (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/15262441d4010de06a50c4aba877e26154187665

commit 15262441d4010de06a50c4aba877e26154187665
Author: Wesley Bland <wbland at anl.gov>
Date:   Thu Jan 29 15:11:18 2015 -0600

    Correctly return errcode for NBC
    
    The error code set in the status was being ignored for NBC and one-sided
    requests (which wasn't right anyway so it didn't matter). This grabs the
    error code from the status now.
    
    Signed-off-by: Huiwei Lu <huiweilu at mcs.anl.gov>

diff --git a/src/mpi/pt2pt/mpir_request.c b/src/mpi/pt2pt/mpir_request.c
index 5cf6b97..1a34ef0 100644
--- a/src/mpi/pt2pt/mpir_request.c
+++ b/src/mpi/pt2pt/mpir_request.c
@@ -218,6 +218,7 @@ int MPIR_Request_complete(MPI_Request * request, MPID_Request * request_ptr,
         case MPID_COLL_REQUEST:
         case MPID_WIN_REQUEST:
         {
+            mpi_errno = request_ptr->status.MPI_ERROR;
             MPIR_Request_extract_status(request_ptr, status);
             MPID_Request_release(request_ptr);
             if (NULL != request) *request = MPI_REQUEST_NULL;

http://git.mpich.org/mpich.git/commitdiff/18b18311514deadcfc66dc357d58e837c4ed2545

commit 18b18311514deadcfc66dc357d58e837c4ed2545
Author: Wesley Bland <wbland at anl.gov>
Date:   Thu Jan 29 11:11:46 2015 -0600

    Add test for non-blocking collective failures
    
    Signed-off-by: Huiwei Lu <huiweilu at mcs.anl.gov>

diff --git a/test/mpi/ft/Makefile.am b/test/mpi/ft/Makefile.am
index 3aa31ed..7c094b5 100644
--- a/test/mpi/ft/Makefile.am
+++ b/test/mpi/ft/Makefile.am
@@ -15,4 +15,4 @@ EXTRA_DIST = testlist
 noinst_PROGRAMS = die abort sendalive isendalive senddead recvdead isenddead \
 		  irecvdead barrier gather reduce bcast scatter failure_ack \
 		  anysource revoke_nofail shrink agree multi_isendalive \
-		  agree_shrink revoke_shrink
+		  agree_shrink revoke_shrink nbccoll
diff --git a/test/mpi/ft/nbccoll.c b/test/mpi/ft/nbccoll.c
new file mode 100644
index 0000000..f5b6cf4
--- /dev/null
+++ b/test/mpi/ft/nbccoll.c
@@ -0,0 +1,76 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ *  (C) 2003 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+ * This test checks if a non-blocking collective failing impacts the result
+ * of another operation going on at the same time.
+ */
+int main(int argc, char **argv)
+{
+    int rank, size;
+    int err;
+    int excl;
+    MPI_Comm small_comm;
+    MPI_Group orig_grp, small_grp;
+    MPI_Request req;
+    MPI_Status status;
+
+    MPI_Init(&argc, &argv);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    MPI_Comm_size(MPI_COMM_WORLD, &size);
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+
+    MPI_Comm_group(MPI_COMM_WORLD, &orig_grp);
+    MPI_Group_size(orig_grp, &excl);
+    excl--;
+    MPI_Group_excl(orig_grp, 1, &excl, &small_grp);
+    MPI_Comm_create_group(MPI_COMM_WORLD, small_grp, 0, &small_comm);
+    MPI_Group_free(&orig_grp);
+    MPI_Group_free(&small_grp);
+
+    if (size < 4) {
+        fprintf( stderr, "Must run with at least 2 processes\n" );
+        MPI_Abort( MPI_COMM_WORLD, 1 );
+    }
+
+    if (rank == excl) {
+        exit(EXIT_FAILURE);
+    }
+
+    MPI_Ibarrier(MPI_COMM_WORLD, &req);
+
+    err = MPI_Barrier(small_comm);
+    if (err != MPI_SUCCESS) {
+        int ec;
+        MPI_Error_class(err, &ec);
+        fprintf(stderr, "Result != MPI_SUCCESS: %d\n", ec);
+        MPI_Abort(MPI_COMM_WORLD, 1);
+    }
+
+    err = MPI_Wait(&req, &status);
+    if (err == MPI_SUCCESS) {
+        int ec, ec2;
+        MPI_Error_class(err, &ec);
+        MPI_Error_class(status.MPI_ERROR, &ec2);
+        fprintf(stderr, "Result != MPIX_ERR_PROC_FAILED: %d Status: %d\n", ec, ec2);
+        MPI_Abort(MPI_COMM_WORLD, 1);
+    }
+
+    MPI_Comm_free(&small_comm);
+
+    if (rank == 0) {
+        printf(" No Errors\n");
+        fflush(stdout);
+    }
+
+    MPI_Finalize();
+
+    return 0;
+}
diff --git a/test/mpi/ft/testlist b/test/mpi/ft/testlist
index 52dde9a..03868d4 100644
--- a/test/mpi/ft/testlist
+++ b/test/mpi/ft/testlist
@@ -17,4 +17,5 @@ revoke_nofail 2 env=MPIR_CVAR_ENABLE_FT=1 strict=false timeLimit=10
 shrink 8 env=MPIR_CVAR_ENABLE_FT=1 mpiexecarg=-disable-auto-cleanup resultTest=TestStatusNoErrors strict=false timeLimit=10
 agree 4 env=MPIR_CVAR_ENABLE_FT=1 mpiexecarg=-disable-auto-cleanup resultTest=TestStatusNoErrors strict=false timeLimit=10
 agree_shrink 4 env=MPIR_CVAR_ENABLE_FT=1 mpiexecarg=-disable-auto-cleanup resultTest=TestStatusNoErrors strict=false timeLimit=10
-revoke_shrink 4 env=MPIR_CVAR_ENABLE=1 mpiexecarg=-disable-auto-cleanup resultTest=TestStatusNoErrors strict=false timeLimit=10 xfail=2198
+revoke_shrink 4 env=MPIR_CVAR_ENABLE_FT=1 mpiexecarg=-disable-auto-cleanup resultTest=TestStatusNoErrors strict=false timeLimit=10 xfail=2198
+nbccoll 4 env=MPIR_CVAR_ENABLE_FT=1 mpiexecarg=-disable-auto-cleanup resultTest=TestStatusNoErrors strict=false timeLimit=10

http://git.mpich.org/mpich.git/commitdiff/48d797a9bdb58adcaaad4361743756f5e0f7dd61

commit 48d797a9bdb58adcaaad4361743756f5e0f7dd61
Author: Wesley Bland <wbland at anl.gov>
Date:   Thu Jan 29 12:33:45 2015 -0600

    Convert scheduler functions to use MPIC
    
    The scheduler functions now use MPIC_* functions to handle their
    communication instead of directly calling the MPID_* functions. This
    helps to simplify code related to error handling and allows the
    collectives to complete even if a failure is detected because the error
    will be tracked via the errflag inside the request object.
    
    Fixes #2222
    
    Signed-off-by: Huiwei Lu <huiweilu at mcs.anl.gov>

diff --git a/src/mpid/common/sched/mpid_sched.c b/src/mpid/common/sched/mpid_sched.c
index 21082d1..9e2a09d 100644
--- a/src/mpid/common/sched/mpid_sched.c
+++ b/src/mpid/common/sched/mpid_sched.c
@@ -124,8 +124,7 @@ fn_fail:
  * performing reductions, calling callbacks, etc. */
 static int MPIDU_Sched_start_entry(struct MPIDU_Sched *s, size_t idx, struct MPIDU_Sched_entry *e)
 {
-    int mpi_errno = MPI_SUCCESS;
-    int context_offset;
+    int mpi_errno = MPI_SUCCESS, ret_errno = MPI_SUCCESS;
     MPID_Request *r = s->req;
     MPID_Comm *comm;
 
@@ -134,43 +133,62 @@ static int MPIDU_Sched_start_entry(struct MPIDU_Sched *s, size_t idx, struct MPI
     switch (e->type) {
         case MPIDU_SCHED_ENTRY_SEND:
             comm = e->u.send.comm;
-            context_offset = (comm->comm_kind == MPID_INTRACOMM) ?
-                MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
+            MPIU_DBG_MSG_D(COMM, VERBOSE, "starting SEND entry %d\n", (int) idx);
             if (e->u.send.count_p) {
                 /* deferred send */
                 /* originally there was no branch and send.count_p was set to
                  * &send.count, but this requires patching up the pointers
                  * during realloc of entries, so this is easier */
-                mpi_errno = MPID_Isend(e->u.send.buf, *e->u.send.count_p, e->u.send.datatype,
-                                       e->u.send.dest, s->tag, comm, context_offset,
-                                       &e->u.send.sreq);
+                ret_errno = MPIC_Isend(e->u.send.buf, *e->u.send.count_p, e->u.send.datatype,
+                                       e->u.send.dest, s->tag, comm, &e->u.send.sreq, &r->dev.errflag);
             }
             else {
                 if (e->u.send.is_sync) {
-                    mpi_errno = MPID_Issend(e->u.send.buf, e->u.send.count, e->u.send.datatype,
-                                            e->u.send.dest, s->tag, comm, context_offset,
-                                            &e->u.send.sreq);
+                    ret_errno = MPIC_Issend(e->u.send.buf, e->u.send.count, e->u.send.datatype,
+                                            e->u.send.dest, s->tag, comm, &e->u.send.sreq, &r->dev.errflag);
                 }
                 else {
-                    mpi_errno = MPID_Isend(e->u.send.buf, e->u.send.count, e->u.send.datatype,
-                                           e->u.send.dest, s->tag, comm, context_offset,
-                                           &e->u.send.sreq);
+                    ret_errno = MPIC_Isend(e->u.send.buf, e->u.send.count, e->u.send.datatype,
+                                           e->u.send.dest, s->tag, comm, &e->u.send.sreq, &r->dev.errflag);
                 }
             }
-            if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-            e->status = MPIDU_SCHED_ENTRY_STATUS_STARTED;
+            /* Check if the error is actually fatal to the NBC or we can continue. */
+            if (unlikely(ret_errno)) {
+                if (MPIR_ERR_NONE == r->dev.errflag) {
+                    if (MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(ret_errno)) {
+                        r->dev.errflag = MPIR_ERR_PROC_FAILED;
+                    } else {
+                        r->dev.errflag = MPIR_ERR_OTHER;
+                    }
+                }
+                e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
+                MPIU_DBG_MSG_D(COMM, VERBOSE, "Sched SEND failed. Errflag: %d\n", (int) r->dev.errflag);
+            } else {
+                e->status = MPIDU_SCHED_ENTRY_STATUS_STARTED;
+            }
             break;
         case MPIDU_SCHED_ENTRY_RECV:
+            MPIU_DBG_MSG_D(COMM, VERBOSE, "starting RECV entry %d\n", (int) idx);
             comm = e->u.recv.comm;
-            context_offset = (comm->comm_kind == MPID_INTRACOMM) ?
-                MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
-            mpi_errno = MPID_Irecv(e->u.recv.buf, e->u.recv.count, e->u.recv.datatype,
-                                   e->u.recv.src, s->tag, comm, context_offset,
-                                   &e->u.recv.rreq);
-            if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-            e->status = MPIDU_SCHED_ENTRY_STATUS_STARTED;
+            ret_errno = MPIC_Irecv(e->u.recv.buf, e->u.recv.count, e->u.recv.datatype,
+                                   e->u.recv.src, s->tag, comm, &e->u.recv.rreq);
+            /* Check if the error is actually fatal to the NBC or we can continue. */
+            if (unlikely(ret_errno)) {
+                if (MPIR_ERR_NONE == r->dev.errflag) {
+                    if (MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(ret_errno)) {
+                        r->dev.errflag = MPIR_ERR_PROC_FAILED;
+                    } else {
+                        r->dev.errflag = MPIR_ERR_OTHER;
+                    }
+                }
+                e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
+                MPIU_DBG_MSG_D(COMM, VERBOSE, "Sched SEND failed. Errflag: %d\n", (int) r->dev.errflag);
+            } else {
+                e->status = MPIDU_SCHED_ENTRY_STATUS_STARTED;
+            }
             break;
         case MPIDU_SCHED_ENTRY_REDUCE:
+            MPIU_DBG_MSG_D(COMM, VERBOSE, "starting REDUCE entry %d\n", (int) idx);
             mpi_errno = MPIR_Reduce_local_impl(e->u.reduce.inbuf, e->u.reduce.inoutbuf, e->u.reduce.count,
                                                e->u.reduce.datatype, e->u.reduce.op);
             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
@@ -183,6 +201,7 @@ static int MPIDU_Sched_start_entry(struct MPIDU_Sched *s, size_t idx, struct MPI
             e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
             break;
         case MPIDU_SCHED_ENTRY_COPY:
+            MPIU_DBG_MSG_D(COMM, VERBOSE, "starting COPY entry %d\n", (int) idx);
             mpi_errno = MPIR_Localcopy(e->u.copy.inbuf, e->u.copy.incount, e->u.copy.intype,
                                        e->u.copy.outbuf, e->u.copy.outcount, e->u.copy.outtype);
             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
@@ -191,30 +210,48 @@ static int MPIDU_Sched_start_entry(struct MPIDU_Sched *s, size_t idx, struct MPI
             e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
             break;
         case MPIDU_SCHED_ENTRY_NOP:
+            MPIU_DBG_MSG_D(COMM, VERBOSE, "starting NOOP entry %d\n", (int) idx);
             /* nothing to be done */
             break;
         case MPIDU_SCHED_ENTRY_CB:
+            MPIU_DBG_MSG_D(COMM, VERBOSE, "starting CB entry %d\n", (int) idx);
             if (e->u.cb.cb_type == MPIDU_SCHED_CB_TYPE_1) {
-                mpi_errno = e->u.cb.u.cb_p(r->comm, s->tag, e->u.cb.cb_state);
-                if (mpi_errno) {
+                ret_errno = e->u.cb.u.cb_p(r->comm, s->tag, e->u.cb.cb_state);
+                if (unlikely(ret_errno)) {
+                    if (MPIR_ERR_NONE == r->dev.errflag) {
+                        if (MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(ret_errno)) {
+                            r->dev.errflag = MPIR_ERR_PROC_FAILED;
+                        } else {
+                            r->dev.errflag = MPIR_ERR_OTHER;
+                        }
+                    }
                     e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
-                    MPIU_ERR_POP(mpi_errno);
+                } else {
+                    e->status = MPIDU_SCHED_ENTRY_STATUS_STARTED;
                 }
             }
             else if (e->u.cb.cb_type == MPIDU_SCHED_CB_TYPE_2) {
-                mpi_errno = e->u.cb.u.cb2_p(r->comm, s->tag, e->u.cb.cb_state, e->u.cb.cb_state2);
-                if (mpi_errno) {
+                ret_errno = e->u.cb.u.cb2_p(r->comm, s->tag, e->u.cb.cb_state, e->u.cb.cb_state2);
+                if (unlikely(ret_errno)) {
+                    if (MPIR_ERR_NONE == r->dev.errflag) {
+                        if (MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(ret_errno)) {
+                            r->dev.errflag = MPIR_ERR_PROC_FAILED;
+                        } else {
+                            r->dev.errflag = MPIR_ERR_OTHER;
+                        }
+                    }
                     e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
-                    MPIU_ERR_POP(mpi_errno);
+                } else {
+                    e->status = MPIDU_SCHED_ENTRY_STATUS_STARTED;
                 }
             }
             else {
-                MPIU_Assert_fmt_msg(FALSE, ("unknown callback type, e->u.cb.cb_type=%d", e->u.cb.cb_type));
+                MPIU_DBG_MSG_D(COMM, TYPICAL, "unknown callback type, e->u.cb.cb_type=%d", e->u.cb.cb_type);
             }
             e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
             break;
         default:
-            MPIU_Assert_fmt_msg(FALSE, ("unknown entry type, e->type=%d", e->type));
+            MPIU_DBG_MSG_D(COMM, TYPICAL, "unknown entry type, e->type=%d", e->type);
             break;
     }
 
@@ -248,13 +285,13 @@ static int MPIDU_Sched_continue(struct MPIDU_Sched *s)
         }
 
         /* _start_entry may have completed the operation, but won't update s->idx */
-        if (i == s->idx && e->status == MPIDU_SCHED_ENTRY_STATUS_COMPLETE) {
+        if (i == s->idx && e->status >= MPIDU_SCHED_ENTRY_STATUS_COMPLETE) {
             ++s->idx; /* this is valid even for barrier entries */
         }
 
         /* watch the indexing, s->idx might have been incremented above, so
          * ||-short-circuit matters here */
-        if (e->is_barrier && (e->status != MPIDU_SCHED_ENTRY_STATUS_COMPLETE || (s->idx != i+1))) {
+        if (e->is_barrier && (e->status < MPIDU_SCHED_ENTRY_STATUS_COMPLETE || (s->idx != i+1))) {
             /* we've hit a barrier but outstanding operations before this
              * barrier remain, so we cannot proceed past the barrier */
             break;
@@ -368,7 +405,7 @@ int MPID_Sched_start(MPID_Sched_t *sp, MPID_Comm *comm, int tag, MPID_Request **
      * progress engine can make progress on it */
     MPL_DL_APPEND(all_schedules.head, s);
 
-    dprintf(stderr, "started schedule s=%p\n", s);
+    MPIU_DBG_MSG_P(COMM, TYPICAL, "started schedule s=%p\n", s);
     MPIDU_Sched_dump(s);
 
 fn_exit:
@@ -795,7 +832,6 @@ static int MPIDU_Sched_progress_state(struct MPIDU_Sched_state *state, int *made
         *made_progress = FALSE;
 
     MPL_DL_FOREACH_SAFE(state->head, s, tmp) {
-        dprintf(stderr, "making progress on s=%p\n", s);
         /*MPIDU_Sched_dump(s);*/
 
         for (i = s->idx; i < s->num_entries; ++i) {
@@ -804,38 +840,38 @@ static int MPIDU_Sched_progress_state(struct MPIDU_Sched_state *state, int *made
             switch (e->type) {
                 case MPIDU_SCHED_ENTRY_SEND:
                     if (e->u.send.sreq != NULL && MPID_Request_is_complete(e->u.send.sreq)) {
-                        dprintf(stderr, "completed SEND entry %d, sreq=%p\n", i, e->u.send.sreq);
+                        MPIU_DBG_MSG_FMT(COMM, VERBOSE, (MPIU_DBG_FDEST, "completed SEND entry %d, sreq=%p\n", (int) i, e->u.send.sreq));
                         e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
-                        mpi_errno = e->u.send.sreq->status.MPI_ERROR;
+                        /* This wait call won't enter the progress engine.
+                         * It's just a convinient way to pull out the error
+                         * information from the tag. */
+                        MPIR_Process_status(&e->u.send.sreq->status, &s->req->dev.errflag);
                         MPID_Request_release(e->u.send.sreq);
                         e->u.send.sreq = NULL;
                         MPIR_Comm_release(e->u.send.comm, /*isDisconnect=*/FALSE);
                         dtype_release_if_not_builtin(e->u.send.datatype);
-                        if (mpi_errno) {
+                        if (e->u.send.sreq->status.MPI_ERROR)
                             e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
-                            MPIU_ERR_POP(mpi_errno);
-                        }
-                        else {
+                        else
                             e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
-                        }
                     }
                     break;
                 case MPIDU_SCHED_ENTRY_RECV:
                     if (e->u.recv.rreq != NULL && MPID_Request_is_complete(e->u.recv.rreq)) {
-                        dprintf(stderr, "completed RECV entry %d, rreq=%p\n", i, e->u.recv.rreq);
-                        mpi_errno = e->u.recv.rreq->status.MPI_ERROR;
+                        MPIU_DBG_MSG_FMT(COMM, VERBOSE, (MPIU_DBG_FDEST, "completed RECV entry %d, rreq=%p\n", (int) i, e->u.recv.rreq));
+                        /* This wait call won't enter the progress engine.
+                         * It's just a convinient way to pull out the error
+                         * information from the tag. */
+                        MPIR_Process_status(&e->u.recv.rreq->status, &s->req->dev.errflag);
                         MPIR_Request_extract_status(e->u.recv.rreq, e->u.recv.status);
                         MPID_Request_release(e->u.recv.rreq);
                         e->u.recv.rreq = NULL;
                         MPIR_Comm_release(e->u.recv.comm, /*isDisconnect=*/FALSE);
                         dtype_release_if_not_builtin(e->u.recv.datatype);
-                        if (mpi_errno) {
+                        if (e->u.recv.rreq->status.MPI_ERROR)
                             e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
-                            MPIU_ERR_POP(mpi_errno);
-                        }
-                        else {
+                        else
                             e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
-                        }
                     }
                     break;
                 default:
@@ -844,28 +880,40 @@ static int MPIDU_Sched_progress_state(struct MPIDU_Sched_state *state, int *made
                     break;
             }
 
-            if (i == s->idx && e->status == MPIDU_SCHED_ENTRY_STATUS_COMPLETE) {
+            if (i == s->idx && e->status >= MPIDU_SCHED_ENTRY_STATUS_COMPLETE) {
                 ++s->idx;
+                MPIU_DBG_MSG_D(COMM, VERBOSE, "completed OTHER entry %d\n", (int) i);
                 if (e->is_barrier) {
-                    dprintf(stderr, "completed barrier in entry %d\n", i);
                     /* post/perform the next round of operations */
                     mpi_errno = MPIDU_Sched_continue(s);
                     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
                 }
             }
-            else if (e->is_barrier && e->status != MPIDU_SCHED_ENTRY_STATUS_COMPLETE) {
+            else if (e->is_barrier && e->status < MPIDU_SCHED_ENTRY_STATUS_COMPLETE) {
                 /* don't process anything after this barrier entry */
                 break;
             }
         }
 
         if (s->idx == s->num_entries) {
-            dprintf(stderr, "completing and dequeuing s=%p r=%p\n", s, s->req);
+            MPIU_DBG_MSG_FMT(COMM, VERBOSE, (MPIU_DBG_FDEST, "completing and dequeuing s=%p r=%p\n", s, s->req));
 
             /* dequeue this schedule from the state, it's complete */
             MPL_DL_DELETE(state->head, s);
 
             /* TODO refactor into a sched_complete routine? */
+            switch (s->req->dev.errflag) {
+                case MPIR_ERR_PROC_FAILED:
+                    MPIU_ERR_SET(s->req->status.MPI_ERROR, MPIX_ERR_PROC_FAILED, "**comm");
+                    break;
+                case MPIR_ERR_OTHER:
+                    MPIU_ERR_SET(s->req->status.MPI_ERROR, MPI_ERR_OTHER, "**comm");
+                    break;
+                case MPIR_ERR_NONE:
+                default:
+                    break;
+            }
+
             MPID_REQUEST_SET_COMPLETED(s->req);
             MPID_Request_release(s->req);
             s->req = NULL;

http://git.mpich.org/mpich.git/commitdiff/67ec0ab1c7606ef5749797c93192a4b02d879c57

commit 67ec0ab1c7606ef5749797c93192a4b02d879c57
Author: Wesley Bland <wbland at anl.gov>
Date:   Wed Jan 28 13:13:59 2015 -0600

    Add mpir_errflag_t to MPIDI_Request
    
    Non-blocking communication requests need a way to track whether an error
    has occurred in a previous part of the NBC schedule. This adds an
    errflag to the request object itself so the tracking is possible.
    
    Signed-off-by: Huiwei Lu <huiweilu at mcs.anl.gov>

diff --git a/src/mpid/ch3/include/mpidpre.h b/src/mpid/ch3/include/mpidpre.h
index 2bb62b2..6b379cb 100644
--- a/src/mpid/ch3/include/mpidpre.h
+++ b/src/mpid/ch3/include/mpidpre.h
@@ -446,6 +446,9 @@ typedef struct MPIDI_Request {
     struct MPIDI_RMA_Lock_entry *lock_queue_entry;
     MPI_Request resp_request_handle; /* Handle for get_accumulate response */
 
+	/* Errflag for NBC requests. Not used by other requests. */
+	mpir_errflag_t errflag;
+
     MPIDI_REQUEST_SEQNUM
 
     /* Occasionally, when a message cannot be sent, we need to cache the
diff --git a/src/mpid/ch3/src/ch3u_request.c b/src/mpid/ch3/src/ch3u_request.c
index 7e795b2..19c0747 100644
--- a/src/mpid/ch3/src/ch3u_request.c
+++ b/src/mpid/ch3/src/ch3u_request.c
@@ -94,6 +94,7 @@ MPID_Request * MPID_Request_create(void)
         req->dev.user_buf          = NULL;
         req->dev.final_user_buf    = NULL;
         req->dev.drop_data         = FALSE;
+        req->dev.errflag           = MPIR_ERR_NONE;
 #ifdef MPIDI_CH3_REQUEST_INIT
 	MPIDI_CH3_REQUEST_INIT(req);
 #endif

http://git.mpich.org/mpich.git/commitdiff/3dae695980abe2580f98e82a08121756cceaf06f

commit 3dae695980abe2580f98e82a08121756cceaf06f
Author: Wesley Bland <wbland at anl.gov>
Date:   Wed Jan 28 13:12:18 2015 -0600

    Move mpir_errflag_t to mpitypedefs.h
    
    Having mpir_errflag_t defined in mpiimpl.h causes a problem if it needs
    to be used in some other headers. This moves the definition to
    mpitypedefs.h so it can be used elsewhere.
    
    Signed-off-by: Huiwei Lu <huiweilu at mcs.anl.gov>

diff --git a/src/include/mpiimpl.h b/src/include/mpiimpl.h
index 1e007f3..3906e52 100644
--- a/src/include/mpiimpl.h
+++ b/src/include/mpiimpl.h
@@ -720,14 +720,6 @@ extern MPID_Errhandler MPID_Errhandler_direct[];
     } while (0)
 /* ------------------------------------------------------------------------- */
 
-/* Define a typedef for the errflag value used by many internal functions.
- * If an error needs to be returned, these values can be used to signal such.
- * More details can be found further down in the code with the bitmasking logic */
-typedef enum {MPIR_ERR_NONE = MPI_SUCCESS,
-              MPIR_ERR_PROC_FAILED = MPIX_ERR_PROC_FAILED,
-              MPIR_ERR_OTHER = MPI_ERR_OTHER}
-mpir_errflag_t;
-
 /* ------------------------------------------------------------------------- */
 /* Keyvals and attributes */
 /*TKyOverview.tex
diff --git a/src/include/mpitypedefs.h b/src/include/mpitypedefs.h
index 95fe3aa..91e6207 100644
--- a/src/include/mpitypedefs.h
+++ b/src/include/mpitypedefs.h
@@ -68,6 +68,14 @@ typedef uint16_t MPIR_Context_id_t;
 
 typedef MPIU_SIZE_T MPIU_Size_t;
 
+/* Define a typedef for the errflag value used by many internal functions.
+ * If an error needs to be returned, these values can be used to signal such.
+ * More details can be found further down in the code with the bitmasking logic */
+typedef enum {MPIR_ERR_NONE = MPI_SUCCESS,
+              MPIR_ERR_PROC_FAILED = MPIX_ERR_PROC_FAILED,
+              MPIR_ERR_OTHER = MPI_ERR_OTHER}
+mpir_errflag_t;
+
 /* Use the MPIU_PtrToXXX macros to convert pointers to and from integer types */
 
 /* The Microsoft compiler will not allow casting of different sized types 

http://git.mpich.org/mpich.git/commitdiff/6556f351cc454a2c858280d7a94ce83b124f6480

commit 6556f351cc454a2c858280d7a94ce83b124f6480
Author: Wesley Bland <wbland at anl.gov>
Date:   Wed Jan 28 12:27:05 2015 -0600

    Add MPIC_Issend
    
    Part of converting the NBC code to use the MPIC_* functions requires
    an MPIC_Issend function to exist. This adds it.
    
    Signed-off-by: Huiwei Lu <huiweilu at mcs.anl.gov>

diff --git a/src/include/mpiimpl.h b/src/include/mpiimpl.h
index 4724314..1e007f3 100644
--- a/src/include/mpiimpl.h
+++ b/src/include/mpiimpl.h
@@ -3964,6 +3964,8 @@ int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
                              MPID_Comm *comm_ptr, MPI_Status *status, mpir_errflag_t *errflag);
 int MPIC_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
                   MPID_Comm *comm_ptr, MPID_Request **request, mpir_errflag_t *errflag);
+int MPIC_Issend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
+                  MPID_Comm *comm_ptr, MPID_Request **request, mpir_errflag_t *errflag);
 int MPIC_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
                   int tag, MPID_Comm *comm_ptr, MPID_Request **request);
 int MPIC_Waitall(int numreq, MPID_Request *requests[], MPI_Status statuses[], mpir_errflag_t *errflag);
diff --git a/src/mpi/coll/helper_fns.c b/src/mpi/coll/helper_fns.c
index e5e8d06..97ebd0b 100644
--- a/src/mpi/coll/helper_fns.c
+++ b/src/mpi/coll/helper_fns.c
@@ -655,6 +655,47 @@ int MPIC_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int
 }
 
 #undef FUNCNAME
+#define FUNCNAME MPIC_Issend
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIC_Issend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
+                  MPID_Comm *comm_ptr, MPID_Request **request_ptr, mpir_errflag_t *errflag)
+{
+    int mpi_errno = MPI_SUCCESS;
+    int context_id;
+    MPIDI_STATE_DECL(MPID_STATE_MPIC_ISSEND);
+
+    MPIDI_FUNC_ENTER(MPID_STATE_MPIC_ISSEND);
+
+    MPIU_DBG_MSG_D(PT2PT, TYPICAL, "IN: errflag = %d", *errflag);
+
+    MPIU_ERR_CHKANDJUMP1((count < 0), mpi_errno, MPI_ERR_COUNT,
+                         "**countneg", "**countneg %d", count);
+
+    switch(*errflag) {
+        case MPIR_ERR_NONE:
+            break;
+        case MPIR_ERR_PROC_FAILED:
+            MPIR_TAG_SET_PROC_FAILURE_BIT(tag);
+        default:
+            MPIR_TAG_SET_ERROR_BIT(tag);
+    }
+
+    context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
+        MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
+
+    mpi_errno = MPID_Issend(buf, count, datatype, dest, tag, comm_ptr,
+            context_id, request_ptr);
+    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+
+ fn_exit:
+    MPIDI_FUNC_EXIT(MPID_STATE_MPIC_ISSEND);
+    return mpi_errno;
+ fn_fail:
+    goto fn_exit;
+}
+
+#undef FUNCNAME
 #define FUNCNAME MPIC_Irecv
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)

http://git.mpich.org/mpich.git/commitdiff/54362c008ee413b40d5e4f654b72ee45091f1c33

commit 54362c008ee413b40d5e4f654b72ee45091f1c33
Author: Wesley Bland <wbland at anl.gov>
Date:   Tue Jan 27 16:11:58 2015 -0600

    Refactor MPIC functions to use the MPID objects
    
    The MPIC helper functions have been using MPI_Comm and MPI_Request
    objects instead of their MPID_* counterparts. This leads to a bunch of
    unnecessary conversions back and forth between the two types of objects
    and makes the work incompatible with other parts of the codebase
    (non-blocking collectives for instance).
    
    This patch converts all of the MPIC_* functions to use MPID_Comm and
    MPID_Request and changes all of the collective calls to use them now
    too.
    
    Signed-off-by: Huiwei Lu <huiweilu at mcs.anl.gov>

diff --git a/src/include/mpiimpl.h b/src/include/mpiimpl.h
index c1439d3..4724314 100644
--- a/src/include/mpiimpl.h
+++ b/src/include/mpiimpl.h
@@ -3949,24 +3949,24 @@ int MPIC_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status);
 
 /* FT versions of te MPIC_ functions */
 int MPIC_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
-                 MPI_Comm comm, mpir_errflag_t *errflag);
+                 MPID_Comm *comm_ptr, mpir_errflag_t *errflag);
 int MPIC_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
-                 MPI_Comm comm, MPI_Status *status, mpir_errflag_t *errflag);
+                 MPID_Comm *comm_ptr, MPI_Status *status, mpir_errflag_t *errflag);
 int MPIC_Ssend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
-                  MPI_Comm comm, mpir_errflag_t *errflag);
+                  MPID_Comm *comm_ptr, mpir_errflag_t *errflag);
 int MPIC_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                      int dest, int sendtag, void *recvbuf, int recvcount,
                      MPI_Datatype recvtype, int source, int recvtag,
-                     MPI_Comm comm, MPI_Status *status, mpir_errflag_t *errflag);
+                     MPID_Comm *comm_ptr, MPI_Status *status, mpir_errflag_t *errflag);
 int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
                              int dest, int sendtag,
                              int source, int recvtag,
-                             MPI_Comm comm, MPI_Status *status, mpir_errflag_t *errflag);
+                             MPID_Comm *comm_ptr, MPI_Status *status, mpir_errflag_t *errflag);
 int MPIC_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
-                  MPI_Comm comm, MPI_Request *request, mpir_errflag_t *errflag);
+                  MPID_Comm *comm_ptr, MPID_Request **request, mpir_errflag_t *errflag);
 int MPIC_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
-                  int tag, MPI_Comm comm, MPI_Request *request);
-int MPIC_Waitall(int numreq, MPI_Request requests[], MPI_Status statuses[], mpir_errflag_t *errflag);
+                  int tag, MPID_Comm *comm_ptr, MPID_Request **request);
+int MPIC_Waitall(int numreq, MPID_Request *requests[], MPI_Status statuses[], mpir_errflag_t *errflag);
 
 
 void MPIR_MAXF  ( void *, void *, int *, MPI_Datatype * ) ;
diff --git a/src/mpi/coll/allgather.c b/src/mpi/coll/allgather.c
index 7d6799e..24f0817 100644
--- a/src/mpi/coll/allgather.c
+++ b/src/mpi/coll/allgather.c
@@ -127,7 +127,6 @@ int MPIR_Allgather_intra (
     int j, i, pof2, src, rem;
     void *tmp_buf = NULL;
     int curr_cnt, dst, type_size, left, right, jnext;
-    MPI_Comm comm;
     MPI_Status status;
     int mask, dst_tree_root, my_tree_root, is_homogeneous,  
         send_offset, recv_offset, last_recv_cnt = 0, nprocs_completed, k,
@@ -140,8 +139,7 @@ int MPIR_Allgather_intra (
 
     if (((sendcount == 0) && (sendbuf != MPI_IN_PLACE)) || (recvcount == 0))
         return MPI_SUCCESS;
-    
-    comm = comm_ptr->handle;
+
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -209,7 +207,7 @@ int MPIR_Allgather_intra (
                                                  ((char *)recvbuf + recv_offset),
                                                  (comm_size-dst_tree_root)*recvcount,
                                                  recvtype, dst,
-                                                 MPIR_ALLGATHER_TAG, comm, &status, errflag);
+                                                 MPIR_ALLGATHER_TAG, comm_ptr, &status, errflag);
 		    if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -271,7 +269,7 @@ int MPIR_Allgather_intra (
                             mpi_errno = MPIC_Send(((char *)recvbuf + offset),
                                                      last_recv_cnt,
                                                      recvtype, dst,
-                                                     MPIR_ALLGATHER_TAG, comm, errflag); 
+                                                     MPIR_ALLGATHER_TAG, comm_ptr, errflag);
                             /* last_recv_cnt was set in the previous
                                receive. that's the amount of data to be
                                sent now. */
@@ -291,7 +289,7 @@ int MPIR_Allgather_intra (
                                                      (comm_size - (my_tree_root + mask))*recvcount,
                                                      recvtype, dst,
                                                      MPIR_ALLGATHER_TAG,
-                                                     comm, &status, errflag); 
+                                                     comm_ptr, &status, errflag);
                             /* nprocs_completed is also equal to the
                                no. of processes whose data we don't have */
                             if (mpi_errno) {
@@ -377,7 +375,7 @@ int MPIR_Allgather_intra (
                                                  ((char *)tmp_buf + recv_offset),
                                                  tmp_buf_size - recv_offset,
                                                  MPI_BYTE, dst,
-                                                 MPIR_ALLGATHER_TAG, comm, &status, errflag);
+                                                 MPIR_ALLGATHER_TAG, comm_ptr, &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -432,7 +430,7 @@ int MPIR_Allgather_intra (
                             mpi_errno = MPIC_Send(((char *)tmp_buf + offset),
                                                      last_recv_cnt, MPI_BYTE,
                                                      dst, MPIR_ALLGATHER_TAG,
-                                                     comm, errflag);
+                                                     comm_ptr, errflag);
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
                                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -452,7 +450,7 @@ int MPIR_Allgather_intra (
                                                      tmp_buf_size - offset,
                                                      MPI_BYTE, dst,
                                                      MPIR_ALLGATHER_TAG,
-                                                     comm, &status, errflag); 
+                                                     comm_ptr, &status, errflag);
                             /* nprocs_completed is also equal to the
                                no. of processes whose data we don't have */
                             if (mpi_errno) {
@@ -528,7 +526,7 @@ int MPIR_Allgather_intra (
                                          MPIR_ALLGATHER_TAG,
                                          ((char *)tmp_buf + curr_cnt*recvtype_extent),
                                          curr_cnt, recvtype,
-                                         src, MPIR_ALLGATHER_TAG, comm,
+                                         src, MPIR_ALLGATHER_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
@@ -551,7 +549,7 @@ int MPIR_Allgather_intra (
                                          dst, MPIR_ALLGATHER_TAG,
                                          ((char *)tmp_buf + curr_cnt*recvtype_extent),
                                          rem * recvcount, recvtype,
-                                         src, MPIR_ALLGATHER_TAG, comm,
+                                         src, MPIR_ALLGATHER_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
@@ -613,7 +611,7 @@ int MPIR_Allgather_intra (
                                          ((char *)recvbuf +
                                           jnext*recvcount*recvtype_extent), 
                                          recvcount, recvtype, left, 
-                                         MPIR_ALLGATHER_TAG, comm,
+                                         MPIR_ALLGATHER_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
diff --git a/src/mpi/coll/allgatherv.c b/src/mpi/coll/allgatherv.c
index 8064713..b3fcfbf 100644
--- a/src/mpi/coll/allgatherv.c
+++ b/src/mpi/coll/allgatherv.c
@@ -100,7 +100,6 @@ int MPIR_Allgatherv_intra (
     MPID_Comm *comm_ptr,
     mpir_errflag_t *errflag )
 {
-    MPI_Comm comm;
     int        comm_size, rank, j, i, left, right;
     int mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
@@ -121,7 +120,6 @@ int MPIR_Allgatherv_intra (
     /* check if multiple threads are calling this collective function */
     MPIDU_ERR_CHECK_MULTIPLE_THREADS_ENTER( comm_ptr );
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
     
@@ -214,7 +212,7 @@ int MPIR_Allgatherv_intra (
                                                  ((char *)tmp_buf + recv_offset * recvtype_extent),
                                                  total_count - recv_offset, recvtype, dst,
                                                  MPIR_ALLGATHERV_TAG,
-                                                 comm, &status, errflag);
+                                                 comm_ptr, &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -282,7 +280,7 @@ int MPIR_Allgatherv_intra (
                             mpi_errno = MPIC_Send(((char *)tmp_buf + offset),
                                                      last_recv_cnt,
                                                      recvtype, dst,
-                                                     MPIR_ALLGATHERV_TAG, comm, errflag);
+                                                     MPIR_ALLGATHERV_TAG, comm_ptr, errflag);
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
                                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -306,7 +304,7 @@ int MPIR_Allgatherv_intra (
                             mpi_errno = MPIC_Recv(((char *)tmp_buf + offset * recvtype_extent),
                                                      total_count - offset, recvtype,
                                                      dst, MPIR_ALLGATHERV_TAG,
-                                                     comm, &status, errflag);
+                                                     comm_ptr, &status, errflag);
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
                                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -415,7 +413,7 @@ int MPIR_Allgatherv_intra (
                                                  MPIR_ALLGATHERV_TAG,  
                                                  ((char *)tmp_buf + recv_offset),
                                                  tmp_buf_size-recv_offset, MPI_BYTE, dst,
-                                                 MPIR_ALLGATHERV_TAG, comm, &status, errflag);
+                                                 MPIR_ALLGATHERV_TAG, comm_ptr, &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -475,7 +473,7 @@ int MPIR_Allgatherv_intra (
                             mpi_errno = MPIC_Send(((char *)tmp_buf + offset),
                                                      last_recv_cnt, MPI_BYTE,
                                                      dst, MPIR_ALLGATHERV_TAG,
-                                                     comm, errflag);
+                                                     comm_ptr, errflag);
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
                                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -495,7 +493,7 @@ int MPIR_Allgatherv_intra (
                                                      tmp_buf_size-offset, MPI_BYTE,
                                                      dst,
                                                      MPIR_ALLGATHERV_TAG,
-                                                     comm, &status, errflag);
+                                                     comm_ptr, &status, errflag);
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
                                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -577,7 +575,7 @@ int MPIR_Allgatherv_intra (
                                          MPIR_ALLGATHERV_TAG,
                                          ((char *)tmp_buf + curr_cnt*recvtype_extent),
                                          total_count - curr_cnt, recvtype,
-                                         src, MPIR_ALLGATHERV_TAG, comm, &status, errflag);
+                                         src, MPIR_ALLGATHERV_TAG, comm_ptr, &status, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -606,7 +604,7 @@ int MPIR_Allgatherv_intra (
                                          dst, MPIR_ALLGATHERV_TAG,
                                          ((char *)tmp_buf + curr_cnt*recvtype_extent),
                                          total_count - curr_cnt, recvtype,
-                                         src, MPIR_ALLGATHERV_TAG, comm,
+                                         src, MPIR_ALLGATHERV_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
@@ -695,7 +693,7 @@ int MPIR_Allgatherv_intra (
 		 * consecutive processes contribute 0 bytes each. */
 	    }
 	    else if (!sendnow) { /* If there's no data to send, just do a recv call */
-		mpi_errno = MPIC_Recv(rbuf, recvnow, recvtype, left, MPIR_ALLGATHERV_TAG, comm, &status, errflag);
+		mpi_errno = MPIC_Recv(rbuf, recvnow, recvtype, left, MPIR_ALLGATHERV_TAG, comm_ptr, &status, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -705,7 +703,7 @@ int MPIR_Allgatherv_intra (
 		torecv -= recvnow;
 	    }
 	    else if (!recvnow) { /* If there's no data to receive, just do a send call */
-		mpi_errno = MPIC_Send(sbuf, sendnow, recvtype, right, MPIR_ALLGATHERV_TAG, comm, errflag);
+		mpi_errno = MPIC_Send(sbuf, sendnow, recvtype, right, MPIR_ALLGATHERV_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -717,7 +715,7 @@ int MPIR_Allgatherv_intra (
 	    else { /* There's data to be sent and received */
 		mpi_errno = MPIC_Sendrecv(sbuf, sendnow, recvtype, right, MPIR_ALLGATHERV_TAG,
                                              rbuf, recvnow, recvtype, left, MPIR_ALLGATHERV_TAG,
-                                             comm, &status, errflag);
+                                             comm_ptr, &status, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/allred_group.c b/src/mpi/coll/allred_group.c
index 6c66347..ecc9a17 100644
--- a/src/mpi/coll/allred_group.c
+++ b/src/mpi/coll/allred_group.c
@@ -37,7 +37,6 @@ int MPIR_Allreduce_group_intra(void *sendbuf, void *recvbuf, int count,
         send_idx, recv_idx, last_idx, send_cnt, recv_cnt, *cnts, *disps;
     MPI_Aint true_extent, true_lb, extent;
     void *tmp_buf;
-    MPI_Comm comm = comm_ptr->handle;
     int group_rank, group_size;
     int cdst, csrc;
     MPIU_CHKLMEM_DECL(3);
@@ -92,7 +91,7 @@ int MPIR_Allreduce_group_intra(void *sendbuf, void *recvbuf, int count,
             to_comm_rank(cdst, group_rank+1);
             mpi_errno = MPIC_Send(recvbuf, count,
                                      datatype, cdst,
-                                     tag, comm, errflag);
+                                     tag, comm_ptr, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -109,7 +108,7 @@ int MPIR_Allreduce_group_intra(void *sendbuf, void *recvbuf, int count,
             to_comm_rank(csrc, group_rank-1);
             mpi_errno = MPIC_Recv(tmp_buf, count,
                                      datatype, csrc,
-                                     tag, comm,
+                                     tag, comm_ptr,
                                      MPI_STATUS_IGNORE, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
@@ -158,7 +157,7 @@ int MPIR_Allreduce_group_intra(void *sendbuf, void *recvbuf, int count,
                 mpi_errno = MPIC_Sendrecv(recvbuf, count, datatype,
                                              cdst, tag, tmp_buf,
                                              count, datatype, cdst,
-                                             tag, comm,
+                                             tag, comm_ptr,
                                              MPI_STATUS_IGNORE, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -242,7 +241,7 @@ int MPIR_Allreduce_group_intra(void *sendbuf, void *recvbuf, int count,
                                              (char *) tmp_buf +
                                              disps[recv_idx]*extent,
                                              recv_cnt, datatype, cdst,
-                                             tag, comm,
+                                             tag, comm_ptr,
                                              MPI_STATUS_IGNORE, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -308,7 +307,7 @@ int MPIR_Allreduce_group_intra(void *sendbuf, void *recvbuf, int count,
                                              (char *) recvbuf +
                                              disps[recv_idx]*extent,
                                              recv_cnt, datatype, cdst,
-                                             tag, comm,
+                                             tag, comm_ptr,
                                              MPI_STATUS_IGNORE, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -332,13 +331,13 @@ int MPIR_Allreduce_group_intra(void *sendbuf, void *recvbuf, int count,
             to_comm_rank(cdst, group_rank-1);
             mpi_errno = MPIC_Send(recvbuf, count,
                                      datatype, cdst,
-                                     tag, comm, errflag);
+                                     tag, comm_ptr, errflag);
         }
         else { /* even */
             to_comm_rank(csrc, group_rank+1);
             mpi_errno = MPIC_Recv(recvbuf, count,
                                      datatype, csrc,
-                                     tag, comm,
+                                     tag, comm_ptr,
                                      MPI_STATUS_IGNORE, errflag);
         }
         if (mpi_errno) {
diff --git a/src/mpi/coll/allreduce.c b/src/mpi/coll/allreduce.c
index c7dc13f..5da27b3 100644
--- a/src/mpi/coll/allreduce.c
+++ b/src/mpi/coll/allreduce.c
@@ -198,14 +198,12 @@ int MPIR_Allreduce_intra (
         send_idx, recv_idx, last_idx, send_cnt, recv_cnt, *cnts, *disps; 
     MPI_Aint true_extent, true_lb, extent;
     void *tmp_buf;
-    MPI_Comm comm;
     MPIU_CHKLMEM_DECL(3);
     
     /* check if multiple threads are calling this collective function */
     MPIDU_ERR_CHECK_MULTIPLE_THREADS_ENTER( comm_ptr );
 
     if (count == 0) goto fn_exit;
-    comm = comm_ptr->handle;
 
     is_commutative = MPIR_Op_is_commutative(op);
 
@@ -349,7 +347,7 @@ int MPIR_Allreduce_intra (
             if (rank % 2 == 0) { /* even */
                 mpi_errno = MPIC_Send(recvbuf, count,
                                          datatype, rank+1,
-                                         MPIR_ALLREDUCE_TAG, comm, errflag);
+                                         MPIR_ALLREDUCE_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -365,7 +363,7 @@ int MPIR_Allreduce_intra (
             else { /* odd */
                 mpi_errno = MPIC_Recv(tmp_buf, count,
                                          datatype, rank-1,
-                                         MPIR_ALLREDUCE_TAG, comm,
+                                         MPIR_ALLREDUCE_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -411,7 +409,7 @@ int MPIR_Allreduce_intra (
                     mpi_errno = MPIC_Sendrecv(recvbuf, count, datatype,
                                                  dst, MPIR_ALLREDUCE_TAG, tmp_buf,
                                                  count, datatype, dst,
-                                                 MPIR_ALLREDUCE_TAG, comm,
+                                                 MPIR_ALLREDUCE_TAG, comm_ptr,
                                                  MPI_STATUS_IGNORE, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
@@ -496,7 +494,7 @@ int MPIR_Allreduce_intra (
                                                  (char *) tmp_buf +
                                                  disps[recv_idx]*extent,
                                                  recv_cnt, datatype, dst,
-                                                 MPIR_ALLREDUCE_TAG, comm,
+                                                 MPIR_ALLREDUCE_TAG, comm_ptr,
                                                  MPI_STATUS_IGNORE, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
@@ -561,7 +559,7 @@ int MPIR_Allreduce_intra (
                                                  (char *) recvbuf +
                                                  disps[recv_idx]*extent,
                                                  recv_cnt, datatype, dst,
-                                                 MPIR_ALLREDUCE_TAG, comm,
+                                                 MPIR_ALLREDUCE_TAG, comm_ptr,
                                                  MPI_STATUS_IGNORE, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
@@ -584,11 +582,11 @@ int MPIR_Allreduce_intra (
             if (rank % 2)  /* odd */
                 mpi_errno = MPIC_Send(recvbuf, count,
                                          datatype, rank-1,
-                                         MPIR_ALLREDUCE_TAG, comm, errflag);
+                                         MPIR_ALLREDUCE_TAG, comm_ptr, errflag);
             else  /* even */
                 mpi_errno = MPIC_Recv(recvbuf, count,
                                          datatype, rank+1,
-                                         MPIR_ALLREDUCE_TAG, comm,
+                                         MPIR_ALLREDUCE_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
@@ -638,7 +636,6 @@ int MPIR_Allreduce_inter (
     MPI_Aint true_extent, true_lb, extent;
     void *tmp_buf=NULL;
     MPID_Comm *newcomm_ptr = NULL;
-    MPI_Comm comm;
     MPIU_CHKLMEM_DECL(1);
 
     MPIDU_ERR_CHECK_MULTIPLE_THREADS_ENTER( comm_ptr );
@@ -655,8 +652,6 @@ int MPIR_Allreduce_inter (
         tmp_buf = (void *)((char*)tmp_buf - true_lb);
     }
 
-    comm = comm_ptr->handle;
-
     /* Get the local intracommunicator */
     if (!comm_ptr->local_comm)
         MPIR_Setup_intercomm_localcomm( comm_ptr );
@@ -677,7 +672,7 @@ int MPIR_Allreduce_inter (
     if (comm_ptr->rank == 0) {
         mpi_errno = MPIC_Sendrecv(tmp_buf, count, datatype, 0, MPIR_REDUCE_TAG,
                                   recvbuf, count, datatype, 0, MPIR_REDUCE_TAG,
-                                  comm, MPI_STATUS_IGNORE, errflag);
+                                  comm_ptr, MPI_STATUS_IGNORE, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/alltoall.c b/src/mpi/coll/alltoall.c
index 576931d..f3e3c35 100644
--- a/src/mpi/coll/alltoall.c
+++ b/src/mpi/coll/alltoall.c
@@ -147,8 +147,7 @@ int MPIR_Alltoall_intra(
     MPI_Aint pack_size, position;
     MPI_Datatype newtype = MPI_DATATYPE_NULL;
     void *tmp_buf;
-    MPI_Comm comm;
-    MPI_Request *reqarray;
+    MPID_Request **reqarray;
     MPI_Status *starray;
     MPIU_CHKLMEM_DECL(6);
 #ifdef MPIR_OLD_SHORT_ALLTOALL_ALG
@@ -159,7 +158,6 @@ int MPIR_Alltoall_intra(
 
     if (recvcount == 0) return MPI_SUCCESS;
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -192,7 +190,7 @@ int MPIR_Alltoall_intra(
                                                          recvcount, recvtype,
                                                          j, MPIR_ALLTOALL_TAG,
                                                          j, MPIR_ALLTOALL_TAG,
-                                                         comm, &status, errflag);
+                                                         comm_ptr, &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -206,7 +204,7 @@ int MPIR_Alltoall_intra(
                                                          recvcount, recvtype,
                                                          i, MPIR_ALLTOALL_TAG,
                                                          i, MPIR_ALLTOALL_TAG,
-                                                         comm, &status, errflag);
+                                                         comm_ptr, &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -279,7 +277,7 @@ int MPIR_Alltoall_intra(
 
             mpi_errno = MPIC_Sendrecv(tmp_buf, position, MPI_PACKED, dst,
                                          MPIR_ALLTOALL_TAG, recvbuf, 1, newtype,
-                                         src, MPIR_ALLTOALL_TAG, comm,
+                                         src, MPIR_ALLTOALL_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
@@ -371,7 +369,7 @@ int MPIR_Alltoall_intra(
                                               dst_tree_root*sendbuf_extent),
                                              sendbuf_extent*(comm_size-dst_tree_root),
                                              sendtype, dst, MPIR_ALLTOALL_TAG, 
-                                             comm, &status, errflag);
+                                             comm_ptr, &status, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -425,7 +423,7 @@ int MPIR_Alltoall_intra(
                                                   dst_tree_root*sendbuf_extent),
                                                  last_recv_cnt, sendtype,
                                                  dst, MPIR_ALLTOALL_TAG,
-                                                 comm, errflag);  
+                                                 comm_ptr, errflag);
                         if (mpi_errno) {
                             /* for communication errors, just record the error but continue */
                             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -443,7 +441,7 @@ int MPIR_Alltoall_intra(
                                                  sendbuf_extent*(comm_size-dst_tree_root),
                                                  sendtype,   
                                                  dst, MPIR_ALLTOALL_TAG,
-                                                 comm, &status, errflag); 
+                                                 comm_ptr, &status, errflag);
                         if (mpi_errno) {
                             /* for communication errors, just record the error but continue */
                             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -498,7 +496,7 @@ int MPIR_Alltoall_intra(
         bblock = MPIR_CVAR_ALLTOALL_THROTTLE;
         if (bblock == 0) bblock = comm_size;
 
-        MPIU_CHKLMEM_MALLOC(reqarray, MPI_Request *, 2*bblock*sizeof(MPI_Request), mpi_errno, "reqarray");
+        MPIU_CHKLMEM_MALLOC(reqarray, MPID_Request **, 2*bblock*sizeof(MPID_Request*), mpi_errno, "reqarray");
 
         MPIU_CHKLMEM_MALLOC(starray, MPI_Status *, 2*bblock*sizeof(MPI_Status), mpi_errno, "starray");
 
@@ -510,7 +508,7 @@ int MPIR_Alltoall_intra(
                 mpi_errno = MPIC_Irecv((char *)recvbuf +
                                           dst*recvcount*recvtype_extent, 
                                           recvcount, recvtype, dst,
-                                          MPIR_ALLTOALL_TAG, comm,
+                                          MPIR_ALLTOALL_TAG, comm_ptr,
                                           &reqarray[i]);
                 if (mpi_errno) MPIU_ERR_POP(mpi_errno);
             }
@@ -520,7 +518,7 @@ int MPIR_Alltoall_intra(
                 mpi_errno = MPIC_Isend((char *)sendbuf +
                                           dst*sendcount*sendtype_extent, 
                                           sendcount, sendtype, dst,
-                                          MPIR_ALLTOALL_TAG, comm,
+                                          MPIR_ALLTOALL_TAG, comm_ptr,
                                           &reqarray[i+ss], errflag);
                 if (mpi_errno) MPIU_ERR_POP(mpi_errno);
             }
@@ -588,7 +586,7 @@ int MPIR_Alltoall_intra(
                                          ((char *)recvbuf +
                                           src*recvcount*recvtype_extent),
                                          recvcount, recvtype, src,
-                                         MPIR_ALLTOALL_TAG, comm, &status, errflag);
+                                         MPIR_ALLTOALL_TAG, comm_ptr, &status, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -647,12 +645,10 @@ int MPIR_Alltoall_inter(
     MPI_Status status;
     int src, dst, rank;
     char *sendaddr, *recvaddr;
-    MPI_Comm comm;
-    
+
     local_size = comm_ptr->local_size; 
     remote_size = comm_ptr->remote_size;
     rank = comm_ptr->rank;
-    comm = comm_ptr->handle;
 
     /* Get extent of send and recv types */
     MPID_Datatype_get_extent_macro(sendtype, sendtype_extent);
@@ -688,7 +684,7 @@ int MPIR_Alltoall_inter(
         mpi_errno = MPIC_Sendrecv(sendaddr, sendcount, sendtype, dst,
                                      MPIR_ALLTOALL_TAG, recvaddr,
                                      recvcount, recvtype, src,
-                                     MPIR_ALLTOALL_TAG, comm, &status, errflag);
+                                     MPIR_ALLTOALL_TAG, comm_ptr, &status, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/alltoallv.c b/src/mpi/coll/alltoallv.c
index 7db2166..fa53196 100644
--- a/src/mpi/coll/alltoallv.c
+++ b/src/mpi/coll/alltoallv.c
@@ -71,15 +71,13 @@ int MPIR_Alltoallv_intra(const void *sendbuf, const int *sendcounts, const int *
     int mpi_errno_ret = MPI_SUCCESS;
     MPI_Status *starray;
     MPI_Status status;
-    MPI_Request *reqarray;
+    MPID_Request **reqarray;
     int dst, rank, req_cnt;
-    MPI_Comm comm;
     int ii, ss, bblock;
     int type_size;
 
     MPIU_CHKLMEM_DECL(2);
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -108,7 +106,7 @@ int MPIR_Alltoallv_intra(const void *sendbuf, const int *sendcounts, const int *
                                                          recvcounts[j], recvtype,
                                                          j, MPIR_ALLTOALLV_TAG,
                                                          j, MPIR_ALLTOALLV_TAG,
-                                                         comm, &status, errflag);
+                                                         comm_ptr, &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -123,7 +121,7 @@ int MPIR_Alltoallv_intra(const void *sendbuf, const int *sendcounts, const int *
                                                          recvcounts[i], recvtype,
                                                          i, MPIR_ALLTOALLV_TAG,
                                                          i, MPIR_ALLTOALLV_TAG,
-                                                         comm, &status, errflag);
+                                                         comm_ptr, &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -141,7 +139,7 @@ int MPIR_Alltoallv_intra(const void *sendbuf, const int *sendcounts, const int *
         MPID_Datatype_get_extent_macro(sendtype, send_extent);
 
         MPIU_CHKLMEM_MALLOC(starray,  MPI_Status*,  2*bblock*sizeof(MPI_Status),  mpi_errno, "starray");
-        MPIU_CHKLMEM_MALLOC(reqarray, MPI_Request*, 2*bblock*sizeof(MPI_Request), mpi_errno, "reqarray");
+        MPIU_CHKLMEM_MALLOC(reqarray, MPID_Request**, 2*bblock*sizeof(MPID_Request *), mpi_errno, "reqarray");
 
         /* post only bblock isends/irecvs at a time as suggested by Tony Ladd */
         for (ii=0; ii<comm_size; ii+=bblock) {
@@ -158,7 +156,7 @@ int MPIR_Alltoallv_intra(const void *sendbuf, const int *sendcounts, const int *
                                                          rdispls[dst]*recv_extent);
                         mpi_errno = MPIC_Irecv((char *)recvbuf+rdispls[dst]*recv_extent,
                                                   recvcounts[dst], recvtype, dst,
-                                                  MPIR_ALLTOALLV_TAG, comm,
+                                                  MPIR_ALLTOALLV_TAG, comm_ptr,
                                                   &reqarray[req_cnt]);
                         if (mpi_errno) {
                             /* for communication errors, just record the error but continue */
@@ -180,7 +178,7 @@ int MPIR_Alltoallv_intra(const void *sendbuf, const int *sendcounts, const int *
                                                          sdispls[dst]*send_extent);
                         mpi_errno = MPIC_Isend((char *)sendbuf+sdispls[dst]*send_extent,
                                                   sendcounts[dst], sendtype, dst,
-                                                  MPIR_ALLTOALLV_TAG, comm,
+                                                  MPIR_ALLTOALLV_TAG, comm_ptr,
                                                   &reqarray[req_cnt], errflag);
                         if (mpi_errno) {
                             /* for communication errors, just record the error but continue */
@@ -261,11 +259,9 @@ int MPIR_Alltoallv_inter(const void *sendbuf, const int *sendcounts, const int *
     MPI_Status status;
     int src, dst, rank, sendcount, recvcount;
     char *sendaddr, *recvaddr;
-    MPI_Comm comm;
-    
+
     local_size = comm_ptr->local_size; 
     remote_size = comm_ptr->remote_size;
-    comm = comm_ptr->handle;
     rank = comm_ptr->rank;
     
     /* Get extent of send and recv types */
@@ -306,7 +302,7 @@ int MPIR_Alltoallv_inter(const void *sendbuf, const int *sendcounts, const int *
         mpi_errno = MPIC_Sendrecv(sendaddr, sendcount, sendtype, dst,
                                      MPIR_ALLTOALLV_TAG, recvaddr, recvcount, 
                                      recvtype, src, MPIR_ALLTOALLV_TAG,
-                                     comm, &status, errflag);
+                                     comm_ptr, &status, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/alltoallw.c b/src/mpi/coll/alltoallw.c
index ecd8852..e55d55a 100644
--- a/src/mpi/coll/alltoallw.c
+++ b/src/mpi/coll/alltoallw.c
@@ -64,15 +64,13 @@ int MPIR_Alltoallw_intra(const void *sendbuf, const int sendcounts[], const int
     int mpi_errno_ret = MPI_SUCCESS;
     MPI_Status status;
     MPI_Status *starray;
-    MPI_Request *reqarray;
+    MPID_Request **reqarray;
     int dst, rank;
-    MPI_Comm comm;
     int outstanding_requests;
     int ii, ss, bblock;
     int type_size;
     MPIU_CHKLMEM_DECL(2);
-    
-    comm = comm_ptr->handle;
+
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
     
@@ -98,7 +96,7 @@ int MPIR_Alltoallw_intra(const void *sendbuf, const int sendcounts[], const int
                                                          recvcounts[j], recvtypes[j],
                                                          j, MPIR_ALLTOALLW_TAG,
                                                          j, MPIR_ALLTOALLW_TAG,
-                                                         comm, &status, errflag);
+                                                         comm_ptr, &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -112,7 +110,7 @@ int MPIR_Alltoallw_intra(const void *sendbuf, const int sendcounts[], const int
                                                          recvcounts[i], recvtypes[i],
                                                          i, MPIR_ALLTOALLW_TAG,
                                                          i, MPIR_ALLTOALLW_TAG,
-                                                         comm, &status, errflag);
+                                                         comm_ptr, &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -128,7 +126,7 @@ int MPIR_Alltoallw_intra(const void *sendbuf, const int sendcounts[], const int
         if (bblock == 0) bblock = comm_size;
 
         MPIU_CHKLMEM_MALLOC(starray,  MPI_Status*,  2*bblock*sizeof(MPI_Status),  mpi_errno, "starray");
-        MPIU_CHKLMEM_MALLOC(reqarray, MPI_Request*, 2*bblock*sizeof(MPI_Request), mpi_errno, "reqarray");
+        MPIU_CHKLMEM_MALLOC(reqarray, MPID_Request**, 2*bblock*sizeof(MPID_Request *), mpi_errno, "reqarray");
 
         /* post only bblock isends/irecvs at a time as suggested by Tony Ladd */
         for (ii=0; ii<comm_size; ii+=bblock) {
@@ -143,7 +141,7 @@ int MPIR_Alltoallw_intra(const void *sendbuf, const int sendcounts[], const int
                     if (type_size) {
                         mpi_errno = MPIC_Irecv((char *)recvbuf+rdispls[dst],
                                                   recvcounts[dst], recvtypes[dst], dst,
-                                                  MPIR_ALLTOALLW_TAG, comm,
+                                                  MPIR_ALLTOALLW_TAG, comm_ptr,
                                                   &reqarray[outstanding_requests]);
                         if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
 
@@ -159,7 +157,7 @@ int MPIR_Alltoallw_intra(const void *sendbuf, const int sendcounts[], const int
                     if (type_size) {
                         mpi_errno = MPIC_Isend((char *)sendbuf+sdispls[dst],
                                                   sendcounts[dst], sendtypes[dst], dst,
-                                                  MPIR_ALLTOALLW_TAG, comm,
+                                                  MPIR_ALLTOALLW_TAG, comm_ptr,
                                                   &reqarray[outstanding_requests], errflag);
                         if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
 
@@ -206,7 +204,7 @@ int MPIR_Alltoallw_intra(const void *sendbuf, const int sendcounts[], const int
                                          MPIR_ALLTOALLW_TAG, 
                                          ((char *)recvbuf+rdispls[src]), 
                                          recvcounts[src], recvtypes[dst], src,
-                                         MPIR_ALLTOALLW_TAG, comm, &status, errflag);
+                                         MPIR_ALLTOALLW_TAG, comm_ptr, &status, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -301,7 +299,7 @@ int MPIR_Alltoallw_inter(const void *sendbuf, const int sendcounts[], const int
         mpi_errno = MPIC_Sendrecv(sendaddr, sendcount, sendtype,
                                      dst, MPIR_ALLTOALLW_TAG, recvaddr,
                                      recvcount, recvtype, src,
-                                     MPIR_ALLTOALLW_TAG, comm, &status, errflag);
+                                     MPIR_ALLTOALLW_TAG, comm_ptr, &status, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/barrier.c b/src/mpi/coll/barrier.c
index 38a311f..821d77a 100644
--- a/src/mpi/coll/barrier.c
+++ b/src/mpi/coll/barrier.c
@@ -132,7 +132,6 @@ int MPIR_Barrier_intra( MPID_Comm *comm_ptr, mpir_errflag_t *errflag )
 {
     int size, rank, src, dst, mask, mpi_errno=MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
-    MPI_Comm comm;
 
     /* Only one collective operation per communicator can be active at any
        time */
@@ -155,7 +154,6 @@ int MPIR_Barrier_intra( MPID_Comm *comm_ptr, mpir_errflag_t *errflag )
     }
 
     rank = comm_ptr->rank;
-    comm = comm_ptr->handle;
 
     mask = 0x1;
     while (mask < size) {
@@ -163,7 +161,7 @@ int MPIR_Barrier_intra( MPID_Comm *comm_ptr, mpir_errflag_t *errflag )
         src = (rank - mask + size) % size;
         mpi_errno = MPIC_Sendrecv(NULL, 0, MPI_BYTE, dst,
                                      MPIR_BARRIER_TAG, NULL, 0, MPI_BYTE,
-                                     src, MPIR_BARRIER_TAG, comm,
+                                     src, MPIR_BARRIER_TAG, comm_ptr,
                                      MPI_STATUS_IGNORE, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
diff --git a/src/mpi/coll/bcast.c b/src/mpi/coll/bcast.c
index e1abbda..f50b941 100644
--- a/src/mpi/coll/bcast.c
+++ b/src/mpi/coll/bcast.c
@@ -140,11 +140,9 @@ static int MPIR_Bcast_binomial(
     MPI_Aint type_size;
     MPI_Aint position;
     void *tmp_buf=NULL;
-    MPI_Comm comm;
     MPID_Datatype *dtp;
     MPIU_CHKLMEM_DECL(1);
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -231,10 +229,10 @@ static int MPIR_Bcast_binomial(
             if (src < 0) src += comm_size;
             if (!is_contig || !is_homogeneous)
                 mpi_errno = MPIC_Recv(tmp_buf,nbytes,MPI_BYTE,src,
-                                         MPIR_BCAST_TAG,comm, &status, errflag);
+                                         MPIR_BCAST_TAG,comm_ptr, &status, errflag);
             else
                 mpi_errno = MPIC_Recv(buffer,count,datatype,src,
-                                         MPIR_BCAST_TAG,comm, &status, errflag);
+                                         MPIR_BCAST_TAG,comm_ptr, &status, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -277,10 +275,10 @@ static int MPIR_Bcast_binomial(
             if (dst >= comm_size) dst -= comm_size;
             if (!is_contig || !is_homogeneous)
                 mpi_errno = MPIC_Send(tmp_buf,nbytes,MPI_BYTE,dst,
-                                         MPIR_BCAST_TAG,comm, errflag);
+                                         MPIR_BCAST_TAG,comm_ptr, errflag);
             else
                 mpi_errno = MPIC_Send(buffer,count,datatype,dst,
-                                         MPIR_BCAST_TAG,comm, errflag); 
+                                         MPIR_BCAST_TAG,comm_ptr, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -348,9 +346,7 @@ static int scatter_for_bcast(
     int mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
     int scatter_size, curr_size, recv_size = 0, send_size;
-    MPI_Comm comm;
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
     relative_rank = (rank >= root) ? rank - root : rank - root + comm_size;
@@ -392,7 +388,7 @@ static int scatter_for_bcast(
                 mpi_errno = MPIC_Recv(((char *)tmp_buf +
                                           relative_rank*scatter_size),
                                          recv_size, MPI_BYTE, src,
-                                         MPIR_BCAST_TAG, comm, &status, errflag);
+                                         MPIR_BCAST_TAG, comm_ptr, &status, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -428,7 +424,7 @@ static int scatter_for_bcast(
                 mpi_errno = MPIC_Send(((char *)tmp_buf +
                                           scatter_size*(relative_rank+mask)),
                                          send_size, MPI_BYTE, dst,
-                                         MPIR_BCAST_TAG, comm, errflag);
+                                         MPIR_BCAST_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -498,12 +494,10 @@ static int MPIR_Bcast_scatter_doubling_allgather(
     int recv_offset, tree_root, nprocs_completed, offset;
     MPI_Aint position;
     MPIU_CHKLMEM_DECL(1);
-    MPI_Comm comm;
     MPID_Datatype *dtp;
     MPI_Aint true_extent, true_lb;
     void *tmp_buf;
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
     relative_rank = (rank >= root) ? rank - root : rank - root + comm_size;
@@ -611,7 +605,7 @@ static int MPIR_Bcast_scatter_doubling_allgather(
                                          curr_size, MPI_BYTE, dst, MPIR_BCAST_TAG, 
                                          ((char *)tmp_buf + recv_offset),
                                          (nbytes-recv_offset < 0 ? 0 : nbytes-recv_offset), 
-                                         MPI_BYTE, dst, MPIR_BCAST_TAG, comm, &status, errflag);
+                                         MPI_BYTE, dst, MPIR_BCAST_TAG, comm_ptr, &status, errflag);
             if (mpi_errno) {
 		/* --BEGIN ERROR HANDLING-- */
                 /* for communication errors, just record the error but continue */
@@ -685,7 +679,7 @@ static int MPIR_Bcast_scatter_doubling_allgather(
                        fflush(stdout); */
                     mpi_errno = MPIC_Send(((char *)tmp_buf + offset),
                                              recv_size, MPI_BYTE, dst,
-                                             MPIR_BCAST_TAG, comm, errflag); 
+                                             MPIR_BCAST_TAG, comm_ptr, errflag);
                     /* recv_size was set in the previous
                        receive. that's the amount of data to be
                        sent now. */
@@ -707,7 +701,7 @@ static int MPIR_Bcast_scatter_doubling_allgather(
                     mpi_errno = MPIC_Recv(((char *)tmp_buf + offset),
                                              nbytes - offset, 
                                              MPI_BYTE, dst, MPIR_BCAST_TAG,
-                                             comm, &status, errflag); 
+                                             comm_ptr, &status, errflag);
                     /* nprocs_completed is also equal to the no. of processes
                        whose data we don't have */
                     if (mpi_errno) {
@@ -807,12 +801,10 @@ static int MPIR_Bcast_scatter_ring_allgather(
     void *tmp_buf;
     int recvd_size;
     MPI_Status status;
-    MPI_Comm comm;
     MPID_Datatype *dtp;
     MPI_Aint true_extent, true_lb;
     MPIU_CHKLMEM_DECL(1);
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -912,7 +904,7 @@ static int MPIR_Bcast_scatter_ring_allgather(
                                      MPI_BYTE, right, MPIR_BCAST_TAG,
                                      (char *)tmp_buf + left_disp, left_count,
                                      MPI_BYTE, left, MPIR_BCAST_TAG,
-                                     comm, &status, errflag);
+                                     comm_ptr, &status, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -1048,7 +1040,7 @@ static int MPIR_SMP_Bcast(
         {                                                /* and is on our node (!-1) */
             if (root == comm_ptr->rank) {
                 mpi_errno = MPIC_Send(buffer,count,datatype,0,
-                                         MPIR_BCAST_TAG,comm_ptr->node_comm->handle, errflag);
+                                         MPIR_BCAST_TAG,comm_ptr->node_comm, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -1058,7 +1050,7 @@ static int MPIR_SMP_Bcast(
             }
             else if (0 == comm_ptr->node_comm->rank) {
                 mpi_errno = MPIC_Recv(buffer,count,datatype,MPIU_Get_intranode_rank(comm_ptr, root),
-                                         MPIR_BCAST_TAG,comm_ptr->node_comm->handle, &status, errflag);
+                                         MPIR_BCAST_TAG,comm_ptr->node_comm, &status, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -1363,12 +1355,10 @@ int MPIR_Bcast_inter (
     int mpi_errno_ret = MPI_SUCCESS;
     MPI_Status status;
     MPID_Comm *newcomm_ptr = NULL;
-    MPI_Comm comm;
     MPID_MPI_STATE_DECL(MPID_STATE_MPIR_BCAST_INTER);
 
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_BCAST_INTER);
 
-    comm = comm_ptr->handle;
 
     if (root == MPI_PROC_NULL)
     {
@@ -1380,7 +1370,7 @@ int MPIR_Bcast_inter (
         /* root sends to rank 0 on remote group and returns */
         MPIDU_ERR_CHECK_MULTIPLE_THREADS_ENTER( comm_ptr );
         mpi_errno =  MPIC_Send(buffer, count, datatype, 0,
-                                  MPIR_BCAST_TAG, comm, errflag); 
+                                  MPIR_BCAST_TAG, comm_ptr, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -1398,7 +1388,7 @@ int MPIR_Bcast_inter (
         if (rank == 0)
         {
             mpi_errno = MPIC_Recv(buffer, count, datatype, root,
-                                     MPIR_BCAST_TAG, comm, &status, errflag);
+                                     MPIR_BCAST_TAG, comm_ptr, &status, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/exscan.c b/src/mpi/coll/exscan.c
index f14444a..856dddd 100644
--- a/src/mpi/coll/exscan.c
+++ b/src/mpi/coll/exscan.c
@@ -101,15 +101,13 @@ int MPIR_Exscan (
     MPI_Aint true_extent, true_lb, extent;
     void *partial_scan, *tmp_buf;
     MPID_Op *op_ptr;
-    MPI_Comm comm;
     MPIU_CHKLMEM_DECL(2);
     MPIU_THREADPRIV_DECL;
     
     if (count == 0) return MPI_SUCCESS;
 
     MPIU_THREADPRIV_GET;
-    
-    comm = comm_ptr->handle;
+
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
     
@@ -157,7 +155,7 @@ int MPIR_Exscan (
             mpi_errno = MPIC_Sendrecv(partial_scan, count, datatype,
                                          dst, MPIR_EXSCAN_TAG, tmp_buf,
                                          count, datatype, dst,
-                                         MPIR_EXSCAN_TAG, comm,
+                                         MPIR_EXSCAN_TAG, comm_ptr,
                                          &status, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
diff --git a/src/mpi/coll/gather.c b/src/mpi/coll/gather.c
index fa8a983..ee6384f 100644
--- a/src/mpi/coll/gather.c
+++ b/src/mpi/coll/gather.c
@@ -99,7 +99,6 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
     void *tmp_buf=NULL;
     MPI_Status status;
     MPI_Aint   extent=0;            /* Datatype extent */
-    MPI_Comm comm;
     int blocks[2];
     int displs[2];
     MPI_Aint struct_displs[2];
@@ -110,8 +109,7 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 #ifdef MPID_HAS_HETERO
     int position, recv_size;
 #endif
-    
-    comm = comm_ptr->handle;
+
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -222,7 +220,7 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 			    mpi_errno = MPIC_Recv(((char *)recvbuf +
                                                       (((rank + mask) % comm_size)*recvcount*extent)),
                                                      recvblks * recvcount, recvtype, src,
-                                                     MPIR_GATHER_TAG, comm,
+                                                     MPIR_GATHER_TAG, comm_ptr,
                                                      &status, errflag);
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
@@ -233,7 +231,7 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 			}
 			else if (nbytes < MPIR_CVAR_GATHER_VSMALL_MSG_SIZE) {
 			    mpi_errno = MPIC_Recv(tmp_buf, recvblks * nbytes, MPI_BYTE,
-                                                     src, MPIR_GATHER_TAG, comm, &status, errflag);
+                                                     src, MPIR_GATHER_TAG, comm_ptr, &status, errflag);
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
                                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -256,7 +254,7 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 			    
 			    mpi_errno = MPIC_Recv(recvbuf, 1, tmp_type, src,
-                                                     MPIR_GATHER_TAG, comm, &status, errflag);
+                                                     MPIR_GATHER_TAG, comm_ptr, &status, errflag);
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
                                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -283,7 +281,7 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 			    offset = (mask - 1) * nbytes;
 			mpi_errno = MPIC_Recv(((char *)tmp_buf + offset),
                                                  recvblks * nbytes, MPI_BYTE, src,
-                                                 MPIR_GATHER_TAG, comm,
+                                                 MPIR_GATHER_TAG, comm_ptr,
                                                  &status, errflag);
                         if (mpi_errno) {
                             /* for communication errors, just record the error but continue */
@@ -304,7 +302,7 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 		{
                     /* leaf nodes send directly from sendbuf */
                     mpi_errno = MPIC_Send(sendbuf, sendcount, sendtype, dst,
-                                             MPIR_GATHER_TAG, comm, errflag);
+                                             MPIR_GATHER_TAG, comm_ptr, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -314,7 +312,7 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                 }
                 else if (nbytes < MPIR_CVAR_GATHER_VSMALL_MSG_SIZE) {
 		    mpi_errno = MPIC_Send(tmp_buf, curr_cnt, MPI_BYTE, dst,
-                                             MPIR_GATHER_TAG, comm, errflag);
+                                             MPIR_GATHER_TAG, comm_ptr, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -337,7 +335,7 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
 		    mpi_errno = MPIC_Send(MPI_BOTTOM, 1, tmp_type, dst,
-                                             MPIR_GATHER_TAG, comm, errflag);
+                                             MPIR_GATHER_TAG, comm_ptr, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -409,7 +407,7 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                     src = (src + root) % comm_size;
                     mpi_errno = MPIC_Recv(((char *)tmp_buf + curr_cnt),
                                              tmp_buf_size-curr_cnt, MPI_BYTE, src,
-                                             MPIR_GATHER_TAG, comm, 
+                                             MPIR_GATHER_TAG, comm_ptr,
                                              &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
@@ -429,7 +427,7 @@ int MPIR_Gather_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                 dst = relative_rank ^ mask;
                 dst = (dst + root) % comm_size;
                 mpi_errno = MPIC_Send(tmp_buf, curr_cnt, MPI_BYTE, dst,
-                                         MPIR_GATHER_TAG, comm, errflag);
+                                         MPIR_GATHER_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -512,7 +510,6 @@ int MPIR_Gather_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
     MPI_Aint extent, true_extent, true_lb = 0;
     void *tmp_buf=NULL;
     MPID_Comm *newcomm_ptr = NULL;
-    MPI_Comm comm;
     MPIU_CHKLMEM_DECL(1);
 
     if (root == MPI_PROC_NULL)
@@ -523,7 +520,6 @@ int MPIR_Gather_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 
     MPIDU_ERR_CHECK_MULTIPLE_THREADS_ENTER( comm_ptr );
 
-    comm = comm_ptr->handle;
     remote_size = comm_ptr->remote_size; 
     local_size = comm_ptr->local_size; 
 
@@ -545,7 +541,7 @@ int MPIR_Gather_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 	{
             /* root receives data from rank 0 on remote group */
             mpi_errno = MPIC_Recv(recvbuf, recvcount*remote_size,
-                                     recvtype, 0, MPIR_GATHER_TAG, comm,
+                                     recvtype, 0, MPIR_GATHER_TAG, comm_ptr,
                                      &status, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
@@ -597,7 +593,7 @@ int MPIR_Gather_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 	    {
                 mpi_errno = MPIC_Send(tmp_buf, sendcount*local_size,
                                          sendtype, root,
-                                         MPIR_GATHER_TAG, comm, errflag);
+                                         MPIR_GATHER_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -620,7 +616,7 @@ int MPIR_Gather_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 	    {
                 mpi_errno = MPIC_Recv(((char *)recvbuf+recvcount*i*extent),
                                          recvcount, recvtype, i,
-                                         MPIR_GATHER_TAG, comm, &status, errflag);
+                                         MPIR_GATHER_TAG, comm_ptr, &status, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -632,7 +628,7 @@ int MPIR_Gather_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
         else
 	{
             mpi_errno = MPIC_Send(sendbuf,sendcount,sendtype,root,
-                                     MPIR_GATHER_TAG,comm, errflag);
+                                     MPIR_GATHER_TAG,comm_ptr, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/gatherv.c b/src/mpi/coll/gatherv.c
index d1b6f94..0f8d81a 100644
--- a/src/mpi/coll/gatherv.c
+++ b/src/mpi/coll/gatherv.c
@@ -88,15 +88,13 @@ int MPIR_Gatherv (
     int        comm_size, rank;
     int        mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
-    MPI_Comm comm;
     MPI_Aint       extent;
     int            i, reqs;
     int min_procs;
-    MPI_Request *reqarray;
+    MPID_Request **reqarray;
     MPI_Status *starray;
     MPIU_CHKLMEM_DECL(2);
-    
-    comm = comm_ptr->handle;
+
     rank = comm_ptr->rank;
     
     /* check if multiple threads are calling this collective function */
@@ -115,7 +113,7 @@ int MPIR_Gatherv (
         MPID_Ensure_Aint_fits_in_pointer(MPI_VOID_PTR_CAST_TO_MPI_AINT recvbuf +
 					 displs[rank] * extent);
 
-        MPIU_CHKLMEM_MALLOC(reqarray, MPI_Request *, comm_size * sizeof(MPI_Request), mpi_errno, "reqarray");
+        MPIU_CHKLMEM_MALLOC(reqarray, MPID_Request **, comm_size * sizeof(MPID_Request *), mpi_errno, "reqarray");
         MPIU_CHKLMEM_MALLOC(starray, MPI_Status *, comm_size * sizeof(MPI_Status), mpi_errno, "starray");
 
         reqs = 0;
@@ -132,7 +130,7 @@ int MPIR_Gatherv (
                 else {
                     mpi_errno = MPIC_Irecv(((char *)recvbuf+displs[i]*extent),
                                               recvcounts[i], recvtype, i,
-                                              MPIR_GATHERV_TAG, comm,
+                                              MPIR_GATHERV_TAG, comm_ptr,
                                               &reqarray[reqs++]);
                     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
                 }
@@ -174,7 +172,7 @@ int MPIR_Gatherv (
 
             if (comm_size >= min_procs) {
                 mpi_errno = MPIC_Ssend(sendbuf, sendcount, sendtype, root,
-                                          MPIR_GATHERV_TAG, comm, errflag);
+                                          MPIR_GATHERV_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -184,7 +182,7 @@ int MPIR_Gatherv (
             }
             else {
                 mpi_errno = MPIC_Send(sendbuf, sendcount, sendtype, root,
-                                         MPIR_GATHERV_TAG, comm, errflag);
+                                         MPIR_GATHERV_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/helper_fns.c b/src/mpi/coll/helper_fns.c
index 3244496..e5e8d06 100644
--- a/src/mpi/coll/helper_fns.c
+++ b/src/mpi/coll/helper_fns.c
@@ -9,6 +9,9 @@
 #include "datatype.h"
 
 #define COPY_BUFFER_SZ 16384
+#if !defined(MPIC_REQUEST_PTR_ARRAY_SIZE)
+#define MPIC_REQUEST_PTR_ARRAY_SIZE 64
+#endif
 
 /* These functions are used in the implementation of collective
    operations. They are wrappers around MPID send/recv functions. They do
@@ -267,12 +270,11 @@ int MPIC_Wait(MPID_Request * request_ptr, mpir_errflag_t *errflag)
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
 int MPIC_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
-                 MPI_Comm comm, mpir_errflag_t *errflag)
+                 MPID_Comm *comm_ptr, mpir_errflag_t *errflag)
 {
     int mpi_errno = MPI_SUCCESS;
     int context_id;
     MPID_Request *request_ptr = NULL;
-    MPID_Comm *comm_ptr = NULL;
     MPIDI_STATE_DECL(MPID_STATE_MPIC_SEND);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIC_SEND);
@@ -291,7 +293,6 @@ int MPIC_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int t
             MPIR_TAG_SET_ERROR_BIT(tag);
     }
 
-    MPID_Comm_get_ptr(comm, comm_ptr);
     context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
         MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
 
@@ -327,13 +328,12 @@ int MPIC_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int t
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
 int MPIC_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
-                 MPI_Comm comm, MPI_Status *status, mpir_errflag_t *errflag)
+                 MPID_Comm *comm_ptr, MPI_Status *status, mpir_errflag_t *errflag)
 {
     int mpi_errno = MPI_SUCCESS;
     int context_id;
     MPI_Status mystatus;
     MPID_Request *request_ptr = NULL;
-    MPID_Comm *comm_ptr = NULL;
     MPIDI_STATE_DECL(MPID_STATE_MPIC_RECV);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIC_RECV);
@@ -343,7 +343,6 @@ int MPIC_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
     MPIU_ERR_CHKANDJUMP1((count < 0), mpi_errno, MPI_ERR_COUNT,
                          "**countneg", "**countneg %d", count);
 
-    MPID_Comm_get_ptr(comm, comm_ptr);
     context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
         MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
 
@@ -385,12 +384,11 @@ int MPIC_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
 int MPIC_Ssend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
-                  MPI_Comm comm, mpir_errflag_t *errflag)
+                  MPID_Comm *comm_ptr, mpir_errflag_t *errflag)
 {
     int mpi_errno = MPI_SUCCESS;
     int context_id;
     MPID_Request *request_ptr = NULL;
-    MPID_Comm *comm_ptr = NULL;
     MPIDI_STATE_DECL(MPID_STATE_MPIC_SSEND);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIC_SSEND);
@@ -400,7 +398,6 @@ int MPIC_Ssend(const void *buf, int count, MPI_Datatype datatype, int dest, int
     MPIU_ERR_CHKANDJUMP1((count < 0), mpi_errno, MPI_ERR_COUNT,
             "**countneg", "**countneg %d", count);
 
-    MPID_Comm_get_ptr(comm, comm_ptr);
     context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
         MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
 
@@ -447,13 +444,12 @@ int MPIC_Ssend(const void *buf, int count, MPI_Datatype datatype, int dest, int
 int MPIC_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                      int dest, int sendtag, void *recvbuf, int recvcount,
                      MPI_Datatype recvtype, int source, int recvtag,
-                     MPI_Comm comm, MPI_Status *status, mpir_errflag_t *errflag)
+                     MPID_Comm *comm_ptr, MPI_Status *status, mpir_errflag_t *errflag)
 {
     int mpi_errno = MPI_SUCCESS;
     int context_id;
     MPI_Status mystatus;
     MPID_Request *recv_req_ptr = NULL, *send_req_ptr = NULL;
-    MPID_Comm *comm_ptr = NULL;
     MPIDI_STATE_DECL(MPID_STATE_MPIC_SENDRECV);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIC_SENDRECV);
@@ -465,7 +461,6 @@ int MPIC_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
     MPIU_ERR_CHKANDJUMP1((recvcount < 0), mpi_errno, MPI_ERR_COUNT,
                          "**countneg", "**countneg %d", recvcount);
 
-    MPID_Comm_get_ptr(comm, comm_ptr);
     context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
         MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
 
@@ -527,7 +522,7 @@ int MPIC_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
                              int dest, int sendtag,
                              int source, int recvtag,
-                             MPI_Comm comm, MPI_Status *status, mpir_errflag_t *errflag)
+                             MPID_Comm *comm_ptr, MPI_Status *status, mpir_errflag_t *errflag)
 {
     int mpi_errno = MPI_SUCCESS;
     MPI_Status mystatus;
@@ -537,7 +532,6 @@ int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
     void *tmpbuf = NULL;
     MPI_Aint tmpbuf_size = 0;
     MPI_Aint tmpbuf_count = 0;
-    MPID_Comm *comm_ptr;
     MPIU_CHKLMEM_DECL(1);
     MPIDI_STATE_DECL(MPID_STATE_MPIC_SENDRECV_REPLACE);
 #ifdef MPID_LOG_ARROWS
@@ -562,7 +556,6 @@ int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
             MPIR_TAG_SET_ERROR_BIT(sendtag);
     }
 
-    MPID_Comm_get_ptr(comm, comm_ptr);
     context_id_offset = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
         MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
 
@@ -625,12 +618,10 @@ int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
 int MPIC_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
-                  MPI_Comm comm, MPI_Request *request, mpir_errflag_t *errflag)
+                  MPID_Comm *comm_ptr, MPID_Request **request_ptr, mpir_errflag_t *errflag)
 {
     int mpi_errno = MPI_SUCCESS;
     int context_id;
-    MPID_Request *request_ptr = NULL;
-    MPID_Comm *comm_ptr = NULL;
     MPIDI_STATE_DECL(MPID_STATE_MPIC_ISEND);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIC_ISEND);
@@ -649,16 +640,13 @@ int MPIC_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int
             MPIR_TAG_SET_ERROR_BIT(tag);
     }
 
-    MPID_Comm_get_ptr(comm, comm_ptr);
     context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
         MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
 
     mpi_errno = MPID_Isend(buf, count, datatype, dest, tag, comm_ptr,
-            context_id, &request_ptr);
+            context_id, request_ptr);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
-    *request = request_ptr->handle;
-
  fn_exit:
     MPIDI_FUNC_EXIT(MPID_STATE_MPIC_ISEND);
     return mpi_errno;
@@ -671,12 +659,10 @@ int MPIC_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
 int MPIC_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
-                  int tag, MPI_Comm comm, MPI_Request *request)
+                  int tag, MPID_Comm *comm_ptr, MPID_Request **request_ptr)
 {
     int mpi_errno = MPI_SUCCESS;
     int context_id;
-    MPID_Request *request_ptr = NULL;
-    MPID_Comm *comm_ptr = NULL;
     MPIDI_STATE_DECL(MPID_STATE_MPIC_IRECV);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIC_IRECV);
@@ -684,16 +670,13 @@ int MPIC_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
     MPIU_ERR_CHKANDJUMP1((count < 0), mpi_errno, MPI_ERR_COUNT,
                          "**countneg", "**countneg %d", count);
 
-    MPID_Comm_get_ptr(comm, comm_ptr);
     context_id = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
         MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
 
     mpi_errno = MPID_Irecv(buf, count, datatype, source, tag, comm_ptr,
-            context_id, &request_ptr);
+            context_id, request_ptr);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
-    *request = request_ptr->handle;
-
  fn_exit:
     MPIDI_FUNC_EXIT(MPID_STATE_MPIC_IRECV);
     return mpi_errno;
@@ -706,34 +689,53 @@ int MPIC_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
 #define FUNCNAME MPIC_Waitall
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIC_Waitall(int numreq, MPI_Request requests[], MPI_Status statuses[], mpir_errflag_t *errflag)
+int MPIC_Waitall(int numreq, MPID_Request *requests[], MPI_Status statuses[], mpir_errflag_t *errflag)
 {
     int mpi_errno = MPI_SUCCESS;
     int i;
+    MPI_Request request_ptr_array[MPIC_REQUEST_PTR_ARRAY_SIZE];
+    MPI_Request *request_ptrs = request_ptr_array;
+    MPI_Status status_static_array[MPIC_REQUEST_PTR_ARRAY_SIZE];
+    MPI_Status *status_array = statuses;
     MPIDI_STATE_DECL(MPID_STATE_MPIC_WAITALL);
+    MPIU_CHKLMEM_DECL(2);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIC_WAITALL);
 
-    MPIU_Assert(statuses != MPI_STATUSES_IGNORE);
-
     MPIU_DBG_MSG_S(PT2PT, TYPICAL, "IN: errflag = %s", *errflag?"TRUE":"FALSE");
 
-    /* The MPI_TAG field is not set for send operations, so if we want
-       to check for the error bit in the tag below, we should initialize all
-       tag fields here. */
-    for (i = 0; i < numreq; ++i)
-        statuses[i].MPI_TAG = 0;
+    if (statuses == MPI_STATUSES_IGNORE) {
+        status_array = status_static_array;
+    }
 
-    mpi_errno = MPIR_Waitall_impl(numreq, requests, statuses);
+    if (numreq > MPIC_REQUEST_PTR_ARRAY_SIZE) {
+        MPIU_CHKLMEM_MALLOC(request_ptrs, MPI_Request *, numreq * sizeof(MPI_Request), mpi_errno, "request pointers");
+        MPIU_CHKLMEM_MALLOC(status_array, MPI_Status *, numreq * sizeof(MPI_Status), mpi_errno, "status objects");
+    }
+
+    for (i = 0; i < numreq; ++i) {
+        /* The MPI_TAG field is not set for send operations, so if we want
+        to check for the error bit in the tag below, we should initialize all
+        tag fields here. */
+        status_array[i].MPI_TAG = 0;
+
+        /* Convert the MPID_Request objects to MPI_Request objects */
+        request_ptrs[i] = requests[i]->handle;
+    }
+
+    mpi_errno = MPIR_Waitall_impl(numreq, request_ptrs, status_array);
 
     /* The errflag value here is for all requests, not just a single one.  If
      * in the future, this function is used for multiple collectives at a
      * single time, we may have to change that. */
     for (i = 0; i < numreq; ++i) {
-        MPIR_Process_status(&statuses[i], errflag);
+        MPIR_Process_status(&status_array[i], errflag);
     }
 
  fn_exit:
+    if (numreq > MPIC_REQUEST_PTR_ARRAY_SIZE)
+        MPIU_CHKLMEM_FREEALL();
+
     MPIU_DBG_MSG_D(PT2PT, TYPICAL, "OUT: errflag = %d", *errflag);
     MPIDI_FUNC_EXIT(MPID_STATE_MPIC_WAITALL);
     return mpi_errno;
diff --git a/src/mpi/coll/igather.c b/src/mpi/coll/igather.c
index 5fa603a..7e126fc 100644
--- a/src/mpi/coll/igather.c
+++ b/src/mpi/coll/igather.c
@@ -319,7 +319,7 @@ int MPIR_Igather_binomial(const void *sendbuf, int sendcount, MPI_Datatype sendt
                     src = (src + root) % comm_size;
                     mpi_errno = MPIC_Recv(((char *)tmp_buf + curr_cnt),
                                              tmp_buf_size-curr_cnt, MPI_BYTE, src,
-                                             MPIR_GATHER_TAG, comm,
+                                             MPIR_GATHER_TAG, comm_ptr,
                                              &status, errflag);
                     /* the recv size is larger than what may be sent in
                        some cases. query amount of data actually received */
@@ -333,7 +333,7 @@ int MPIR_Igather_binomial(const void *sendbuf, int sendcount, MPI_Datatype sendt
                 dst = relative_rank ^ mask;
                 dst = (dst + root) % comm_size;
                 mpi_errno = MPIC_Send(tmp_buf, curr_cnt, MPI_BYTE, dst,
-                                         MPIR_GATHER_TAG, comm, errflag);
+                                         MPIR_GATHER_TAG, comm_ptr, errflag);
                 if (mpi_errno) MPIU_ERR_POP(mpi_errno);
                 break;
             }
diff --git a/src/mpi/coll/iscatter.c b/src/mpi/coll/iscatter.c
index 3d842bc..9710a9f 100644
--- a/src/mpi/coll/iscatter.c
+++ b/src/mpi/coll/iscatter.c
@@ -364,7 +364,7 @@ int MPIR_Iscatter_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtyp
                 if (src < 0) src += comm_size;
 
                 mpi_errno = MPIC_Recv(tmp_buf, tmp_buf_size, MPI_BYTE, src,
-                                         MPIR_SCATTER_TAG, comm, &status, errflag);
+                                         MPIR_SCATTER_TAG, comm_ptr, &status, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -395,7 +395,7 @@ int MPIR_Iscatter_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtyp
                 /* mask is also the size of this process's subtree */
                 mpi_errno = MPIC_Send(((char *)tmp_buf + nbytes*mask),
                                          send_subtree_cnt, MPI_BYTE, dst,
-                                         MPIR_SCATTER_TAG, comm, errflag);
+                                         MPIR_SCATTER_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/red_scat.c b/src/mpi/coll/red_scat.c
index fa7105b..40d9ad6 100644
--- a/src/mpi/coll/red_scat.c
+++ b/src/mpi/coll/red_scat.c
@@ -73,7 +73,6 @@ static int MPIR_Reduce_scatter_noncomm(const void *sendbuf, void *recvbuf, const
     void *tmp_buf0;
     void *tmp_buf1;
     void *result_ptr;
-    MPI_Comm comm = comm_ptr->handle;
     MPIU_CHKLMEM_DECL(3);
 
     MPIR_Type_get_true_extent_impl(datatype, &true_lb, &true_extent);
@@ -136,7 +135,7 @@ static int MPIR_Reduce_scatter_noncomm(const void *sendbuf, void *recvbuf, const
                                      size, datatype, peer, MPIR_REDUCE_SCATTER_TAG,
                                      incoming_data + recv_offset*true_extent,
                                      size, datatype, peer, MPIR_REDUCE_SCATTER_TAG,
-                                     comm, MPI_STATUS_IGNORE, errflag);
+                                     comm_ptr, MPI_STATUS_IGNORE, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -257,11 +256,9 @@ int MPIR_Reduce_scatter_intra(const void *sendbuf, void *recvbuf, const int recv
     MPI_Datatype sendtype, recvtype;
     int nprocs_completed, tmp_mask, tree_root, is_commutative;
     MPID_Op *op_ptr;
-    MPI_Comm comm;
     MPIU_THREADPRIV_DECL;
     MPIU_CHKLMEM_DECL(5);
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -345,7 +342,7 @@ int MPIR_Reduce_scatter_intra(const void *sendbuf, void *recvbuf, const int recv
             if (rank % 2 == 0) { /* even */
                 mpi_errno = MPIC_Send(tmp_results, total_count,
                                          datatype, rank+1,
-                                         MPIR_REDUCE_SCATTER_TAG, comm, errflag);
+                                         MPIR_REDUCE_SCATTER_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -361,7 +358,7 @@ int MPIR_Reduce_scatter_intra(const void *sendbuf, void *recvbuf, const int recv
             else { /* odd */
                 mpi_errno = MPIC_Recv(tmp_recvbuf, total_count,
                                          datatype, rank-1,
-                                         MPIR_REDUCE_SCATTER_TAG, comm,
+                                         MPIR_REDUCE_SCATTER_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -444,20 +441,20 @@ int MPIR_Reduce_scatter_intra(const void *sendbuf, void *recvbuf, const int recv
                                                  (char *) tmp_recvbuf +
                                                  newdisps[recv_idx]*extent,
                                                  recv_cnt, datatype, dst,
-                                                 MPIR_REDUCE_SCATTER_TAG, comm,
+                                                 MPIR_REDUCE_SCATTER_TAG, comm_ptr,
                                                  MPI_STATUS_IGNORE, errflag);
                 else if ((send_cnt == 0) && (recv_cnt != 0))
                     mpi_errno = MPIC_Recv((char *) tmp_recvbuf +
                                              newdisps[recv_idx]*extent,
                                              recv_cnt, datatype, dst,
-                                             MPIR_REDUCE_SCATTER_TAG, comm,
+                                             MPIR_REDUCE_SCATTER_TAG, comm_ptr,
                                              MPI_STATUS_IGNORE, errflag);
                 else if ((recv_cnt == 0) && (send_cnt != 0))
                     mpi_errno = MPIC_Send((char *) tmp_results +
                                              newdisps[send_idx]*extent,
                                              send_cnt, datatype,
                                              dst, MPIR_REDUCE_SCATTER_TAG,
-                                             comm, errflag);
+                                             comm_ptr, errflag);
 
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -502,7 +499,7 @@ int MPIR_Reduce_scatter_intra(const void *sendbuf, void *recvbuf, const int recv
                     mpi_errno = MPIC_Send((char *) tmp_results +
                                              disps[rank-1]*extent, recvcounts[rank-1],
                                              datatype, rank-1,
-                                             MPIR_REDUCE_SCATTER_TAG, comm, errflag);
+                                             MPIR_REDUCE_SCATTER_TAG, comm_ptr, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -515,7 +512,7 @@ int MPIR_Reduce_scatter_intra(const void *sendbuf, void *recvbuf, const int recv
                 if (recvcounts[rank]) {
                     mpi_errno = MPIC_Recv(recvbuf, recvcounts[rank],
                                              datatype, rank+1,
-                                             MPIR_REDUCE_SCATTER_TAG, comm,
+                                             MPIR_REDUCE_SCATTER_TAG, comm_ptr,
                                              MPI_STATUS_IGNORE, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
@@ -557,14 +554,14 @@ int MPIR_Reduce_scatter_intra(const void *sendbuf, void *recvbuf, const int recv
                                              recvcounts[dst], datatype, dst,
                                              MPIR_REDUCE_SCATTER_TAG, tmp_recvbuf,
                                              recvcounts[rank], datatype, src,
-                                             MPIR_REDUCE_SCATTER_TAG, comm,
+                                             MPIR_REDUCE_SCATTER_TAG, comm_ptr,
                                              MPI_STATUS_IGNORE, errflag);
             else
                 mpi_errno = MPIC_Sendrecv(((char *)recvbuf+disps[dst]*extent),
                                              recvcounts[dst], datatype, dst,
                                              MPIR_REDUCE_SCATTER_TAG, tmp_recvbuf,
                                              recvcounts[rank], datatype, src,
-                                             MPIR_REDUCE_SCATTER_TAG, comm,
+                                             MPIR_REDUCE_SCATTER_TAG, comm_ptr,
                                              MPI_STATUS_IGNORE, errflag);
             
             if (mpi_errno) {
@@ -740,7 +737,7 @@ int MPIR_Reduce_scatter_intra(const void *sendbuf, void *recvbuf, const int recv
                     mpi_errno = MPIC_Sendrecv(tmp_results, 1, sendtype, dst,
                                                  MPIR_REDUCE_SCATTER_TAG, 
                                                  tmp_recvbuf, 1, recvtype, dst,
-                                                 MPIR_REDUCE_SCATTER_TAG, comm,
+                                                 MPIR_REDUCE_SCATTER_TAG, comm_ptr,
                                                  MPI_STATUS_IGNORE, errflag);
                     received = 1;
                     if (mpi_errno) {
@@ -789,7 +786,7 @@ int MPIR_Reduce_scatter_intra(const void *sendbuf, void *recvbuf, const int recv
                             /* send the current result */
                             mpi_errno = MPIC_Send(tmp_recvbuf, 1, recvtype,
                                                      dst, MPIR_REDUCE_SCATTER_TAG,
-                                                     comm, errflag);
+                                                     comm_ptr, errflag);
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
                                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -804,7 +801,7 @@ int MPIR_Reduce_scatter_intra(const void *sendbuf, void *recvbuf, const int recv
                                  (rank >= tree_root + nprocs_completed)) {
                             mpi_errno = MPIC_Recv(tmp_recvbuf, 1, recvtype, dst,
                                                      MPIR_REDUCE_SCATTER_TAG,
-                                                     comm, MPI_STATUS_IGNORE, errflag); 
+                                                     comm_ptr, MPI_STATUS_IGNORE, errflag);
                             received = 1;
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
diff --git a/src/mpi/coll/red_scat_block.c b/src/mpi/coll/red_scat_block.c
index fdab92e..3f28151 100644
--- a/src/mpi/coll/red_scat_block.c
+++ b/src/mpi/coll/red_scat_block.c
@@ -69,7 +69,6 @@ static int MPIR_Reduce_scatter_block_noncomm (
     void *tmp_buf0;
     void *tmp_buf1;
     void *result_ptr;
-    MPI_Comm comm = comm_ptr->handle;
     MPIU_CHKLMEM_DECL(3);
 
     MPIR_Type_get_true_extent_impl(datatype, &true_lb, &true_extent);
@@ -128,7 +127,7 @@ static int MPIR_Reduce_scatter_block_noncomm (
                                      size, datatype, peer, MPIR_REDUCE_SCATTER_BLOCK_TAG,
                                      incoming_data + recv_offset*true_extent,
                                      size, datatype, peer, MPIR_REDUCE_SCATTER_BLOCK_TAG,
-                                     comm, MPI_STATUS_IGNORE, errflag);
+                                     comm_ptr, MPI_STATUS_IGNORE, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -257,11 +256,9 @@ int MPIR_Reduce_scatter_block_intra (
     MPI_Datatype sendtype, recvtype;
     int nprocs_completed, tmp_mask, tree_root, is_commutative;
     MPID_Op *op_ptr;
-    MPI_Comm comm;
     MPIU_THREADPRIV_DECL;
     MPIU_CHKLMEM_DECL(5);
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -344,7 +341,7 @@ int MPIR_Reduce_scatter_block_intra (
             if (rank % 2 == 0) { /* even */
                 mpi_errno = MPIC_Send(tmp_results, total_count,
                                          datatype, rank+1,
-                                         MPIR_REDUCE_SCATTER_BLOCK_TAG, comm, errflag);
+                                         MPIR_REDUCE_SCATTER_BLOCK_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -360,7 +357,7 @@ int MPIR_Reduce_scatter_block_intra (
             else { /* odd */
                 mpi_errno = MPIC_Recv(tmp_recvbuf, total_count,
                                          datatype, rank-1,
-                                         MPIR_REDUCE_SCATTER_BLOCK_TAG, comm,
+                                         MPIR_REDUCE_SCATTER_BLOCK_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -443,20 +440,20 @@ int MPIR_Reduce_scatter_block_intra (
                                                  (char *) tmp_recvbuf +
                                                  newdisps[recv_idx]*extent,
                                                  recv_cnt, datatype, dst,
-                                                 MPIR_REDUCE_SCATTER_BLOCK_TAG, comm,
+                                                 MPIR_REDUCE_SCATTER_BLOCK_TAG, comm_ptr,
                                                  MPI_STATUS_IGNORE, errflag);
                 else if ((send_cnt == 0) && (recv_cnt != 0))
                     mpi_errno = MPIC_Recv((char *) tmp_recvbuf +
                                              newdisps[recv_idx]*extent,
                                              recv_cnt, datatype, dst,
-                                             MPIR_REDUCE_SCATTER_BLOCK_TAG, comm,
+                                             MPIR_REDUCE_SCATTER_BLOCK_TAG, comm_ptr,
                                              MPI_STATUS_IGNORE, errflag);
                 else if ((recv_cnt == 0) && (send_cnt != 0))
                     mpi_errno = MPIC_Send((char *) tmp_results +
                                              newdisps[send_idx]*extent,
                                              send_cnt, datatype,
                                              dst, MPIR_REDUCE_SCATTER_BLOCK_TAG,
-                                             comm, errflag);
+                                             comm_ptr, errflag);
 
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -497,12 +494,12 @@ int MPIR_Reduce_scatter_block_intra (
                 mpi_errno = MPIC_Send((char *) tmp_results +
                                          disps[rank-1]*extent, recvcount,
                                          datatype, rank-1,
-                                         MPIR_REDUCE_SCATTER_BLOCK_TAG, comm, errflag);
+                                         MPIR_REDUCE_SCATTER_BLOCK_TAG, comm_ptr, errflag);
             }
             else  {   /* even */
                 mpi_errno = MPIC_Recv(recvbuf, recvcount,
                                          datatype, rank+1,
-                                         MPIR_REDUCE_SCATTER_BLOCK_TAG, comm,
+                                         MPIR_REDUCE_SCATTER_BLOCK_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
             }
             if (mpi_errno) {
@@ -543,14 +540,14 @@ int MPIR_Reduce_scatter_block_intra (
                                              recvcount, datatype, dst,
                                              MPIR_REDUCE_SCATTER_BLOCK_TAG, tmp_recvbuf,
                                              recvcount, datatype, src,
-                                             MPIR_REDUCE_SCATTER_BLOCK_TAG, comm,
+                                             MPIR_REDUCE_SCATTER_BLOCK_TAG, comm_ptr,
                                              MPI_STATUS_IGNORE, errflag);
             else
                 mpi_errno = MPIC_Sendrecv(((char *)recvbuf+disps[dst]*extent),
                                              recvcount, datatype, dst,
                                              MPIR_REDUCE_SCATTER_BLOCK_TAG, tmp_recvbuf,
                                              recvcount, datatype, src,
-                                             MPIR_REDUCE_SCATTER_BLOCK_TAG, comm,
+                                             MPIR_REDUCE_SCATTER_BLOCK_TAG, comm_ptr,
                                              MPI_STATUS_IGNORE, errflag);
             
             if (mpi_errno) {
@@ -715,7 +712,7 @@ int MPIR_Reduce_scatter_block_intra (
                     mpi_errno = MPIC_Sendrecv(tmp_results, 1, sendtype, dst,
                                                  MPIR_REDUCE_SCATTER_BLOCK_TAG, 
                                                  tmp_recvbuf, 1, recvtype, dst,
-                                                 MPIR_REDUCE_SCATTER_BLOCK_TAG, comm,
+                                                 MPIR_REDUCE_SCATTER_BLOCK_TAG, comm_ptr,
                                                  MPI_STATUS_IGNORE, errflag);
                     received = 1;
                     if (mpi_errno) {
@@ -764,7 +761,7 @@ int MPIR_Reduce_scatter_block_intra (
                             /* send the current result */
                             mpi_errno = MPIC_Send(tmp_recvbuf, 1, recvtype,
                                                      dst, MPIR_REDUCE_SCATTER_BLOCK_TAG,
-                                                     comm, errflag);
+                                                     comm_ptr, errflag);
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
                                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -779,7 +776,7 @@ int MPIR_Reduce_scatter_block_intra (
                                  (rank >= tree_root + nprocs_completed)) {
                             mpi_errno = MPIC_Recv(tmp_recvbuf, 1, recvtype, dst,
                                                      MPIR_REDUCE_SCATTER_BLOCK_TAG,
-                                                     comm, MPI_STATUS_IGNORE, errflag);
+                                                     comm_ptr, MPI_STATUS_IGNORE, errflag);
                             received = 1;
                             if (mpi_errno) {
                                 /* for communication errors, just record the error but continue */
diff --git a/src/mpi/coll/reduce.c b/src/mpi/coll/reduce.c
index b5cdaa9..1be40f9 100644
--- a/src/mpi/coll/reduce.c
+++ b/src/mpi/coll/reduce.c
@@ -93,12 +93,10 @@ static int MPIR_Reduce_binomial (
     int mask, relrank, source, lroot;
     MPI_Aint true_lb, true_extent, extent; 
     void *tmp_buf;
-    MPI_Comm comm;
     MPIU_CHKLMEM_DECL(2);
 
     if (count == 0) return MPI_SUCCESS;
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -181,7 +179,7 @@ static int MPIR_Reduce_binomial (
             if (source < comm_size) {
                 source = (source + lroot) % comm_size;
                 mpi_errno = MPIC_Recv(tmp_buf, count, datatype, source,
-                                         MPIR_REDUCE_TAG, comm, &status, errflag);
+                                         MPIR_REDUCE_TAG, comm_ptr, &status, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -210,7 +208,7 @@ static int MPIR_Reduce_binomial (
                my parent */
             source = ((relrank & (~ mask)) + lroot) % comm_size;
             mpi_errno  = MPIC_Send(recvbuf, count, datatype,
-                                      source, MPIR_REDUCE_TAG, comm, errflag);
+                                      source, MPIR_REDUCE_TAG, comm_ptr, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -227,12 +225,12 @@ static int MPIR_Reduce_binomial (
         if (rank == 0)
         {
             mpi_errno  = MPIC_Send(recvbuf, count, datatype, root,
-                                      MPIR_REDUCE_TAG, comm, errflag);
+                                      MPIR_REDUCE_TAG, comm_ptr, errflag);
         }
         else if (rank == root)
         {
             mpi_errno = MPIC_Recv(recvbuf, count, datatype, 0,
-                                    MPIR_REDUCE_TAG, comm, &status, errflag);
+                                    MPIR_REDUCE_TAG, comm_ptr, &status, errflag);
         }
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
@@ -302,11 +300,10 @@ static int MPIR_Reduce_redscat_gather (
     int dst, send_cnt, recv_cnt, newroot, newdst_tree_root, newroot_tree_root; 
     MPI_Aint true_lb, true_extent, extent; 
     void *tmp_buf;
-    MPI_Comm comm;
+
     MPIU_CHKLMEM_DECL(4);
     MPIU_THREADPRIV_DECL;
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -373,7 +370,7 @@ static int MPIR_Reduce_redscat_gather (
         if (rank % 2 != 0) { /* odd */
             mpi_errno = MPIC_Send(recvbuf, count,
                                      datatype, rank-1,
-                                     MPIR_REDUCE_TAG, comm, errflag);
+                                     MPIR_REDUCE_TAG, comm_ptr, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -389,7 +386,7 @@ static int MPIR_Reduce_redscat_gather (
         else { /* even */
             mpi_errno = MPIC_Recv(tmp_buf, count,
                                      datatype, rank+1,
-                                     MPIR_REDUCE_TAG, comm,
+                                     MPIR_REDUCE_TAG, comm_ptr,
                                      MPI_STATUS_IGNORE, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
@@ -464,7 +461,7 @@ static int MPIR_Reduce_redscat_gather (
                                          (char *) tmp_buf +
                                          disps[recv_idx]*extent,
                                          recv_cnt, datatype, dst,
-                                         MPIR_REDUCE_TAG, comm,
+                                         MPIR_REDUCE_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
@@ -513,7 +510,7 @@ static int MPIR_Reduce_redscat_gather (
                     disps[i] = disps[i-1] + cnts[i-1];
                 
                 mpi_errno = MPIC_Recv(recvbuf, cnts[0], datatype,
-                                         0, MPIR_REDUCE_TAG, comm,
+                                         0, MPIR_REDUCE_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -527,7 +524,7 @@ static int MPIR_Reduce_redscat_gather (
             }
             else if (newrank == 0) {  /* send */
                 mpi_errno = MPIC_Send(recvbuf, cnts[0], datatype,
-                                         root, MPIR_REDUCE_TAG, comm, errflag);
+                                         root, MPIR_REDUCE_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -601,7 +598,7 @@ static int MPIR_Reduce_redscat_gather (
                                          disps[send_idx]*extent,
                                          send_cnt, datatype,
                                          dst, MPIR_REDUCE_TAG,
-                                         comm, errflag);
+                                         comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -617,7 +614,7 @@ static int MPIR_Reduce_redscat_gather (
                 mpi_errno = MPIC_Recv((char *) recvbuf +
                                          disps[recv_idx]*extent,
                                          recv_cnt, datatype, dst,
-                                         MPIR_REDUCE_TAG, comm,
+                                         MPIR_REDUCE_TAG, comm_ptr,
                                          MPI_STATUS_IGNORE, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -929,7 +926,6 @@ int MPIR_Reduce_inter (
     MPI_Aint true_extent, true_lb, extent;
     void *tmp_buf=NULL;
     MPID_Comm *newcomm_ptr = NULL;
-    MPI_Comm comm;
     MPIU_CHKLMEM_DECL(1);
 
     if (root == MPI_PROC_NULL) {
@@ -938,13 +934,12 @@ int MPIR_Reduce_inter (
     }
 
     MPIDU_ERR_CHECK_MULTIPLE_THREADS_ENTER( comm_ptr );
-    
-    comm = comm_ptr->handle;
+
 
     if (root == MPI_ROOT) {
         /* root receives data from rank 0 on remote group */
         mpi_errno = MPIC_Recv(recvbuf, count, datatype, 0,
-                                 MPIR_REDUCE_TAG, comm, &status, errflag);
+                                 MPIR_REDUCE_TAG, comm_ptr, &status, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -993,7 +988,7 @@ int MPIR_Reduce_inter (
         if (rank == 0)
 	{
             mpi_errno = MPIC_Send(tmp_buf, count, datatype, root,
-                                     MPIR_REDUCE_TAG, comm, errflag);
+                                     MPIR_REDUCE_TAG, comm_ptr, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/scan.c b/src/mpi/coll/scan.c
index 05df09b..ee3bf89 100644
--- a/src/mpi/coll/scan.c
+++ b/src/mpi/coll/scan.c
@@ -86,7 +86,6 @@ static int MPIR_Scan_generic (
     MPI_Aint true_extent, true_lb, extent;
     void *partial_scan, *tmp_buf;
     MPID_Op *op_ptr;
-    MPI_Comm comm;
     MPIU_THREADPRIV_DECL;
     MPIU_CHKLMEM_DECL(2);
     
@@ -95,7 +94,6 @@ static int MPIR_Scan_generic (
     /* check if multiple threads are calling this collective function */
     MPIDU_ERR_CHECK_MULTIPLE_THREADS_ENTER( comm_ptr );
 
-    comm = comm_ptr->handle;
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -157,7 +155,7 @@ static int MPIR_Scan_generic (
             mpi_errno = MPIC_Sendrecv(partial_scan, count, datatype,
                                          dst, MPIR_SCAN_TAG, tmp_buf,
                                          count, datatype, dst,
-                                         MPIR_SCAN_TAG, comm,
+                                         MPIR_SCAN_TAG, comm_ptr,
                                          &status, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
@@ -305,7 +303,7 @@ int MPIR_Scan(
     {
         mpi_errno = MPIC_Recv(localfulldata, count, datatype,
                                  comm_ptr->node_comm->local_size - 1, MPIR_SCAN_TAG, 
-                                 comm_ptr->node_comm->handle, &status, errflag);
+                                 comm_ptr, &status, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -318,7 +316,7 @@ int MPIR_Scan(
              MPIU_Get_intranode_rank(comm_ptr, rank) == comm_ptr->node_comm->local_size - 1)
     {
         mpi_errno = MPIC_Send(recvbuf, count, datatype,
-                                 0, MPIR_SCAN_TAG, comm_ptr->node_comm->handle, errflag);
+                                 0, MPIR_SCAN_TAG, comm_ptr, errflag);
         if (mpi_errno) {
             /* for communication errors, just record the error but continue */
             *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -351,7 +349,7 @@ int MPIR_Scan(
         {
             mpi_errno = MPIC_Send(prefulldata, count, datatype,
                                      MPIU_Get_internode_rank(comm_ptr, rank) + 1,
-                                     MPIR_SCAN_TAG, comm_ptr->node_roots_comm->handle, errflag);
+                                     MPIR_SCAN_TAG, comm_ptr, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -362,9 +360,8 @@ int MPIR_Scan(
         if (MPIU_Get_internode_rank(comm_ptr, rank) != 0)
         {
             mpi_errno = MPIC_Recv(tempbuf, count, datatype,
-                                     MPIU_Get_internode_rank(comm_ptr, rank) - 1, 
-                                     MPIR_SCAN_TAG, comm_ptr->node_roots_comm->handle, 
-                                     &status, errflag);
+                                     MPIU_Get_internode_rank(comm_ptr, rank) - 1,
+                                     MPIR_SCAN_TAG, comm_ptr, &status, errflag);
             noneed = 0;
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
diff --git a/src/mpi/coll/scatter.c b/src/mpi/coll/scatter.c
index 94d9587..ee5f0b7 100644
--- a/src/mpi/coll/scatter.c
+++ b/src/mpi/coll/scatter.c
@@ -85,10 +85,8 @@ int MPIR_Scatter_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype
     void *tmp_buf=NULL;
     int        mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
-    MPI_Comm comm;
     MPIU_CHKLMEM_DECL(4);
-    
-    comm = comm_ptr->handle;
+
     comm_size = comm_ptr->local_size;
     rank = comm_ptr->rank;
 
@@ -184,7 +182,7 @@ int MPIR_Scatter_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype
                    receive data into a temporary buffer. */
                 if (relative_rank % 2) {
                     mpi_errno = MPIC_Recv(recvbuf, recvcount, recvtype,
-                                             src, MPIR_SCATTER_TAG, comm, 
+                                             src, MPIR_SCATTER_TAG, comm_ptr,
                                              &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
@@ -195,7 +193,7 @@ int MPIR_Scatter_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype
                 }
                 else {
                     mpi_errno = MPIC_Recv(tmp_buf, tmp_buf_size, MPI_BYTE, src,
-                                             MPIR_SCATTER_TAG, comm, &status, errflag);
+                                             MPIR_SCATTER_TAG, comm_ptr, &status, errflag);
                     if (mpi_errno) {
                         /* for communication errors, just record the error but continue */
                         *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -231,7 +229,7 @@ int MPIR_Scatter_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype
                                               extent * sendcount * mask),
                                              send_subtree_cnt,
                                              sendtype, dst,
-                                             MPIR_SCATTER_TAG, comm, errflag);
+                                             MPIR_SCATTER_TAG, comm_ptr, errflag);
                 }
                 else
 		{
@@ -241,7 +239,7 @@ int MPIR_Scatter_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype
                     mpi_errno = MPIC_Send(((char *)tmp_buf + nbytes*mask),
                                              send_subtree_cnt,
                                              MPI_BYTE, dst,
-                                             MPIR_SCATTER_TAG, comm, errflag);
+                                             MPIR_SCATTER_TAG, comm_ptr, errflag);
                 }
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
@@ -349,7 +347,7 @@ int MPIR_Scatter_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype
                 if (src < 0) src += comm_size;
                 
                 mpi_errno = MPIC_Recv(tmp_buf, tmp_buf_size, MPI_BYTE, src,
-                                         MPIR_SCATTER_TAG, comm, &status, errflag);
+                                         MPIR_SCATTER_TAG, comm_ptr, &status, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -380,7 +378,7 @@ int MPIR_Scatter_intra(const void *sendbuf, int sendcount, MPI_Datatype sendtype
                 /* mask is also the size of this process's subtree */
                 mpi_errno = MPIC_Send(((char *)tmp_buf + nbytes*mask),
                                          send_subtree_cnt, MPI_BYTE, dst,
-                                         MPIR_SCATTER_TAG, comm, errflag);
+                                         MPIR_SCATTER_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -442,7 +440,6 @@ int MPIR_Scatter_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype
     MPI_Aint extent, true_extent, true_lb = 0;
     void *tmp_buf=NULL;
     MPID_Comm *newcomm_ptr = NULL;
-    MPI_Comm comm;
     MPIU_CHKLMEM_DECL(1);
 
     if (root == MPI_PROC_NULL) {
@@ -450,8 +447,7 @@ int MPIR_Scatter_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype
         return MPI_SUCCESS;
     }
     MPIDU_ERR_CHECK_MULTIPLE_THREADS_ENTER( comm_ptr );
-    
-    comm        = comm_ptr->handle;
+
     remote_size = comm_ptr->remote_size; 
     local_size  = comm_ptr->local_size; 
 
@@ -469,7 +465,7 @@ int MPIR_Scatter_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype
         if (root == MPI_ROOT) {
             /* root sends all data to rank 0 on remote group and returns */
             mpi_errno = MPIC_Send(sendbuf, sendcount*remote_size,
-                                     sendtype, 0, MPIR_SCATTER_TAG, comm, errflag);
+                                     sendtype, 0, MPIR_SCATTER_TAG, comm_ptr, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -499,7 +495,7 @@ int MPIR_Scatter_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype
 
                 mpi_errno = MPIC_Recv(tmp_buf, recvcount*local_size,
                                          recvtype, root,
-                                         MPIR_SCATTER_TAG, comm, &status, errflag);
+                                         MPIR_SCATTER_TAG, comm_ptr, &status, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -533,7 +529,7 @@ int MPIR_Scatter_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype
             for (i=0; i<remote_size; i++) {
                 mpi_errno = MPIC_Send(((char *)sendbuf+sendcount*i*extent),
                                          sendcount, sendtype, i,
-                                         MPIR_SCATTER_TAG, comm, errflag);
+                                         MPIR_SCATTER_TAG, comm_ptr, errflag);
                 if (mpi_errno) {
                     /* for communication errors, just record the error but continue */
                     *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
@@ -544,7 +540,7 @@ int MPIR_Scatter_inter(const void *sendbuf, int sendcount, MPI_Datatype sendtype
         }
         else {
             mpi_errno = MPIC_Recv(recvbuf,recvcount,recvtype,root,
-                                     MPIR_SCATTER_TAG,comm,&status, errflag);
+                                     MPIR_SCATTER_TAG,comm_ptr,&status, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/coll/scatterv.c b/src/mpi/coll/scatterv.c
index 4aaacc3..16fc7cb 100644
--- a/src/mpi/coll/scatterv.c
+++ b/src/mpi/coll/scatterv.c
@@ -59,14 +59,12 @@ int MPIR_Scatterv(const void *sendbuf, const int *sendcounts, const int *displs,
 {
     int rank, comm_size, mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
-    MPI_Comm comm;
     MPI_Aint extent;
     int      i, reqs;
-    MPI_Request *reqarray;
+    MPID_Request **reqarray;
     MPI_Status *starray;
     MPIU_CHKLMEM_DECL(2);
 
-    comm = comm_ptr->handle;
     rank = comm_ptr->rank;
     
     /* check if multiple threads are calling this collective function */
@@ -89,7 +87,7 @@ int MPIR_Scatterv(const void *sendbuf, const int *sendcounts, const int *displs,
          * this? */
         MPID_Ensure_Aint_fits_in_pointer(MPI_VOID_PTR_CAST_TO_MPI_AINT sendbuf + extent);
 
-        MPIU_CHKLMEM_MALLOC(reqarray, MPI_Request *, comm_size * sizeof(MPI_Request), mpi_errno, "reqarray");
+        MPIU_CHKLMEM_MALLOC(reqarray, MPID_Request **, comm_size * sizeof(MPID_Request *), mpi_errno, "reqarray");
         MPIU_CHKLMEM_MALLOC(starray, MPI_Status *, comm_size * sizeof(MPI_Status), mpi_errno, "starray");
 
         reqs = 0;
@@ -106,7 +104,7 @@ int MPIR_Scatterv(const void *sendbuf, const int *sendcounts, const int *displs,
                 else {
                     mpi_errno = MPIC_Isend(((char *)sendbuf+displs[i]*extent),
                                               sendcounts[i], sendtype, i,
-                                              MPIR_SCATTERV_TAG, comm, &reqarray[reqs++], errflag);
+                                              MPIR_SCATTERV_TAG, comm_ptr, &reqarray[reqs++], errflag);
                     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
                 }
             }
@@ -134,7 +132,7 @@ int MPIR_Scatterv(const void *sendbuf, const int *sendcounts, const int *displs,
     else if (root != MPI_PROC_NULL) { /* non-root nodes, and in the intercomm. case, non-root nodes on remote side */
         if (recvcount) {
             mpi_errno = MPIC_Recv(recvbuf,recvcount,recvtype,root,
-                                     MPIR_SCATTERV_TAG,comm,MPI_STATUS_IGNORE, errflag);
+                                     MPIR_SCATTERV_TAG,comm_ptr,MPI_STATUS_IGNORE, errflag);
             if (mpi_errno) {
                 /* for communication errors, just record the error but continue */
                 *errflag = MPIR_ERR_GET_CLASS(mpi_errno);
diff --git a/src/mpi/comm/comm_create.c b/src/mpi/comm/comm_create.c
index abcddde..9d9f100 100644
--- a/src/mpi/comm/comm_create.c
+++ b/src/mpi/comm/comm_create.c
@@ -313,7 +313,6 @@ PMPI_LOCAL int MPIR_Comm_create_inter(MPID_Comm *comm_ptr, MPID_Group *group_ptr
 {
     int mpi_errno = MPI_SUCCESS;
     MPIR_Context_id_t new_context_id;
-    MPI_Comm comm = comm_ptr->handle;
     int *mapping = NULL;
     int *remote_mapping = NULL;
     int remote_size = -1;
@@ -387,7 +386,7 @@ PMPI_LOCAL int MPIR_Comm_create_inter(MPID_Comm *comm_ptr, MPID_Group *group_ptr
 
         mpi_errno = MPIC_Sendrecv(info, 2, MPI_INT, 0, 0,
                                      rinfo, 2, MPI_INT, 0, 0,
-                                     comm, MPI_STATUS_IGNORE, &errflag );
+                                     comm_ptr, MPI_STATUS_IGNORE, &errflag );
         if (mpi_errno) { MPIU_ERR_POP( mpi_errno ); }
         if (*newcomm_ptr != NULL) {
             (*newcomm_ptr)->context_id = rinfo[0];
@@ -401,7 +400,7 @@ PMPI_LOCAL int MPIR_Comm_create_inter(MPID_Comm *comm_ptr, MPID_Group *group_ptr
         /* Populate and exchange the ranks */
         mpi_errno = MPIC_Sendrecv( mapping, group_ptr->size, MPI_INT, 0, 0,
                                       remote_mapping, remote_size, MPI_INT, 0, 0,
-                                      comm, MPI_STATUS_IGNORE, &errflag );
+                                      comm_ptr, MPI_STATUS_IGNORE, &errflag );
         if (mpi_errno) { MPIU_ERR_POP( mpi_errno ); }
 
         /* Broadcast to the other members of the local group */
diff --git a/src/mpi/comm/comm_split.c b/src/mpi/comm/comm_split.c
index 31db2da..effa047 100644
--- a/src/mpi/comm/comm_split.c
+++ b/src/mpi/comm/comm_split.c
@@ -256,7 +256,7 @@ int MPIR_Comm_split_impl(MPID_Comm *comm_ptr, int color, int key, MPID_Comm **ne
 	if (comm_ptr->rank == 0) {
 	    mpi_errno = MPIC_Sendrecv( &new_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, 0,
 				       &remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 
-				       0, 0, comm_ptr->handle, MPI_STATUS_IGNORE, &errflag );
+				       0, 0, comm_ptr, MPI_STATUS_IGNORE, &errflag );
 	    if (mpi_errno) { MPIU_ERR_POP( mpi_errno ); }
 	    mpi_errno = MPIR_Bcast_impl( &remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, local_comm_ptr, &errflag );
             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
diff --git a/src/mpi/comm/commutil.c b/src/mpi/comm/commutil.c
index 171b9d2..cbe659e 100644
--- a/src/mpi/comm/commutil.c
+++ b/src/mpi/comm/commutil.c
@@ -1632,7 +1632,7 @@ int MPIR_Get_intercomm_contextid( MPID_Comm *comm_ptr, MPIR_Context_id_t *contex
     if (comm_ptr->rank == 0) {
         mpi_errno = MPIC_Sendrecv( &mycontext_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, tag,
                                       &remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, tag,
-                                      comm_ptr->handle, MPI_STATUS_IGNORE, &errflag );
+                                      comm_ptr, MPI_STATUS_IGNORE, &errflag );
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
     }
 
diff --git a/src/mpi/comm/intercomm_create.c b/src/mpi/comm/intercomm_create.c
index 41d1a34..69ba0c4 100644
--- a/src/mpi/comm/intercomm_create.c
+++ b/src/mpi/comm/intercomm_create.c
@@ -230,7 +230,7 @@ int MPIR_Intercomm_create_impl(MPID_Comm *local_comm_ptr, int local_leader,
                                       remote_leader, cts_tag,
                                       &remote_size, 1, MPI_INT,
                                       remote_leader, cts_tag,
-                                      peer_comm_ptr->handle, MPI_STATUS_IGNORE, &errflag );
+                                      peer_comm_ptr, MPI_STATUS_IGNORE, &errflag );
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
         MPIU_DBG_MSG_FMT(COMM,VERBOSE,(MPIU_DBG_FDEST, "local size = %d, remote size = %d", local_size,
@@ -249,7 +249,7 @@ int MPIR_Intercomm_create_impl(MPID_Comm *local_comm_ptr, int local_leader,
         mpi_errno = MPIC_Sendrecv( local_gpids, 2*local_size, MPI_INT,
                                       remote_leader, cts_tag,
                                       remote_gpids, 2*remote_size, MPI_INT,
-                                      remote_leader, cts_tag, peer_comm_ptr->handle,
+                                      remote_leader, cts_tag, peer_comm_ptr,
                                       MPI_STATUS_IGNORE, &errflag );
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
@@ -307,7 +307,7 @@ int MPIR_Intercomm_create_impl(MPID_Comm *local_comm_ptr, int local_leader,
 
         mpi_errno = MPIC_Sendrecv( &recvcontext_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, remote_leader, cts_tag,
                                       &remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, remote_leader, cts_tag,
-                                      peer_comm_ptr->handle, MPI_STATUS_IGNORE, &errflag );
+                                      peer_comm_ptr, MPI_STATUS_IGNORE, &errflag );
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
         final_context_id = remote_context_id;
diff --git a/src/mpi/comm/intercomm_merge.c b/src/mpi/comm/intercomm_merge.c
index 0b7b4a5..0b0a941 100644
--- a/src/mpi/comm/intercomm_merge.c
+++ b/src/mpi/comm/intercomm_merge.c
@@ -107,7 +107,7 @@ int MPIR_Intercomm_merge_impl(MPID_Comm *comm_ptr, int high, MPID_Comm **new_int
         /* This routine allows use to use the collective communication
            context rather than the point-to-point context. */
         mpi_errno = MPIC_Sendrecv( &local_high, 1, MPI_INT, 0, 0,
-                                      &remote_high, 1, MPI_INT, 0, 0, comm_ptr->handle,
+                                      &remote_high, 1, MPI_INT, 0, 0, comm_ptr,
                                       MPI_STATUS_IGNORE, &errflag );
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         
@@ -121,7 +121,7 @@ int MPIR_Intercomm_merge_impl(MPID_Comm *comm_ptr, int high, MPID_Comm **new_int
             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
             
             mpi_errno = MPIC_Sendrecv( ingpid, 2, MPI_INT, 0, 1,
-                                          outgpid, 2, MPI_INT, 0, 1, comm_ptr->handle,
+                                          outgpid, 2, MPI_INT, 0, 1, comm_ptr,
                                           MPI_STATUS_IGNORE, &errflag );
             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
diff --git a/src/mpi/topo/dist_gr_create.c b/src/mpi/topo/dist_gr_create.c
index 5913b01..495d00a 100644
--- a/src/mpi/topo/dist_gr_create.c
+++ b/src/mpi/topo/dist_gr_create.c
@@ -75,7 +75,7 @@ int MPI_Dist_graph_create(MPI_Comm comm_old, int n, const int sources[],
     int mpi_errno = MPI_SUCCESS;
     MPID_Comm *comm_ptr = NULL;
     MPID_Comm *comm_dist_graph_ptr = NULL;
-    MPI_Request *reqs = NULL;
+    MPID_Request **reqs = NULL;
     MPIR_Topology *topo_ptr = NULL;
     MPIR_Dist_graph_topology *dist_graph_ptr = NULL;
     int i;
@@ -271,16 +271,16 @@ int MPI_Dist_graph_create(MPI_Comm comm_old, int n, const int sources[],
     idx = 0;
     /* must be 2*comm_size requests because we will possibly send inbound and
      * outbound edges to everyone in our communicator */
-    MPIU_CHKLMEM_MALLOC(reqs, MPI_Request *, 2*comm_size*sizeof(MPI_Request), mpi_errno, "temp request array");
+    MPIU_CHKLMEM_MALLOC(reqs, MPID_Request **, 2*comm_size*sizeof(MPID_Request *), mpi_errno, "temp request array");
     for (i = 0; i < comm_size; ++i) {
         if (rin_sizes[i]) {
             /* send edges where i is a destination to process i */
-            mpi_errno = MPIC_Isend(&rin[i][0], rin_sizes[i], MPI_INT, i, MPIR_TOPO_A_TAG, comm_old, &reqs[idx++], &errflag);
+            mpi_errno = MPIC_Isend(&rin[i][0], rin_sizes[i], MPI_INT, i, MPIR_TOPO_A_TAG, comm_ptr, &reqs[idx++], &errflag);
             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         }
         if (rout_sizes[i]) {
             /* send edges where i is a source to process i */
-            mpi_errno = MPIC_Isend(&rout[i][0], rout_sizes[i], MPI_INT, i, MPIR_TOPO_B_TAG, comm_old, &reqs[idx++], &errflag);
+            mpi_errno = MPIC_Isend(&rout[i][0], rout_sizes[i], MPI_INT, i, MPIR_TOPO_B_TAG, comm_ptr, &reqs[idx++], &errflag);
             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         }
     }
@@ -322,7 +322,7 @@ int MPI_Dist_graph_create(MPI_Comm comm_old, int n, const int sources[],
         buf = MPIU_Malloc(count*sizeof(int));
         MPIU_ERR_CHKANDJUMP(!buf, mpi_errno, MPI_ERR_OTHER, "**nomem");
 
-        mpi_errno = MPIC_Recv(buf, count, MPI_INT, MPI_ANY_SOURCE, MPIR_TOPO_A_TAG, comm_old, MPI_STATUS_IGNORE, &errflag);
+        mpi_errno = MPIC_Recv(buf, count, MPI_INT, MPI_ANY_SOURCE, MPIR_TOPO_A_TAG, comm_ptr, MPI_STATUS_IGNORE, &errflag);
         /* FIXME: buf is never freed on error! */
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         
@@ -356,7 +356,7 @@ int MPI_Dist_graph_create(MPI_Comm comm_old, int n, const int sources[],
         buf = MPIU_Malloc(count*sizeof(int));
         MPIU_ERR_CHKANDJUMP(!buf, mpi_errno, MPI_ERR_OTHER, "**nomem");
 
-        mpi_errno = MPIC_Recv(buf, count, MPI_INT, MPI_ANY_SOURCE, MPIR_TOPO_B_TAG, comm_old, MPI_STATUS_IGNORE, &errflag);
+        mpi_errno = MPIC_Recv(buf, count, MPI_INT, MPI_ANY_SOURCE, MPIR_TOPO_B_TAG, comm_ptr, MPI_STATUS_IGNORE, &errflag);
         /* FIXME: buf is never freed on error! */
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
@@ -377,7 +377,7 @@ int MPI_Dist_graph_create(MPI_Comm comm_old, int n, const int sources[],
         MPIU_Free(buf);
     }
 
-    mpi_errno = MPIR_Waitall_impl(idx, reqs, MPI_STATUSES_IGNORE);
+    mpi_errno = MPIC_Waitall(idx, reqs, MPI_STATUSES_IGNORE, &errflag);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
     /* remove any excess memory allocation */
diff --git a/src/mpid/ch3/src/ch3u_port.c b/src/mpid/ch3/src/ch3u_port.c
index cb6a1dc..6870f51 100644
--- a/src/mpid/ch3/src/ch3u_port.c
+++ b/src/mpid/ch3/src/ch3u_port.c
@@ -399,7 +399,7 @@ int MPIDI_Comm_connect(const char *port_name, MPID_Info *info, int root,
                   send_ints[0], send_ints[1], send_ints[2]));
         mpi_errno = MPIC_Sendrecv(send_ints, 3, MPI_INT, 0,
                                      sendtag++, recv_ints, 3, MPI_INT,
-                                     0, recvtag++, tmp_comm->handle,
+                                     0, recvtag++, tmp_comm,
                                      MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
             /* this is a no_port error because we may fail to connect
@@ -443,7 +443,7 @@ int MPIDI_Comm_connect(const char *port_name, MPID_Info *info, int root,
 	mpi_errno = MPIC_Sendrecv(local_translation, local_comm_size * 2,
 				  MPI_INT, 0, sendtag++,
 				  remote_translation, remote_comm_size * 2, 
-				  MPI_INT, 0, recvtag++, tmp_comm->handle, 
+				  MPI_INT, 0, recvtag++, tmp_comm,
 				  MPI_STATUS_IGNORE, &errflag);
 	if (mpi_errno) {
 	    MPIU_ERR_POP(mpi_errno);
@@ -499,7 +499,7 @@ int MPIDI_Comm_connect(const char *port_name, MPID_Info *info, int root,
 	MPIU_DBG_MSG(CH3_CONNECT,VERBOSE,"sync with peer");
         mpi_errno = MPIC_Sendrecv(&i, 0, MPI_INT, 0,
                                      sendtag++, &j, 0, MPI_INT,
-                                     0, recvtag++, tmp_comm->handle,
+                                     0, recvtag++, tmp_comm,
                                      MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
 	    MPIU_ERR_POP(mpi_errno);
@@ -705,7 +705,7 @@ static int ReceivePGAndDistribute( MPID_Comm *tmp_comm, MPID_Comm *comm_ptr,
 	if (rank == root) {
 	    /* First, receive the pg description from the partner */
 	    mpi_errno = MPIC_Recv(&j, 1, MPI_INT, 0, recvtag++,
-				  tmp_comm->handle, MPI_STATUS_IGNORE, &errflag);
+				  tmp_comm, MPI_STATUS_IGNORE, &errflag);
 	    *recvtag_p = recvtag;
 	    if (mpi_errno != MPI_SUCCESS) {
 		MPIU_ERR_POP(mpi_errno);
@@ -715,7 +715,7 @@ static int ReceivePGAndDistribute( MPID_Comm *tmp_comm, MPID_Comm *comm_ptr,
 		MPIU_ERR_POP(mpi_errno);
 	    }
 	    mpi_errno = MPIC_Recv(pg_str, j, MPI_CHAR, 0, recvtag++,
-				  tmp_comm->handle, MPI_STATUS_IGNORE, &errflag);
+				  tmp_comm, MPI_STATUS_IGNORE, &errflag);
 	    *recvtag_p = recvtag;
 	    if (mpi_errno != MPI_SUCCESS) {
 		MPIU_ERR_POP(mpi_errno);
@@ -884,7 +884,7 @@ static int SendPGtoPeerAndFree( MPID_Comm *tmp_comm, int *sendtag_p,
 	pg_iter = pg_list;
 	i = pg_iter->lenStr;
 	/*printf("connect:sending 1 int: %d\n", i);fflush(stdout);*/
-	mpi_errno = MPIC_Send(&i, 1, MPI_INT, 0, sendtag++, tmp_comm->handle, &errflag);
+	mpi_errno = MPIC_Send(&i, 1, MPI_INT, 0, sendtag++, tmp_comm, &errflag);
 	*sendtag_p = sendtag;
 	if (mpi_errno != MPI_SUCCESS) {
 	    MPIU_ERR_POP(mpi_errno);
@@ -892,7 +892,7 @@ static int SendPGtoPeerAndFree( MPID_Comm *tmp_comm, int *sendtag_p,
 	
 	/* printf("connect:sending string length %d\n", i);fflush(stdout); */
 	mpi_errno = MPIC_Send(pg_iter->str, i, MPI_CHAR, 0, sendtag++,
-			      tmp_comm->handle, &errflag);
+			      tmp_comm, &errflag);
 	*sendtag_p = sendtag;
 	if (mpi_errno != MPI_SUCCESS) {
 	    MPIU_ERR_POP(mpi_errno);
@@ -997,7 +997,7 @@ int MPIDI_Comm_accept(const char *port_name, MPID_Info *info, int root,
 	/*printf("accept:sending 3 ints, %d, %d, %d, and receiving 2 ints\n", send_ints[0], send_ints[1], send_ints[2]);fflush(stdout);*/
         mpi_errno = MPIC_Sendrecv(send_ints, 3, MPI_INT, 0,
                                      sendtag++, recv_ints, 3, MPI_INT,
-                                     0, recvtag++, tmp_comm->handle,
+                                     0, recvtag++, tmp_comm,
                                      MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
 	    MPIU_ERR_POP(mpi_errno);
@@ -1037,7 +1037,7 @@ int MPIDI_Comm_accept(const char *port_name, MPID_Info *info, int root,
 	mpi_errno = MPIC_Sendrecv(local_translation, local_comm_size * 2,
 				  MPI_INT, 0, sendtag++,
 				  remote_translation, remote_comm_size * 2, 
-				  MPI_INT, 0, recvtag++, tmp_comm->handle, 
+				  MPI_INT, 0, recvtag++, tmp_comm,
 				  MPI_STATUS_IGNORE, &errflag);
 #ifdef MPICH_DBG_OUTPUT
 	MPIU_DBG_PRINTF(("[%d]accept:Received remote_translation:\n", rank));
@@ -1088,7 +1088,7 @@ int MPIDI_Comm_accept(const char *port_name, MPID_Info *info, int root,
 	MPIU_DBG_MSG(CH3_CONNECT,VERBOSE,"sync with peer");
         mpi_errno = MPIC_Sendrecv(&i, 0, MPI_INT, 0,
                                      sendtag++, &j, 0, MPI_INT,
-                                     0, recvtag++, tmp_comm->handle,
+                                     0, recvtag++, tmp_comm,
                                      MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
 	    MPIU_ERR_POP(mpi_errno);
diff --git a/src/mpid/ch3/src/mpid_comm_agree.c b/src/mpid/ch3/src/mpid_comm_agree.c
index 5e77d52..ca0273e 100644
--- a/src/mpid/ch3/src/mpid_comm_agree.c
+++ b/src/mpid/ch3/src/mpid_comm_agree.c
@@ -77,7 +77,7 @@ int MPID_Comm_agree(MPID_Comm *comm_ptr, uint32_t *bitarray, int *flag, mpir_err
     for (i = 0; i < nchildren; i++) {
         if (children[i] == -1) continue;
         mpi_errno = MPIC_Recv(&tmp_flag, 1, MPI_INT, children[i], MPIR_AGREE_TAG,
-                comm_ptr->handle, MPI_STATUS_IGNORE, &errflag);
+                comm_ptr, MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno) return mpi_errno;
         if (errflag) new_fail = 1;
 
@@ -88,12 +88,12 @@ int MPID_Comm_agree(MPID_Comm *comm_ptr, uint32_t *bitarray, int *flag, mpir_err
     if (-1 != parent) {
         /* Send my message to my parent */
         mpi_errno = MPIC_Send(flag, 1, MPI_INT, parent, MPIR_AGREE_TAG,
-                comm_ptr->handle, &errflag);
+                comm_ptr, &errflag);
         if (mpi_errno) return mpi_errno;
 
         /* Receive the result from my parent */
         mpi_errno = MPIC_Recv(flag, 1, MPI_INT, parent, MPIR_AGREE_TAG,
-                comm_ptr->handle, MPI_STATUS_IGNORE, &errflag);
+                comm_ptr, MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno) return mpi_errno;
         if (errflag) new_fail = 1;
     }
@@ -102,7 +102,7 @@ int MPID_Comm_agree(MPID_Comm *comm_ptr, uint32_t *bitarray, int *flag, mpir_err
     for (i = 0; i < nchildren; i++) {
         if (children[i] == -1) continue;
         mpi_errno = MPIC_Send(flag, 1, MPI_INT, children[i], MPIR_AGREE_TAG,
-                comm_ptr->handle, &errflag);
+                comm_ptr, &errflag);
         if (mpi_errno) return mpi_errno;
     }
 
diff --git a/src/mpid/ch3/src/mpid_comm_get_all_failed_procs.c b/src/mpid/ch3/src/mpid_comm_get_all_failed_procs.c
index 465d24f..015ddd9 100644
--- a/src/mpid/ch3/src/mpid_comm_get_all_failed_procs.c
+++ b/src/mpid/ch3/src/mpid_comm_get_all_failed_procs.c
@@ -116,7 +116,7 @@ int MPID_Comm_get_all_failed_procs(MPID_Comm *comm_ptr, MPID_Group **failed_grou
         for (i = 1; i < comm_ptr->local_size; i++) {
             /* Get everyone's list of failed processes to aggregate */
             ret_errno = MPIC_Recv(remote_bitarray, bitarray_size, MPI_UINT32_T,
-                i, tag, comm_ptr->handle, MPI_STATUS_IGNORE, &errflag);
+                i, tag, comm_ptr, MPI_STATUS_IGNORE, &errflag);
             if (ret_errno) continue;
 
             /* Combine the received bitarray with my own */
@@ -130,7 +130,7 @@ int MPID_Comm_get_all_failed_procs(MPID_Comm *comm_ptr, MPID_Group **failed_grou
         for (i = 1; i < comm_ptr->local_size; i++) {
             /* Send the list to each rank to be processed locally */
             ret_errno = MPIC_Send(bitarray, bitarray_size, MPI_UINT32_T, i,
-                tag, comm_ptr->handle, &errflag);
+                tag, comm_ptr, &errflag);
             if (ret_errno) continue;
         }
 
@@ -139,11 +139,11 @@ int MPID_Comm_get_all_failed_procs(MPID_Comm *comm_ptr, MPID_Group **failed_grou
     } else {
         /* Send my bitarray to rank 0 */
         mpi_errno = MPIC_Send(bitarray, bitarray_size, MPI_UINT32_T, 0,
-            tag, comm_ptr->handle, &errflag);
+            tag, comm_ptr, &errflag);
 
         /* Get the resulting bitarray back from rank 0 */
         mpi_errno = MPIC_Recv(remote_bitarray, bitarray_size, MPI_UINT32_T, 0,
-            tag, comm_ptr->handle, MPI_STATUS_IGNORE, &errflag);
+            tag, comm_ptr, MPI_STATUS_IGNORE, &errflag);
 
         /* Convert the bitarray into a group */
         *failed_group = bitarray_to_group(comm_ptr, remote_bitarray);
diff --git a/src/mpid/pamid/src/dyntask/mpidi_port.c b/src/mpid/pamid/src/dyntask/mpidi_port.c
index 092d2dd..cab1c20 100644
--- a/src/mpid/pamid/src/dyntask/mpidi_port.c
+++ b/src/mpid/pamid/src/dyntask/mpidi_port.c
@@ -562,7 +562,7 @@ int MPIDI_Comm_connect(const char *port_name, MPID_Info *info, int root,
 	TRACE_ERR("connect:sending 3 ints, %d, %d, %d, and receiving 2 ints with sendtag=%d recvtag=%d\n", send_ints[0], send_ints[1], send_ints[2], sendtag, recvtag);
         mpi_errno = MPIC_Sendrecv(send_ints, 3, MPI_INT, 0,
                                   sendtag++, recv_ints, 3, MPI_INT,
-                                  0, recvtag++, tmp_comm->handle,
+                                  0, recvtag++, tmp_comm,
                                   MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
             /* this is a no_port error because we may fail to connect
@@ -571,7 +571,7 @@ int MPIDI_Comm_connect(const char *port_name, MPID_Info *info, int root,
 	}
 
         mpi_errno = MPIC_Sendrecv_replace(&comm_cntr, 1, MPI_LONG_LONG_INT, 0,
-                                  sendtag++, 0, recvtag++, tmp_comm->handle,
+                                  sendtag++, 0, recvtag++, tmp_comm,
                                   MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
             /* this is a no_port error because we may fail to connect
@@ -611,7 +611,7 @@ int MPIDI_Comm_connect(const char *port_name, MPID_Info *info, int root,
 	mpi_errno = MPIC_Sendrecv(local_translation, local_comm_size * 3,
 				  MPI_INT, 0, sendtag++,
 				  remote_translation, remote_comm_size * 3,
-				  MPI_INT, 0, recvtag++, tmp_comm->handle,
+				  MPI_INT, 0, recvtag++, tmp_comm,
 				  MPI_STATUS_IGNORE, &errflag);
 	if (mpi_errno) {
 	    TRACE_ERR("MPIC_Sendrecv returned with mpi_errno=%d\n", mpi_errno);
@@ -676,7 +676,7 @@ int MPIDI_Comm_connect(const char *port_name, MPID_Info *info, int root,
     {
         mpi_errno = MPIC_Sendrecv(&i, 0, MPI_INT, 0,
                                   sendtag++, &j, 0, MPI_INT,
-                                  0, recvtag++, tmp_comm->handle,
+                                  0, recvtag++, tmp_comm,
                                   MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
 	    TRACE_ERR("MPIC_Sendrecv returned with mpi_errno=%d\n", mpi_errno);
@@ -823,14 +823,14 @@ static int MPIDI_ReceivePGAndDistribute( struct MPID_Comm *tmp_comm, struct MPID
 	if (rank == root) {
 	    /* First, receive the pg description from the partner */
 	    mpi_errno = MPIC_Recv(&j, 1, MPI_INT, 0, recvtag++,
-				  tmp_comm->handle, MPI_STATUS_IGNORE, &errflag);
+				  tmp_comm, MPI_STATUS_IGNORE, &errflag);
 	    *recvtag_p = recvtag;
 	    if (mpi_errno != MPI_SUCCESS) {
 		TRACE_ERR("MPIC_Recv returned with mpi_errno=%d\n", mpi_errno);
 	    }
 	    pg_str = (char*)MPIU_Malloc(j);
 	    mpi_errno = MPIC_Recv(pg_str, j, MPI_CHAR, 0, recvtag++,
-				  tmp_comm->handle, MPI_STATUS_IGNORE, &errflag);
+				  tmp_comm, MPI_STATUS_IGNORE, &errflag);
 	    *recvtag_p = recvtag;
 	    if (mpi_errno != MPI_SUCCESS) {
 		TRACE_ERR("MPIC_Recv returned with mpi_errno=%d\n", mpi_errno);
@@ -1094,7 +1094,7 @@ static int MPIDI_SendPGtoPeerAndFree( struct MPID_Comm *tmp_comm, int *sendtag_p
 	pg_iter = pg_list;
         i = pg_iter->lenStr;
 	TRACE_ERR("connect:sending 1 int: %d\n", i);
-	mpi_errno = MPIC_Send(&i, 1, MPI_INT, 0, sendtag++, tmp_comm->handle, &errflag);
+	mpi_errno = MPIC_Send(&i, 1, MPI_INT, 0, sendtag++, tmp_comm, &errflag);
 	*sendtag_p = sendtag;
 	if (mpi_errno != MPI_SUCCESS) {
 	    TRACE_ERR("MPIC_Send returned with mpi_errno=%d\n", mpi_errno);
@@ -1102,7 +1102,7 @@ static int MPIDI_SendPGtoPeerAndFree( struct MPID_Comm *tmp_comm, int *sendtag_p
 
 	TRACE_ERR("connect:sending string length %d\n", i);
 	mpi_errno = MPIC_Send(pg_iter->str, i, MPI_CHAR, 0, sendtag++,
-			      tmp_comm->handle, &errflag);
+			      tmp_comm, &errflag);
 	*sendtag_p = sendtag;
 	if (mpi_errno != MPI_SUCCESS) {
 	    TRACE_ERR("MPIC_Send returned with mpi_errno=%d\n", mpi_errno);
@@ -1208,7 +1208,7 @@ int MPIDI_Comm_accept(const char *port_name, MPID_Info *info, int root,
 	TRACE_ERR("accept:sending 3 ints, %d, %d, %d, and receiving 2 ints with sendtag=%d recvtag=%d\n", send_ints[0], send_ints[1], send_ints[2], sendtag, recvtag);
         mpi_errno = MPIC_Sendrecv(send_ints, 3, MPI_INT, 0,
                                   sendtag++, recv_ints, 3, MPI_INT,
-                                  0, recvtag++, tmp_comm->handle,
+                                  0, recvtag++, tmp_comm,
                                   MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
 	    TRACE_ERR("MPIC_Sendrecv returned with mpi_errno=%d\n", mpi_errno);
@@ -1218,14 +1218,14 @@ int MPIDI_Comm_accept(const char *port_name, MPID_Info *info, int root,
 	TRACE_ERR("accept:sending 1 string and receiving 1 string\n", send_char, recv_char);
         mpi_errno = MPIC_Sendrecv(send_char, 1, MPI_CHAR, 0,
                                      sendtag++, recv_char, 3, MPI_CHAR,
-                                     0, recvtag++, tmp_comm->handle,
+                                     0, recvtag++, tmp_comm,
                                      MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
 	    TRACE_ERR("MPIC_Sendrecv returned with mpi_errno=%d\n", mpi_errno);
 	}
 #endif
         mpi_errno = MPIC_Sendrecv_replace(&comm_cntr, 1, MPI_LONG_LONG_INT, 0,
-                                  sendtag++, 0, recvtag++, tmp_comm->handle,
+                                  sendtag++, 0, recvtag++, tmp_comm,
                                   MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
             /* this is a no_port error because we may fail to connect
@@ -1266,7 +1266,7 @@ int MPIDI_Comm_accept(const char *port_name, MPID_Info *info, int root,
 	mpi_errno = MPIC_Sendrecv(local_translation, local_comm_size * 3,
 				  MPI_INT, 0, sendtag++,
 				  remote_translation, remote_comm_size * 3,
-				  MPI_INT, 0, recvtag++, tmp_comm->handle,
+				  MPI_INT, 0, recvtag++, tmp_comm,
                                   MPI_STATUS_IGNORE, &errflag);
 	for (i=0; i<remote_comm_size; i++)
 	{
@@ -1331,7 +1331,7 @@ int MPIDI_Comm_accept(const char *port_name, MPID_Info *info, int root,
     {
         mpi_errno = MPIC_Sendrecv(&i, 0, MPI_INT, 0,
                                   sendtag++, &j, 0, MPI_INT,
-                                  0, recvtag++, tmp_comm->handle,
+                                  0, recvtag++, tmp_comm,
                                   MPI_STATUS_IGNORE, &errflag);
         if (mpi_errno != MPI_SUCCESS) {
 	    TRACE_ERR("MPIC_Sendrecv returned with mpi_errno=%d\n", mpi_errno);
diff --git a/src/pmi/pmi2/poe/poe2pmi.c b/src/pmi/pmi2/poe/poe2pmi.c
index 7132716..e56ce1c 100644
--- a/src/pmi/pmi2/poe/poe2pmi.c
+++ b/src/pmi/pmi2/poe/poe2pmi.c
@@ -389,7 +389,7 @@ int _mpi_reduce_for_dyntask(int *sendbuf, int *recvbuf)
   int         numchildren, parent=0, i, result=0,tag, remaining_child_count;
   MPID_Comm   *comm_ptr;
   int         mpi_errno;
-  int         errflag = FALSE;
+  mpir_errflag_t errflag = MPIR_ERR_NONE;
 
   int TASKS= world_size;
   children = MPIU_Malloc(TASKS*sizeof(int));
@@ -413,7 +413,7 @@ int _mpi_reduce_for_dyntask(int *sendbuf, int *recvbuf)
     remaining_child_count = i;
     child_rank = (children[i])% TASKS;
     TRACE_ERR("_mpi_reduce_for_dyntask - recv from child_rank%d child_taskid=%d\n", child_rank, pg_world->vct[child_rank].taskid);
-    mpi_errno = MPIC_Recv(recvbuf, sizeof(int),MPI_BYTE, child_rank, tag, comm_ptr->handle, MPI_STATUS_IGNORE, &errflag);
+    mpi_errno = MPIC_Recv(recvbuf, sizeof(int),MPI_BYTE, child_rank, tag, comm_ptr, MPI_STATUS_IGNORE, &errflag);
     TRACE_ERR("_mpi_reduce_for_dyntask - recv DONE from child_rank%d child_taskid=%d\n", child_rank, pg_world->vct[child_rank].taskid);
 
     if(world_rank != parent)
@@ -422,7 +422,7 @@ int _mpi_reduce_for_dyntask(int *sendbuf, int *recvbuf)
         parent_rank = (parent) % TASKS;
         result += *recvbuf;
         TRACE_ERR("_mpi_reduce_for_dyntask - send to parent_rank=%d parent taskid=%d \n", parent_rank, pg_world->vct[parent_rank].taskid);
-        MPIC_Send(&result, sizeof(int), MPI_BYTE, parent_rank, tag, comm_ptr->handle, &errflag);
+        MPIC_Send(&result, sizeof(int), MPI_BYTE, parent_rank, tag, comm_ptr, &errflag);
       }
       else
       {
@@ -438,7 +438,7 @@ int _mpi_reduce_for_dyntask(int *sendbuf, int *recvbuf)
   if(world_rank != parent && numchildren == 0) {
     parent_rank = (parent) % TASKS;
     TRACE_ERR("_mpi_reduce_for_dyntask - send to parent_rank=%d parent_task_id=%d\n", parent_rank, pg_world->vct[parent_rank].taskid);
-    MPIC_Send(sendbuf, sizeof(int), MPI_BYTE, parent_rank, tag, comm_ptr->handle, &errflag);
+    MPIC_Send(sendbuf, sizeof(int), MPI_BYTE, parent_rank, tag, comm_ptr, &errflag);
   }
 
   if(world_rank == 0) {

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

commit c04f08514fddfd16996e913e3d18d32aaed460f2
Author: Wesley Bland <wbland at anl.gov>
Date:   Fri Jan 23 15:13:57 2015 -0600

    Refactor MPIC_Wait to return an errflag
    
    The collective helper functions generally have an errflag that is used
    when a failure is detected to allow the collective to continue while
    also communicating that a failure occurred. That flag is now included
    as a parameter for MPIC_Wait.
    
    The rest of this commit is the refactoring necessary in the rest of the
    helper functions to support the change.
    
    Signed-off-by: Huiwei Lu <huiweilu at mcs.anl.gov>

diff --git a/src/include/mpiimpl.h b/src/include/mpiimpl.h
index e178615..c1439d3 100644
--- a/src/include/mpiimpl.h
+++ b/src/include/mpiimpl.h
@@ -3944,7 +3944,7 @@ int MPID_VCR_Get_lpid(MPID_VCR vcr, int * lpid_ptr);
    MPID_CONTEXT_INTRA(INTER)_COLL. */
 int MPIR_Localcopy(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                    void *recvbuf, int recvcount, MPI_Datatype recvtype);
-int MPIC_Wait(MPID_Request * request_ptr);
+int MPIC_Wait(MPID_Request * request_ptr, mpir_errflag_t *errflag);
 int MPIC_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status);
 
 /* FT versions of te MPIC_ functions */
@@ -4558,6 +4558,29 @@ static inline int MPIR_Request_complete_fastpath(MPI_Request *request, MPID_Requ
     return mpi_errno;
 }
 
+/* Pull the error status out of the tag space and put it into an errflag. */
+#undef FUNCNAME
+#define FUNCNAME MPIR_process_status
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+static inline void MPIR_Process_status(MPI_Status *status, mpir_errflag_t *errflag)
+{
+    if ((MPIX_ERR_REVOKED == MPIR_ERR_GET_CLASS(status->MPI_ERROR) ||
+        MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(status->MPI_ERROR) ||
+        MPIR_TAG_CHECK_ERROR_BIT(status->MPI_TAG)) && !*errflag) {
+        /* If the receive was completed within the MPID_Recv, handle the
+        * errflag here. */
+        if (MPIR_TAG_CHECK_PROC_FAILURE_BIT(status->MPI_TAG) ||
+            MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(status->MPI_ERROR)) {
+            *errflag = MPIR_ERR_PROC_FAILED;
+            MPIR_TAG_CLEAR_ERROR_BITS(status->MPI_TAG);
+        } else {
+            *errflag = MPIR_ERR_OTHER;
+            MPIR_TAG_CLEAR_ERROR_BITS(status->MPI_TAG);
+        }
+    }
+}
+
 extern const char MPIR_Version_string[];
 extern const char MPIR_Version_date[];
 extern const char MPIR_Version_configure[];
diff --git a/src/mpi/coll/helper_fns.c b/src/mpi/coll/helper_fns.c
index 4ea6202..3244496 100644
--- a/src/mpi/coll/helper_fns.c
+++ b/src/mpi/coll/helper_fns.c
@@ -200,12 +200,18 @@ int MPIR_Localcopy(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
 #define FUNCNAME MPIC_Wait
 #undef FCNAME
 #define FCNAME "MPIC_Wait"
-int MPIC_Wait(MPID_Request * request_ptr)
+int MPIC_Wait(MPID_Request * request_ptr, mpir_errflag_t *errflag)
 {
     int mpi_errno = MPI_SUCCESS;
     MPIDI_STATE_DECL(MPID_STATE_MPIC_WAIT);
 
     MPIDI_PT2PT_FUNC_ENTER(MPID_STATE_MPIC_WAIT);
+
+    MPIU_DBG_MSG_S(PT2PT, TYPICAL, "IN: errflag = %s", *errflag?"TRUE":"FALSE");
+
+    if (request_ptr->kind == MPID_REQUEST_SEND)
+        request_ptr->status.MPI_TAG = 0;
+
     if (!MPID_Request_is_complete(request_ptr))
     {
 	MPID_Progress_state progress_state;
@@ -219,10 +225,19 @@ int MPIC_Wait(MPID_Request * request_ptr)
 	MPID_Progress_end(&progress_state);
     }
 
- fn_fail:
-    /* --BEGIN ERROR HANDLING-- */
+    if (request_ptr->kind == MPID_REQUEST_RECV &&
+        request_ptr->status.MPI_SOURCE == MPI_PROC_NULL)
+        goto fn_exit;
+
+    MPIR_Process_status(&request_ptr->status, errflag);
+
+ fn_exit:
+    MPIU_DBG_MSG_D(PT2PT, TYPICAL, "OUT: errflag = %d", *errflag);
     MPIDI_PT2PT_FUNC_EXIT(MPID_STATE_MPIC_WAIT);
     return mpi_errno;
+ fn_fail:
+    /* --BEGIN ERROR HANDLING-- */
+    goto fn_exit;
     /* --END ERROR HANDLING-- */
 }
 
@@ -284,17 +299,25 @@ int MPIC_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int t
                           context_id, &request_ptr);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
     if (request_ptr) {
-        mpi_errno = MPIC_Wait(request_ptr);
+        mpi_errno = MPIC_Wait(request_ptr, errflag);
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         MPID_Request_release(request_ptr);
     }
 
  fn_exit:
+    MPIU_DBG_MSG_D(PT2PT, TYPICAL, "OUT: errflag = %d", *errflag);
     MPIDI_FUNC_EXIT(MPID_STATE_MPIC_SEND);
     return mpi_errno;
  fn_fail:
     /* --BEGIN ERROR HANDLING-- */
     if (request_ptr) MPID_Request_release(request_ptr);
+    if (mpi_errno && !*errflag) {
+        if (MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(mpi_errno)) {
+            *errflag = MPIR_ERR_PROC_FAILED;
+        } else {
+            *errflag = MPIR_ERR_OTHER;
+        }
+    }
     goto fn_exit;
     /* --END ERROR HANDLING-- */
 }
@@ -331,29 +354,19 @@ int MPIC_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
                           context_id, status, &request_ptr);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
     if (request_ptr) {
-        mpi_errno = MPIC_Wait(request_ptr);
+        mpi_errno = MPIC_Wait(request_ptr, errflag);
         if (mpi_errno != MPI_SUCCESS)
             MPIU_ERR_POP(mpi_errno);
 
         *status = request_ptr->status;
         mpi_errno = status->MPI_ERROR;
         MPID_Request_release(request_ptr);
+    } else {
+        MPIR_Process_status(status, errflag);
     }
 
-    if (source != MPI_PROC_NULL) {
-        if (MPIX_ERR_REVOKED == MPIR_ERR_GET_CLASS(status->MPI_ERROR) ||
-            MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(status->MPI_ERROR) ||
-            MPIR_TAG_CHECK_ERROR_BIT(status->MPI_TAG)) {
-            if (MPIR_TAG_CHECK_PROC_FAILURE_BIT(status->MPI_TAG)) {
-                *errflag = MPIR_ERR_PROC_FAILED;
-                MPIR_TAG_CLEAR_ERROR_BITS(status->MPI_TAG);
-            } else if (MPIR_TAG_CHECK_ERROR_BIT(status->MPI_TAG)) {
-                *errflag = MPIR_ERR_OTHER;
-                MPIR_TAG_CLEAR_ERROR_BITS(status->MPI_TAG);
-            }
-        } else if (MPI_SUCCESS == MPIR_ERR_GET_CLASS(status->MPI_ERROR)) {
-            MPIU_Assert(status->MPI_TAG == tag);
-        }
+    if (MPI_SUCCESS == MPIR_ERR_GET_CLASS(status->MPI_ERROR)) {
+        MPIU_Assert(status->MPI_TAG == tag);
     }
 
  fn_exit:
@@ -404,17 +417,25 @@ int MPIC_Ssend(const void *buf, int count, MPI_Datatype datatype, int dest, int
                            context_id, &request_ptr);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
     if (request_ptr) {
-        mpi_errno = MPIC_Wait(request_ptr);
+        mpi_errno = MPIC_Wait(request_ptr, errflag);
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         MPID_Request_release(request_ptr);
     }
 
  fn_exit:
+    MPIU_DBG_MSG_D(PT2PT, TYPICAL, "OUT: errflag = %d", *errflag);
     MPIDI_FUNC_EXIT(MPID_STATE_MPIC_SSEND);
     return mpi_errno;
  fn_fail:
     /* --BEGIN ERROR HANDLING-- */
     if (request_ptr) MPID_Request_release(request_ptr);
+    if (mpi_errno && !*errflag) {
+        if (MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(mpi_errno)) {
+            *errflag = MPIR_ERR_PROC_FAILED;
+        } else {
+            *errflag = MPIR_ERR_OTHER;
+        }
+    }
     goto fn_exit;
     /* --END ERROR HANDLING-- */
 }
@@ -465,33 +486,23 @@ int MPIC_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                            comm_ptr, context_id, &send_req_ptr);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
-    mpi_errno = MPIC_Wait(send_req_ptr);
+    mpi_errno = MPIC_Wait(send_req_ptr, errflag);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = MPIC_Wait(recv_req_ptr);
+    mpi_errno = MPIC_Wait(recv_req_ptr, errflag);
     if (mpi_errno) MPIU_ERR_POPFATAL(mpi_errno);
 
     *status = recv_req_ptr->status;
-    mpi_errno = recv_req_ptr->status.MPI_ERROR;
 
-    MPID_Request_release(send_req_ptr);
-    MPID_Request_release(recv_req_ptr);
+    if (mpi_errno == MPI_SUCCESS) {
+        mpi_errno = recv_req_ptr->status.MPI_ERROR;
 
-    if (source != MPI_PROC_NULL) {
-        if (MPIX_ERR_REVOKED == MPIR_ERR_GET_CLASS(status->MPI_ERROR) ||
-            MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(status->MPI_ERROR) ||
-            MPIR_TAG_CHECK_ERROR_BIT(status->MPI_TAG)) {
-            if (MPIR_TAG_CHECK_PROC_FAILURE_BIT(status->MPI_TAG)) {
-                *errflag = MPIR_ERR_PROC_FAILED;
-                MPIR_TAG_CLEAR_ERROR_BITS(status->MPI_TAG);
-            } else if (MPIR_TAG_CHECK_ERROR_BIT(status->MPI_TAG)) {
-                *errflag = MPIR_ERR_OTHER;
-                MPIR_TAG_CLEAR_ERROR_BITS(status->MPI_TAG);
-            }
-        } else if (MPI_SUCCESS == MPIR_ERR_GET_CLASS(status->MPI_ERROR)) {
-            MPIU_Assert(status->MPI_TAG == recvtag);
+        if (mpi_errno == MPI_SUCCESS) {
+            mpi_errno = send_req_ptr->status.MPI_ERROR;
         }
     }
 
+    MPID_Request_release(send_req_ptr);
+    MPID_Request_release(recv_req_ptr);
 
  fn_exit:
     MPIU_DBG_MSG_D(PT2PT, TYPICAL, "OUT: errflag = %d", *errflag);
@@ -521,8 +532,8 @@ int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
     int mpi_errno = MPI_SUCCESS;
     MPI_Status mystatus;
     MPIR_Context_id_t context_id_offset;
-    MPID_Request *sreq;
-    MPID_Request *rreq;
+    MPID_Request *sreq = NULL;
+    MPID_Request *rreq = NULL;
     void *tmpbuf = NULL;
     MPI_Aint tmpbuf_size = 0;
     MPI_Aint tmpbuf_count = 0;
@@ -578,21 +589,10 @@ int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
         /* --END ERROR HANDLING-- */
     }
 
-    if (!MPID_Request_is_complete(sreq) || !MPID_Request_is_complete(rreq)) {
-        MPID_Progress_state progress_state;
-
-        MPID_Progress_start(&progress_state);
-        while (!MPID_Request_is_complete(sreq) || !MPID_Request_is_complete(rreq)) {
-            mpi_errno = MPID_Progress_wait(&progress_state);
-            if (mpi_errno != MPI_SUCCESS) {
-                /* --BEGIN ERROR HANDLING-- */
-                MPID_Progress_end(&progress_state);
-                MPIU_ERR_POP(mpi_errno);
-                /* --END ERROR HANDLING-- */
-            }
-        }
-        MPID_Progress_end(&progress_state);
-    }
+    mpi_errno = MPIC_Wait(sreq, errflag);
+    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+    mpi_errno = MPIC_Wait(rreq, errflag);
+    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
     *status = rreq->status;
 
@@ -607,31 +607,16 @@ int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
     MPID_Request_release(sreq);
     MPID_Request_release(rreq);
 
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-
-    if (source != MPI_PROC_NULL) {
-        if (MPIX_ERR_REVOKED == MPIR_ERR_GET_CLASS(status->MPI_ERROR) ||
-            MPIX_ERR_PROC_FAILED == MPIR_ERR_GET_CLASS(status->MPI_ERROR) ||
-            MPIR_TAG_CHECK_ERROR_BIT(status->MPI_TAG)) {
-            if (MPIR_TAG_CHECK_PROC_FAILURE_BIT(status->MPI_TAG)) {
-                *errflag = MPIR_ERR_PROC_FAILED;
-                MPIR_TAG_CLEAR_ERROR_BITS(status->MPI_TAG);
-            } else if (MPIR_TAG_CHECK_ERROR_BIT(status->MPI_TAG)) {
-                *errflag = MPIR_ERR_OTHER;
-                MPIR_TAG_CLEAR_ERROR_BITS(status->MPI_TAG);
-            }
-        } else if (MPI_SUCCESS == MPIR_ERR_GET_CLASS(status->MPI_ERROR)) {
-            MPIU_Assert(status->MPI_TAG == recvtag);
-        }
-    }
-
-
  fn_exit:
     MPIU_CHKLMEM_FREEALL();
     MPIU_DBG_MSG_D(PT2PT, TYPICAL, "OUT: errflag = %d", *errflag);
     MPIDI_FUNC_EXIT(MPID_STATE_MPIC_SENDRECV_REPLACE);
     return mpi_errno;
  fn_fail:
+     if (sreq)
+         MPID_Request_release(sreq);
+     if (rreq)
+         MPID_Request_release(rreq);
     goto fn_exit;
 }
 
@@ -738,22 +723,14 @@ int MPIC_Waitall(int numreq, MPI_Request requests[], MPI_Status statuses[], mpir
        tag fields here. */
     for (i = 0; i < numreq; ++i)
         statuses[i].MPI_TAG = 0;
-    
-    mpi_errno = MPIR_Waitall_impl(numreq, requests, statuses);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
-    if (*errflag) goto fn_exit;
+    mpi_errno = MPIR_Waitall_impl(numreq, requests, statuses);
 
+    /* The errflag value here is for all requests, not just a single one.  If
+     * in the future, this function is used for multiple collectives at a
+     * single time, we may have to change that. */
     for (i = 0; i < numreq; ++i) {
-        if (MPIR_TAG_CHECK_PROC_FAILURE_BIT(statuses[i].MPI_TAG)) {
-            *errflag = MPIR_ERR_PROC_FAILED;
-            MPIR_TAG_CLEAR_ERROR_BITS(statuses[i].MPI_TAG);
-            break;
-        } else if (MPIR_TAG_CHECK_ERROR_BIT(statuses[i].MPI_TAG)) {
-            *errflag = MPIR_ERR_OTHER;
-            MPIR_TAG_CLEAR_ERROR_BITS(statuses[i].MPI_TAG);
-            break;
-        }
+        MPIR_Process_status(&statuses[i], errflag);
     }
 
  fn_exit:

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

Summary of changes:
 src/include/mpiimpl.h                             |   51 +++--
 src/include/mpitypedefs.h                         |    8 +
 src/mpi/coll/allgather.c                          |   22 +-
 src/mpi/coll/allgatherv.c                         |   24 +-
 src/mpi/coll/allred_group.c                       |   15 +-
 src/mpi/coll/allreduce.c                          |   21 +-
 src/mpi/coll/alltoall.c                           |   30 +--
 src/mpi/coll/alltoallv.c                          |   20 +-
 src/mpi/coll/alltoallw.c                          |   20 +-
 src/mpi/coll/barrier.c                            |    4 +-
 src/mpi/coll/bcast.c                              |   38 +--
 src/mpi/coll/exscan.c                             |    6 +-
 src/mpi/coll/gather.c                             |   32 +--
 src/mpi/coll/gatherv.c                            |   14 +-
 src/mpi/coll/helper_fns.c                         |  268 +++++++++++----------
 src/mpi/coll/igather.c                            |    4 +-
 src/mpi/coll/iscatter.c                           |    4 +-
 src/mpi/coll/red_scat.c                           |   29 +--
 src/mpi/coll/red_scat_block.c                     |   29 +--
 src/mpi/coll/reduce.c                             |   35 ++--
 src/mpi/coll/scan.c                               |   15 +-
 src/mpi/coll/scatter.c                            |   28 +--
 src/mpi/coll/scatterv.c                           |   10 +-
 src/mpi/comm/comm_create.c                        |    5 +-
 src/mpi/comm/comm_split.c                         |    2 +-
 src/mpi/comm/commutil.c                           |    2 +-
 src/mpi/comm/intercomm_create.c                   |    6 +-
 src/mpi/comm/intercomm_merge.c                    |    4 +-
 src/mpi/pt2pt/mpir_request.c                      |    1 +
 src/mpi/topo/dist_gr_create.c                     |   14 +-
 src/mpid/ch3/include/mpidpre.h                    |    3 +
 src/mpid/ch3/src/ch3u_port.c                      |   20 +-
 src/mpid/ch3/src/ch3u_request.c                   |    1 +
 src/mpid/ch3/src/mpid_comm_agree.c                |    8 +-
 src/mpid/ch3/src/mpid_comm_get_all_failed_procs.c |    8 +-
 src/mpid/common/sched/mpid_sched.c                |  152 ++++++++----
 src/mpid/pamid/src/dyntask/mpidi_port.c           |   26 +-
 src/pmi/pmi2/poe/poe2pmi.c                        |    8 +-
 test/mpi/ft/Makefile.am                           |    2 +-
 test/mpi/ft/nbccoll.c                             |   76 ++++++
 test/mpi/ft/testlist                              |    3 +-
 41 files changed, 591 insertions(+), 477 deletions(-)
 create mode 100644 test/mpi/ft/nbccoll.c


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list