[mpich2-commits] r7972 - in mpich2/trunk/src: include mpid/common/sched
goodell at mcs.anl.gov
goodell at mcs.anl.gov
Tue Feb 15 15:58:56 CST 2011
Author: goodell
Date: 2011-02-15 15:58:56 -0600 (Tue, 15 Feb 2011)
New Revision: 7972
Modified:
mpich2/trunk/src/include/mpiimpl.h
mpich2/trunk/src/mpid/common/sched/mpid_sched.c
Log:
add/release refs in the NBC schedule code to prevent premature frees
Otherwise a user might initiate an MPIX_Ifoo request, free a datatype
or op, and then wait on the request, which would blow up.
Reviewed by buntinas at .
Modified: mpich2/trunk/src/include/mpiimpl.h
===================================================================
--- mpich2/trunk/src/include/mpiimpl.h 2011-02-15 21:58:52 UTC (rev 7971)
+++ mpich2/trunk/src/include/mpiimpl.h 2011-02-15 21:58:56 UTC (rev 7972)
@@ -1766,6 +1766,8 @@
extern MPID_Op MPID_Op_direct[];
extern MPIU_Object_alloc_t MPID_Op_mem;
+#define MPIR_Op_add_ref(_op) \
+ do { MPIU_Object_add_ref(_op); } while (0)
#define MPIR_Op_release_ref( _op, _inuse ) \
do { MPIU_Object_release_ref( _op, _inuse ); } while (0)
Modified: mpich2/trunk/src/mpid/common/sched/mpid_sched.c
===================================================================
--- mpich2/trunk/src/mpid/common/sched/mpid_sched.c 2011-02-15 21:58:52 UTC (rev 7971)
+++ mpich2/trunk/src/mpid/common/sched/mpid_sched.c 2011-02-15 21:58:56 UTC (rev 7972)
@@ -129,6 +129,11 @@
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);
+ if (HANDLE_GET_KIND(e->u.reduce.op) != HANDLE_KIND_BUILTIN) {
+ MPID_Op *op_ptr = NULL;
+ MPID_Op_get_ptr(e->u.reduce.op, op_ptr);
+ MPIR_Op_release(op_ptr);
+ }
e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
break;
case MPIDU_SCHED_ENTRY_COPY:
@@ -380,6 +385,16 @@
e->u.send.sreq = NULL; /* will be populated by _start_entry */
e->u.send.comm = comm;
+ /* the user may free the comm & type after initiating but before the
+ * underlying send is actually posted, so we must add a reference here and
+ * release it at entry completion time */
+ MPIR_Comm_add_ref(comm);
+ if (HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN) {
+ MPID_Datatype *dtp = NULL;
+ MPID_Datatype_get_ptr(datatype, dtp);
+ MPID_Datatype_add_ref(dtp);
+ }
+
fn_exit:
return mpi_errno;
fn_fail:
@@ -409,6 +424,13 @@
e->u.recv.rreq = NULL; /* will be populated by _start_entry */
e->u.recv.comm = comm;
+ MPIR_Comm_add_ref(comm);
+ if (HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN) {
+ MPID_Datatype *dtp = NULL;
+ MPID_Datatype_get_ptr(datatype, dtp);
+ MPID_Datatype_add_ref(dtp);
+ }
+
fn_exit:
return mpi_errno;
fn_fail:
@@ -439,6 +461,17 @@
reduce->datatype = datatype;
reduce->op = op;
+ if (HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN) {
+ MPID_Datatype *dtp = NULL;
+ MPID_Datatype_get_ptr(datatype, dtp);
+ MPID_Datatype_add_ref(dtp);
+ }
+ if (HANDLE_GET_KIND(op) != HANDLE_KIND_BUILTIN) {
+ MPID_Op *op_ptr = NULL;
+ MPID_Op_get_ptr(op, op_ptr);
+ MPIR_Op_add_ref(op_ptr);
+ }
+
fn_exit:
return mpi_errno;
fn_fail:
@@ -473,6 +506,17 @@
copy->outcount = outcount;
copy->outtype = outtype;
+ if (HANDLE_GET_KIND(intype) != HANDLE_KIND_BUILTIN) {
+ MPID_Datatype *dtp = NULL;
+ MPID_Datatype_get_ptr(intype, dtp);
+ MPID_Datatype_add_ref(dtp);
+ }
+ if (HANDLE_GET_KIND(outtype) != HANDLE_KIND_BUILTIN) {
+ MPID_Datatype *dtp = NULL;
+ MPID_Datatype_get_ptr(outtype, dtp);
+ MPID_Datatype_add_ref(dtp);
+ }
+
fn_exit:
return mpi_errno;
fn_fail:
@@ -558,6 +602,12 @@
dprintf(stderr, "completed SEND entry %d, sreq=%p\n", i, e->u.send.sreq);
e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
MPID_Request_release(e->u.send.sreq);
+ MPIR_Comm_release(e->u.send.comm, /*isDisconnect=*/FALSE);
+ if (HANDLE_GET_KIND(e->u.send.datatype) != HANDLE_KIND_BUILTIN) {
+ MPID_Datatype *dtp = NULL;
+ MPID_Datatype_get_ptr(e->u.send.datatype, dtp);
+ MPID_Datatype_release(dtp);
+ }
e->u.send.sreq = NULL;
}
break;
@@ -567,6 +617,12 @@
e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
MPID_Request_release(e->u.recv.rreq);
e->u.recv.rreq = NULL;
+ MPIR_Comm_release(e->u.recv.comm, /*isDisconnect=*/FALSE);
+ if (HANDLE_GET_KIND(e->u.recv.datatype) != HANDLE_KIND_BUILTIN) {
+ MPID_Datatype *dtp = NULL;
+ MPID_Datatype_get_ptr(e->u.recv.datatype, dtp);
+ MPID_Datatype_release(dtp);
+ }
}
break;
default:
More information about the mpich2-commits
mailing list