Commit 8b7a87bc authored by Darius Buntinas's avatar Darius Buntinas
Browse files

[svn-r6941] NMPI_ to MPIR_ changes for comm, group, attr and errhandler functions

parent 3b52db93
......@@ -3469,6 +3469,11 @@ int MPIU_Find_local_and_external(struct MPID_Comm *comm, int *local_size_p, int
int MPIU_Get_internode_rank(MPID_Comm *comm_ptr, int r);
int MPIU_Get_intranode_rank(MPID_Comm *comm_ptr, int r);
/* Trivial accessor macros */
#define MPIR_Comm_rank(comm_ptr) ((comm_ptr)->rank)
#define MPIR_Comm_size(comm_ptr) ((comm_ptr)->local_size)
/* MPIR_ functions. These are versions of MPI_ functions appropriate for calling within MPI */
int MPIR_Cancel_impl(MPID_Request *request_ptr);
struct MPIR_Topology;
......@@ -3487,8 +3492,19 @@ int MPIR_Comm_accept_impl(char * port_name, MPID_Info * info_ptr, int root,
MPID_Comm * comm_ptr, MPID_Comm ** newcomm_ptr);
int MPIR_Comm_connect_impl(char * port_name, MPID_Info * info_ptr, int root,
MPID_Comm * comm_ptr, MPID_Comm ** newcomm_ptr);
int MPIR_Comm_create_errhandler_impl(MPI_Comm_errhandler_function *function,
int MPIR_Comm_create_errhandler_impl(MPI_Comm_errhandler_function *function,
MPI_Errhandler *errhandler);
int MPIR_Comm_dup_impl(MPID_Comm *comm_ptr, MPID_Comm **newcomm_ptr);
int MPIR_Comm_free_impl(MPID_Comm * comm_ptr);
void MPIR_Comm_free_keyval_impl(int keyval);
void MPIR_Comm_get_errhandler_impl(MPID_Comm *comm_ptr, MPID_Errhandler **errhandler_ptr);
void MPIR_Comm_set_errhandler_impl(MPID_Comm *comm_ptr, MPID_Errhandler *errhandler_ptr);
void MPIR_Comm_get_name_impl(MPID_Comm *comm, char *comm_name, int *resultlen);
int MPIR_Comm_group_impl(MPID_Comm *comm_ptr, MPID_Group **group_ptr);
int MPIR_Comm_remote_group_impl(MPID_Comm *comm_ptr, MPID_Group **group_ptr);
int MPIR_Comm_split(MPID_Comm *comm_ptr, int color, int key, MPID_Comm **newcomm_ptr);
void MPIR_Group_compare_impl(MPID_Group *group_ptr1, MPID_Group *group_ptr2, int *result);
int MPIR_Group_free_impl(MPID_Group *group_ptr);
#endif /* MPIIMPL_INCLUDED */
......@@ -31,14 +31,7 @@
#define NMPI_Test MPI_Test
#define NMPI_Type_get_attr MPI_Type_get_attr
#define NMPI_Type_set_attr MPI_Type_set_attr
#define NMPI_Comm_free_keyval MPI_Comm_free_keyval
#define NMPI_Comm_group MPI_Comm_group
#define NMPI_Comm_remote_group MPI_Comm_remote_group
#define NMPI_Group_compare MPI_Group_compare
#define NMPI_Group_free MPI_Group_free
#define NMPI_Comm_split MPI_Comm_split
#define NMPI_Comm_size MPI_Comm_size
#define NMPI_Comm_rank MPI_Comm_rank
#define NMPI_Isend MPI_Isend
#define NMPI_Irecv MPI_Irecv
#define NMPI_Recv MPI_Recv
......@@ -46,8 +39,6 @@
#define NMPI_Waitall MPI_Waitall
#define NMPI_Sendrecv MPI_Sendrecv
#define NMPI_Type_extent MPI_Type_extent
#define NMPI_Comm_free MPI_Comm_free
#define NMPI_Comm_dup MPI_Comm_dup
#define NMPI_Type_lb MPI_Type_lb
#define NMPI_Type_indexed MPI_Type_indexed
#define NMPI_Type_commit MPI_Type_commit
......@@ -68,9 +59,6 @@
#define NMPI_Info_get MPI_Info_get
#define NMPI_Info_create MPI_Info_create
#define NMPI_Info_set MPI_Info_set
#define NMPI_Comm_get_name MPI_Comm_get_name
#define NMPI_Comm_get_errhandler MPI_Comm_get_errhandler
#define NMPI_Comm_set_errhandler MPI_Comm_set_errhandler
#define NMPI_Comm_call_errhandler MPI_Comm_call_errhandler
#define NMPI_Grequest_start MPI_Grequest_start
#define NMPI_Grequest_complete MPI_Grequest_complete
......@@ -96,14 +84,7 @@
#define NMPI_Test PMPI_Test
#define NMPI_Type_get_attr PMPI_Type_get_attr
#define NMPI_Type_set_attr PMPI_Type_set_attr
#define NMPI_Comm_free_keyval PMPI_Comm_free_keyval
#define NMPI_Comm_group PMPI_Comm_group
#define NMPI_Comm_remote_group PMPI_Comm_remote_group
#define NMPI_Group_compare PMPI_Group_compare
#define NMPI_Group_free PMPI_Group_free
#define NMPI_Comm_split PMPI_Comm_split
#define NMPI_Comm_size PMPI_Comm_size
#define NMPI_Comm_rank PMPI_Comm_rank
#define NMPI_Isend PMPI_Isend
#define NMPI_Irecv PMPI_Irecv
#define NMPI_Recv PMPI_Recv
......@@ -111,8 +92,6 @@
#define NMPI_Waitall PMPI_Waitall
#define NMPI_Sendrecv PMPI_Sendrecv
#define NMPI_Type_extent PMPI_Type_extent
#define NMPI_Comm_free PMPI_Comm_free
#define NMPI_Comm_dup PMPI_Comm_dup
#define NMPI_Type_lb PMPI_Type_lb
#define NMPI_Type_indexed PMPI_Type_indexed
#define NMPI_Type_commit PMPI_Type_commit
......@@ -133,9 +112,6 @@
#define NMPI_Info_get PMPI_Info_get
#define NMPI_Info_create PMPI_Info_create
#define NMPI_Info_set PMPI_Info_set
#define NMPI_Comm_get_name PMPI_Comm_get_name
#define NMPI_Comm_get_errhandler PMPI_Comm_get_errhandler
#define NMPI_Comm_set_errhandler PMPI_Comm_set_errhandler
#define NMPI_Comm_call_errhandler PMPI_Comm_call_errhandler
#define NMPI_Grequest_start PMPI_Grequest_start
#define NMPI_Grequest_complete PMPI_Grequest_complete
......
......@@ -24,11 +24,33 @@
#undef MPI_Comm_free_keyval
#define MPI_Comm_free_keyval PMPI_Comm_free_keyval
#undef FUNCNAME
#define FUNCNAME MPIR_Comm_free_keyval_impl
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
void MPIR_Comm_free_keyval_impl(int keyval)
{
int in_use;
MPID_Keyval *keyval_ptr;
MPID_Keyval_get_ptr(keyval, keyval_ptr);
if (!keyval_ptr->was_freed) {
keyval_ptr->was_freed = 1;
MPIR_Keyval_release_ref( keyval_ptr, &in_use);
if (!in_use) {
MPIU_Handle_obj_free( &MPID_Keyval_mem, keyval_ptr );
}
}
return;
}
#endif
#undef FUNCNAME
#define FUNCNAME MPI_Comm_free_keyval
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/*@
MPI_Comm_free_keyval - Frees an attribute key for communicators
......@@ -49,11 +71,7 @@ Key values are global (they can be used with any and all communicators)
@*/
int MPI_Comm_free_keyval(int *comm_keyval)
{
#ifdef HAVE_ERROR_CHECKING
static const char FCNAME[] = "MPI_Comm_free_keyval";
#endif
MPID_Keyval *keyval_ptr = NULL;
int in_use;
int mpi_errno = MPI_SUCCESS;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_COMM_FREE_KEYVAL);
......@@ -94,16 +112,10 @@ int MPI_Comm_free_keyval(int *comm_keyval)
# endif /* HAVE_ERROR_CHECKING */
/* ... body of routine ... */
if (!keyval_ptr->was_freed) {
keyval_ptr->was_freed = 1;
MPIR_Keyval_release_ref( keyval_ptr, &in_use);
if (!in_use) {
MPIU_Handle_obj_free( &MPID_Keyval_mem, keyval_ptr );
}
}
*comm_keyval = MPI_KEYVAL_INVALID;
MPIR_Comm_free_keyval_impl(*comm_keyval);
*comm_keyval = MPI_KEYVAL_INVALID;
/* ... end of body of routine ... */
#ifdef HAVE_ERROR_CHECKING
......
......@@ -26,10 +26,11 @@
#undef FUNCNAME
#define FUNCNAME MPIR_CommSetAttr
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIR_CommSetAttr( MPI_Comm comm, int comm_keyval, void *attribute_val,
MPIR_AttrType attrType )
{
static const char FCNAME[] = "MPIR_CommSetAttr";
int mpi_errno = MPI_SUCCESS;
MPID_Comm *comm_ptr = NULL;
MPID_Keyval *keyval_ptr = NULL;
......
......@@ -6,6 +6,7 @@
*/
#include "mpiimpl.h"
#include "attr.h"
/* -- Begin Profiling Symbol Block for routine MPI_Keyval_free */
#if defined(HAVE_PRAGMA_WEAK)
......@@ -56,7 +57,7 @@ int MPI_Keyval_free(int *keyval)
{
static const char FCNAME[] = "MPI_Keyval_free";
int mpi_errno = MPI_SUCCESS;
MPIU_THREADPRIV_DECL; \
MPID_Keyval *keyval_ptr = NULL;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_KEYVAL_FREE);
MPIR_ERRTEST_INITIALIZED_ORDIE();
......@@ -74,17 +75,29 @@ int MPI_Keyval_free(int *keyval)
}
# endif /* HAVE_ERROR_CHECKING */
/* Convert MPI object handles to object pointers */
MPID_Keyval_get_ptr( *keyval, keyval_ptr );
/* Validate parameters and objects (post conversion) */
# ifdef HAVE_ERROR_CHECKING
{
MPID_BEGIN_ERROR_CHECKS;
{
MPID_Keyval_valid_ptr( keyval_ptr, mpi_errno );
if (mpi_errno) goto fn_fail;
}
MPID_END_ERROR_CHECKS;
}
# endif /* HAVE_ERROR_CHECKING */
/* ... body of routine ... */
MPIU_THREADPRIV_GET; \
MPIR_Nest_incr();
mpi_errno = NMPI_Comm_free_keyval( keyval );
MPIR_Nest_decr();
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIR_Comm_free_keyval_impl(*keyval);
*keyval = MPI_KEYVAL_INVALID;
/* ... end of body of routine ... */
fn_exit:
fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_KEYVAL_FREE);
MPIU_THREAD_CS_EXIT(ALLFUNC,);
return mpi_errno;
......
......@@ -490,7 +490,7 @@ int MPI_Alltoallv(void *sendbuf, int *sendcnts, int *sdispls,
mpi_errno = MPIR_Alltoallv_impl(sendbuf, sendcnts, sdispls,
sendtype, recvbuf, recvcnts,
rdispls, recvtype, comm_ptr);
if (mpi_errno) goto fn_exit;
if (mpi_errno) goto fn_fail;
/* ... end of body of routine ... */
......
......@@ -1301,7 +1301,7 @@ int MPI_Bcast( void *buffer, int count, MPI_Datatype datatype, int root,
/* ... body of routine ... */
mpi_errno = MPIR_Bcast_impl( buffer, count, datatype, root, comm_ptr );
if (mpi_errno) goto fn_exit;
if (mpi_errno) goto fn_fail;
/* ... end of body of routine ... */
......
......@@ -392,7 +392,7 @@ int MPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
/* ... body of routine ... */
mpi_errno = MPIR_Exscan_impl(sendbuf, recvbuf, count, datatype, op, comm_ptr);
if (mpi_errno) goto fn_exit;
if (mpi_errno) goto fn_fail;
/* ... end of body of routine ... */
......
......@@ -1195,7 +1195,7 @@ int MPI_Reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
/* ... body of routine ... */
mpi_errno = MPIR_Reduce_impl(sendbuf, recvbuf, count, datatype, op, root, comm_ptr);
if (mpi_errno) goto fn_exit;
if (mpi_errno) goto fn_fail;
/* ... end of body of routine ... */
......
......@@ -71,15 +71,12 @@ int MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
int mpi_errno = MPI_SUCCESS;
MPID_Comm *comm_ptr1 = NULL;
MPID_Comm *comm_ptr2 = NULL;
MPIU_THREADPRIV_DECL;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_COMM_COMPARE);
MPIR_ERRTEST_INITIALIZED_ORDIE();
MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_COMM_COMPARE);
MPIU_THREADPRIV_GET;
# ifdef HAVE_ERROR_CHECKING
{
MPID_BEGIN_ERROR_CHECKS;
......@@ -120,35 +117,40 @@ int MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
*result = MPI_IDENT;
}
else if (comm_ptr1->comm_kind == MPID_INTRACOMM) {
MPI_Group group1, group2;
MPID_Group *group_ptr1, *group_ptr2;
MPIR_Nest_incr();
NMPI_Comm_group( comm1, &group1 );
NMPI_Comm_group( comm2, &group2 );
NMPI_Group_compare( group1, group2, result );
mpi_errno = MPIR_Comm_group_impl(comm_ptr1, &group_ptr1);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIR_Comm_group_impl(comm_ptr2, &group_ptr2);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIR_Group_compare_impl(group_ptr1, group_ptr2, result);
/* If the groups are the same but the contexts are different, then
the communicators are congruent */
if (*result == MPI_IDENT)
if (*result == MPI_IDENT)
*result = MPI_CONGRUENT;
NMPI_Group_free( &group1 );
NMPI_Group_free( &group2 );
MPIR_Nest_decr();
mpi_errno = MPIR_Group_free_impl(group_ptr1);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIR_Group_free_impl(group_ptr2);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else {
/* INTER_COMM */
int lresult, rresult;
MPI_Group group1, group2;
MPI_Group rgroup1, rgroup2;
MPID_Group *group_ptr1, *group_ptr2;
MPID_Group *rgroup_ptr1, *rgroup_ptr2;
/* Get the groups and see what their relationship is */
MPIR_Nest_incr();
NMPI_Comm_group (comm1, &group1);
NMPI_Comm_group (comm2, &group2);
NMPI_Group_compare ( group1, group2, &lresult );
NMPI_Comm_remote_group (comm1, &rgroup1);
NMPI_Comm_remote_group (comm2, &rgroup2);
NMPI_Group_compare ( rgroup1, rgroup2, &rresult );
mpi_errno = MPIR_Comm_group_impl(comm_ptr1, &group_ptr1);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIR_Comm_group_impl(comm_ptr2, &group_ptr2);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIR_Group_compare_impl(group_ptr1, group_ptr2, &lresult);
mpi_errno = MPIR_Comm_remote_group_impl(comm_ptr1, &rgroup_ptr1);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIR_Comm_remote_group_impl(comm_ptr2, &rgroup_ptr2);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIR_Group_compare_impl(rgroup_ptr1, rgroup_ptr2, &rresult);
/* Choose the result that is "least" strong. This works
due to the ordering of result types in mpi.h */
......@@ -160,23 +162,24 @@ int MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
(*result) = MPI_CONGRUENT;
/* Free the groups */
NMPI_Group_free (&group1);
NMPI_Group_free (&group2);
NMPI_Group_free (&rgroup1);
NMPI_Group_free (&rgroup2);
MPIR_Nest_decr();
mpi_errno = MPIR_Group_free_impl(group_ptr1);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIR_Group_free_impl(group_ptr2);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIR_Group_free_impl(rgroup_ptr1);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIR_Group_free_impl(rgroup_ptr2);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
/* ... end of body of routine ... */
#ifdef HAVE_ERROR_CHECKING
fn_exit:
#endif
MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_COMM_COMPARE);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
# ifdef HAVE_ERROR_CHECKING
fn_fail:
# ifdef HAVE_ERROR_CHECKING
{
mpi_errno = MPIR_Err_create_code(
mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
......@@ -184,9 +187,9 @@ int MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
"**mpi_comm_compare %C %C %p", comm1, comm2, result);
}
/* Use whichever communicator is non-null if possible */
# endif
mpi_errno = MPIR_Err_return_comm( comm_ptr1 ? comm_ptr1 : comm_ptr2,
FCNAME, mpi_errno );
goto fn_exit;
# endif
/* --END ERROR HANDLING-- */
}
......@@ -24,11 +24,51 @@
#undef MPI_Comm_dup
#define MPI_Comm_dup PMPI_Comm_dup
#undef FUNCNAME
#define FUNCNAME MPIR_Comm_dup_impl
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIR_Comm_dup_impl(MPID_Comm *comm_ptr, MPID_Comm **newcomm_ptr)
{
int mpi_errno = MPI_SUCCESS;
MPID_Attribute *new_attributes = 0;
/* Copy attributes, executing the attribute copy functions */
/* This accesses the attribute dup function through the perprocess
structure to prevent comm_dup from forcing the linking of the
attribute functions. The actual function is (by default)
MPIR_Attr_dup_list
*/
if (MPIR_Process.attr_dup) {
mpi_errno = MPIR_Process.attr_dup( comm_ptr->handle,
comm_ptr->attributes,
&new_attributes );
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
/* Generate a new context value and a new communicator structure */
/* We must use the local size, because this is compared to the
rank of the process in the communicator. For intercomms,
this must be the local size */
mpi_errno = MPIR_Comm_copy( comm_ptr, comm_ptr->local_size, newcomm_ptr );
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
(*newcomm_ptr)->attributes = new_attributes;
fn_exit:
return mpi_errno;
fn_fail:
goto fn_exit;
}
#endif
#undef FUNCNAME
#define FUNCNAME MPI_Comm_dup
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/*@
MPI_Comm_dup - Duplicates an existing communicator with all its cached
......@@ -76,10 +116,8 @@ Notes:
@*/
int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm)
{
static const char FCNAME[] = "MPI_Comm_dup";
int mpi_errno = MPI_SUCCESS;
MPID_Comm *comm_ptr = NULL, *newcomm_ptr;
MPID_Attribute *new_attributes = 0;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_COMM_DUP);
MPIR_ERRTEST_INITIALIZED_ORDIE();
......@@ -118,38 +156,9 @@ int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm)
# endif /* HAVE_ERROR_CHECKING */
/* ... body of routine ... */
/* Copy attributes, executing the attribute copy functions */
/* This accesses the attribute dup function through the perprocess
structure to prevent comm_dup from forcing the linking of the
attribute functions. The actual function is (by default)
MPIR_Attr_dup_list
*/
if (MPIR_Process.attr_dup) {
mpi_errno = MPIR_Process.attr_dup( comm_ptr->handle,
comm_ptr->attributes,
&new_attributes );
if (mpi_errno) {
/* Note: The error code returned here should reflect the error code
determined by the user routine called during the
attribute duplication step. Adding additional text to the
message associated with the code is allowable; changing the
code is not */
*newcomm = MPI_COMM_NULL;
goto fn_fail;
}
}
/* Generate a new context value and a new communicator structure */
/* We must use the local size, because this is compared to the
rank of the process in the communicator. For intercomms,
this must be the local size */
mpi_errno = MPIR_Comm_copy( comm_ptr, comm_ptr->local_size,
&newcomm_ptr );
if (mpi_errno) goto fn_fail;
newcomm_ptr->attributes = new_attributes;
mpi_errno = MPIR_Comm_dup_impl(comm_ptr, &newcomm_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_OBJ_PUBLISH_HANDLE(*newcomm, newcomm_ptr->handle);
/* ... end of body of routine ... */
......@@ -168,6 +177,7 @@ int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm)
"**mpi_comm_dup %C %p", comm, newcomm);
}
# endif
*newcomm = MPI_COMM_NULL;
mpi_errno = MPIR_Err_return_comm( comm_ptr, FCNAME, mpi_errno );
goto fn_exit;
/* --END ERROR HANDLING-- */
......
......@@ -24,11 +24,20 @@
#undef MPI_Comm_free
#define MPI_Comm_free PMPI_Comm_free
#undef FUNCNAME
#define FUNCNAME MPIR_Comm_free_impl
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIR_Comm_free_impl(MPID_Comm * comm_ptr)
{
return MPIR_Comm_release(comm_ptr, 0);
}
#endif
#undef FUNCNAME
#define FUNCNAME MPI_Comm_free
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/*@
MPI_Comm_free - Marks the communicator object for deallocation
......@@ -65,7 +74,6 @@ disallows freeing a null communicator. The text from the standard is:
@*/
int MPI_Comm_free(MPI_Comm *comm)
{
static const char FCNAME[] = "MPI_Comm_free";
int mpi_errno = MPI_SUCCESS;
MPID_Comm *comm_ptr = NULL;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_COMM_FREE);
......@@ -114,7 +122,7 @@ int MPI_Comm_free(MPI_Comm *comm)
/* ... body of routine ... */
mpi_errno = MPIR_Comm_release(comm_ptr, 0);
mpi_errno = MPIR_Comm_free_impl(comm_ptr);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
*comm = MPI_COMM_NULL;
......
......@@ -23,6 +23,14 @@
#undef MPI_Comm_get_name
#define MPI_Comm_get_name PMPI_Comm_get_name
void MPIR_Comm_get_name_impl(MPID_Comm *comm_ptr, char *comm_name, int *resultlen)
{
/* The user must allocate a large enough section of memory */
MPIU_Strncpy(comm_name, comm_ptr->name, MPI_MAX_OBJECT_NAME);
*resultlen = (int)strlen(comm_name);
return;
}
#endif
#undef FUNCNAME
......@@ -95,11 +103,8 @@ int MPI_Comm_get_name(MPI_Comm comm, char *comm_name, int *resultlen)
# endif /* HAVE_ERROR_CHECKING */
/* ... body of routine ... */
/* The user must allocate a large enough section of memory */
MPIU_Strncpy( comm_name, comm_ptr->name, MPI_MAX_OBJECT_NAME );
*resultlen = (int)strlen( comm_name );
MPIR_Comm_get_name_impl(comm_ptr, comm_name, resultlen);
/* ... end of body of routine ... */
......
......@@ -24,11 +24,63 @@
#undef MPI_Comm_group
#define MPI_Comm_group PMPI_Comm_group
#undef FUNCNAME
#define FUNCNAME MPIR_Comm_group_impl
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIR_Comm_group_impl(MPID_Comm *comm_ptr, MPID_Group **group_ptr)
{
int mpi_errno = MPI_SUCCESS;
MPID_VCR *local_vcr;
int i, lpid, n;
/* Create a group if necessary and populate it with the
local process ids */
if (!comm_ptr->local_group) {
n = comm_ptr->local_size;
mpi_errno = MPIR_Group_create( n, group_ptr );
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* Make sure that we get the correct group */
if (comm_ptr->comm_kind == MPID_INTERCOMM) {
local_vcr = comm_ptr->local_vcr;
}
else
local_vcr = comm_ptr->vcr;
for (i=0; i<n; i++) {
(void) MPID_VCR_Get_lpid( local_vcr[i], &lpid );
(*group_ptr)->lrank_to_lpid[i].lrank = i;
(*group_ptr)->lrank_to_lpid[i].lpid = lpid;
}
(*group_ptr)->size = n;
(*group_ptr)->rank = comm_ptr->rank;
(*group_ptr)->idx_of_first_lpid = -1;
comm_ptr->local_group = *group_ptr;
} else {
*group_ptr = comm_ptr->local_group;
}
/* FIXME : Add a sanity check that the size of the group is the same as
the size of the communicator. This helps catch corrupted
communicators */
MPIR_Group_add_ref( comm_ptr->local_group );
fn_exit:
return mpi_errno;
fn_fail:
goto fn_exit;
}
#endif