[mpich2-commits] r7774 - in mpich2/trunk/src: include mpi/coll
goodell at mcs.anl.gov
goodell at mcs.anl.gov
Thu Jan 20 16:08:26 CST 2011
Author: goodell
Date: 2011-01-20 16:08:26 -0600 (Thu, 20 Jan 2011)
New Revision: 7774
Modified:
mpich2/trunk/src/include/mpiimpl.h
mpich2/trunk/src/mpi/coll/reduce_local.c
Log:
refactor MPI_Reduce_local s.t. it has an _impl
This provides a single, simple way to invoke reduction operators from
within the library.
Reviewed by balaji at .
Modified: mpich2/trunk/src/include/mpiimpl.h
===================================================================
--- mpich2/trunk/src/include/mpiimpl.h 2011-01-20 22:08:23 UTC (rev 7773)
+++ mpich2/trunk/src/include/mpiimpl.h 2011-01-20 22:08:26 UTC (rev 7774)
@@ -3470,6 +3470,8 @@
int MPIR_Barrier_intra( MPID_Comm *comm_ptr );
int MPIR_Barrier_inter( MPID_Comm *comm_ptr);
+int MPIR_Reduce_local_impl(void *inbuf, void *inoutbuf, int count, MPI_Datatype datatype, MPI_Op op);
+
int MPIR_Setup_intercomm_localcomm( MPID_Comm * );
int MPIR_Comm_create( MPID_Comm ** );
Modified: mpich2/trunk/src/mpi/coll/reduce_local.c
===================================================================
--- mpich2/trunk/src/mpi/coll/reduce_local.c 2011-01-20 22:08:23 UTC (rev 7773)
+++ mpich2/trunk/src/mpi/coll/reduce_local.c 2011-01-20 22:08:26 UTC (rev 7774)
@@ -24,8 +24,72 @@
#define MPI_Reduce_local PMPI_Reduce_local
/* any utility functions should go here, usually prefixed with PMPI_LOCAL to
* correctly handle weak symbols and the profiling interface */
+
+#undef FUNCNAME
+#define FUNCNAME MPIR_Reduce_local_impl
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIR_Reduce_local_impl(void *inbuf, void *inoutbuf, int count, MPI_Datatype datatype, MPI_Op op)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPID_Op *op_ptr;
+ MPI_User_function *uop;
+#ifdef HAVE_CXX_BINDING
+ int is_cxx_uop = 0;
#endif
+ MPIU_THREADPRIV_DECL;
+ if (count == 0) goto fn_exit;
+
+ MPIU_THREADPRIV_GET;
+ MPIU_THREADPRIV_FIELD(op_errno) = MPI_SUCCESS;
+
+ if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
+ /* get the function by indexing into the op table */
+ uop = MPIR_Op_table[op%16 - 1];
+ }
+ else {
+ MPID_Op_get_ptr(op, op_ptr);
+
+#ifdef HAVE_CXX_BINDING
+ if (op_ptr->language == MPID_LANG_CXX) {
+ uop = (MPI_User_function *) op_ptr->function.c_function;
+ is_cxx_uop = 1;
+ }
+ else
+#endif
+ {
+ if ((op_ptr->language == MPID_LANG_C))
+ uop = (MPI_User_function *) op_ptr->function.c_function;
+ else
+ uop = (MPI_User_function *) op_ptr->function.f77_function;
+ }
+ }
+
+ /* actually perform the reduction */
+#ifdef HAVE_CXX_BINDING
+ if (is_cxx_uop) {
+ (*MPIR_Process.cxx_call_op_fn)(inbuf, inoutbuf, count, datatype, uop);
+ }
+ else
+#endif
+ {
+ (*uop)(inbuf, inoutbuf, &count, &datatype);
+ }
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (MPIU_THREADPRIV_FIELD(op_errno))
+ mpi_errno = MPIU_THREADPRIV_FIELD(op_errno);
+ /* --END ERROR HANDLING-- */
+
+fn_exit:
+ return mpi_errno;
+fn_fail:
+ goto fn_exit;
+}
+
+#endif
+
#undef FUNCNAME
#define FUNCNAME MPI_Reduce_local
#undef FCNAME
@@ -58,12 +122,7 @@
int MPI_Reduce_local(void *inbuf, void *inoutbuf, int count, MPI_Datatype datatype, MPI_Op op)
{
int mpi_errno = MPI_SUCCESS;
- MPI_User_function *uop;
MPID_Op *op_ptr;
-#ifdef HAVE_CXX_BINDING
- int is_cxx_uop = 0;
-#endif
- MPIU_THREADPRIV_DECL;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_REDUCE_LOCAL);
MPIR_ERRTEST_INITIALIZED_ORDIE();
@@ -98,49 +157,8 @@
/* ... body of routine ... */
- if (count == 0) goto fn_exit;
+ mpi_errno = MPIR_Reduce_local_impl(inbuf, inoutbuf, count, datatype, op);
- MPIU_THREADPRIV_GET;
- MPIU_THREADPRIV_FIELD(op_errno) = MPI_SUCCESS;
-
- if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
- /* get the function by indexing into the op table */
- uop = MPIR_Op_table[op%16 - 1];
- }
- else {
- MPID_Op_get_ptr(op, op_ptr);
-
-#ifdef HAVE_CXX_BINDING
- if (op_ptr->language == MPID_LANG_CXX) {
- uop = (MPI_User_function *) op_ptr->function.c_function;
- is_cxx_uop = 1;
- }
- else
-#endif
- {
- if ((op_ptr->language == MPID_LANG_C))
- uop = (MPI_User_function *) op_ptr->function.c_function;
- else
- uop = (MPI_User_function *) op_ptr->function.f77_function;
- }
- }
-
- /* actually perform the reduction */
-#ifdef HAVE_CXX_BINDING
- if (is_cxx_uop) {
- (*MPIR_Process.cxx_call_op_fn)(inbuf, inoutbuf, count, datatype, uop);
- }
- else
-#endif
- {
- (*uop)(inbuf, inoutbuf, &count, &datatype);
- }
-
- /* --BEGIN ERROR HANDLING-- */
- if (MPIU_THREADPRIV_FIELD(op_errno))
- mpi_errno = MPIU_THREADPRIV_FIELD(op_errno);
- /* --END ERROR HANDLING-- */
-
/* ... end of body of routine ... */
fn_exit:
More information about the mpich2-commits
mailing list