|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpiimpl.h"
|
|
Packit Service |
c5cf8c |
#include "group.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* -- Begin Profiling Symbol Block for routine MPI_Group_union */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_Group_union = PMPI_Group_union
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_Group_union MPI_Group_union
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_Group_union as PMPI_Group_union
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPI_Group_union")));
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
/* -- End Profiling Symbol Block */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
|
|
Packit Service |
c5cf8c |
the MPI routines */
|
|
Packit Service |
c5cf8c |
#ifndef MPICH_MPI_FROM_PMPI
|
|
Packit Service |
c5cf8c |
#undef MPI_Group_union
|
|
Packit Service |
c5cf8c |
#define MPI_Group_union PMPI_Group_union
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPIR_Group_union_impl
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
int MPIR_Group_union_impl(MPIR_Group * group_ptr1, MPIR_Group * group_ptr2,
|
|
Packit Service |
c5cf8c |
MPIR_Group ** new_group_ptr)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
int g1_idx, g2_idx, nnew, i, k, size1, size2, mylpid;
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPIR_GROUP_UNION_IMPL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPIR_GROUP_UNION_IMPL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Determine the size of the new group. The new group consists of all
|
|
Packit Service |
c5cf8c |
* members of group1 plus the members of group2 that are not in group1.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
g1_idx = group_ptr1->idx_of_first_lpid;
|
|
Packit Service |
c5cf8c |
g2_idx = group_ptr2->idx_of_first_lpid;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* If the lpid list hasn't been created, do it now */
|
|
Packit Service |
c5cf8c |
if (g1_idx < 0) {
|
|
Packit Service |
c5cf8c |
MPII_Group_setup_lpid_list(group_ptr1);
|
|
Packit Service |
c5cf8c |
g1_idx = group_ptr1->idx_of_first_lpid;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (g2_idx < 0) {
|
|
Packit Service |
c5cf8c |
MPII_Group_setup_lpid_list(group_ptr2);
|
|
Packit Service |
c5cf8c |
g2_idx = group_ptr2->idx_of_first_lpid;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
nnew = group_ptr1->size;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Clear the flag bits on the second group. The flag is set if
|
|
Packit Service |
c5cf8c |
* a member of the second group belongs to the union */
|
|
Packit Service |
c5cf8c |
size2 = group_ptr2->size;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size2; i++) {
|
|
Packit Service |
c5cf8c |
group_ptr2->lrank_to_lpid[i].flag = 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* Loop through the lists that are ordered by lpid (local process
|
|
Packit Service |
c5cf8c |
* id) to detect which processes in group 2 are not in group 1
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
while (g1_idx >= 0 && g2_idx >= 0) {
|
|
Packit Service |
c5cf8c |
int l1_pid, l2_pid;
|
|
Packit Service |
c5cf8c |
l1_pid = group_ptr1->lrank_to_lpid[g1_idx].lpid;
|
|
Packit Service |
c5cf8c |
l2_pid = group_ptr2->lrank_to_lpid[g2_idx].lpid;
|
|
Packit Service |
c5cf8c |
if (l1_pid > l2_pid) {
|
|
Packit Service |
c5cf8c |
nnew++;
|
|
Packit Service |
c5cf8c |
group_ptr2->lrank_to_lpid[g2_idx].flag = 1;
|
|
Packit Service |
c5cf8c |
g2_idx = group_ptr2->lrank_to_lpid[g2_idx].next_lpid;
|
|
Packit Service |
c5cf8c |
} else if (l1_pid == l2_pid) {
|
|
Packit Service |
c5cf8c |
g1_idx = group_ptr1->lrank_to_lpid[g1_idx].next_lpid;
|
|
Packit Service |
c5cf8c |
g2_idx = group_ptr2->lrank_to_lpid[g2_idx].next_lpid;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
/* l1 < l2 */
|
|
Packit Service |
c5cf8c |
g1_idx = group_ptr1->lrank_to_lpid[g1_idx].next_lpid;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* If we hit the end of group1, add the remaining members of group 2 */
|
|
Packit Service |
c5cf8c |
while (g2_idx >= 0) {
|
|
Packit Service |
c5cf8c |
nnew++;
|
|
Packit Service |
c5cf8c |
group_ptr2->lrank_to_lpid[g2_idx].flag = 1;
|
|
Packit Service |
c5cf8c |
g2_idx = group_ptr2->lrank_to_lpid[g2_idx].next_lpid;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (nnew == 0) {
|
|
Packit Service |
c5cf8c |
*new_group_ptr = MPIR_Group_empty;
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Allocate a new group and lrank_to_lpid array */
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Group_create(nnew, new_group_ptr);
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
MPIR_ERR_POP(mpi_errno);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* If this process is in group1, then we can set the rank now.
|
|
Packit Service |
c5cf8c |
* If we are not in this group, this assignment will set the
|
|
Packit Service |
c5cf8c |
* current rank to MPI_UNDEFINED */
|
|
Packit Service |
c5cf8c |
(*new_group_ptr)->rank = group_ptr1->rank;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Add group1 */
|
|
Packit Service |
c5cf8c |
size1 = group_ptr1->size;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size1; i++) {
|
|
Packit Service |
c5cf8c |
(*new_group_ptr)->lrank_to_lpid[i].lpid = group_ptr1->lrank_to_lpid[i].lpid;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Add members of group2 that are not in group 1 */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (group_ptr1->rank == MPI_UNDEFINED && group_ptr2->rank >= 0) {
|
|
Packit Service |
c5cf8c |
mylpid = group_ptr2->lrank_to_lpid[group_ptr2->rank].lpid;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
mylpid = -2;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
k = size1;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size2; i++) {
|
|
Packit Service |
c5cf8c |
if (group_ptr2->lrank_to_lpid[i].flag) {
|
|
Packit Service |
c5cf8c |
(*new_group_ptr)->lrank_to_lpid[k].lpid = group_ptr2->lrank_to_lpid[i].lpid;
|
|
Packit Service |
c5cf8c |
if ((*new_group_ptr)->rank == MPI_UNDEFINED &&
|
|
Packit Service |
c5cf8c |
group_ptr2->lrank_to_lpid[i].lpid == mylpid)
|
|
Packit Service |
c5cf8c |
(*new_group_ptr)->rank = k;
|
|
Packit Service |
c5cf8c |
k++;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* TODO calculate is_local_dense_monotonic */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPIR_GROUP_UNION_IMPL);
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPI_Group_union
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*@
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Group_union - Produces a group by combining two groups
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
+ group1 - first group (handle)
|
|
Packit Service |
c5cf8c |
- group2 - second group (handle)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Output Parameters:
|
|
Packit Service |
c5cf8c |
. newgroup - union group (handle)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N ThreadSafe
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N Fortran
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N Errors
|
|
Packit Service |
c5cf8c |
.N MPI_SUCCESS
|
|
Packit Service |
c5cf8c |
.N MPI_ERR_GROUP
|
|
Packit Service |
c5cf8c |
.N MPI_ERR_EXHAUSTED
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.seealso: MPI_Group_free
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
MPIR_Group *group_ptr1 = NULL;
|
|
Packit Service |
c5cf8c |
MPIR_Group *group_ptr2 = NULL;
|
|
Packit Service |
c5cf8c |
MPIR_Group *new_group_ptr;
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_GROUP_UNION);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_INITIALIZED_ORDIE();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPI_GROUP_UNION);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Validate parameters, especially handles needing to be converted */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPID_BEGIN_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_GROUP(group1, mpi_errno);
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_GROUP(group2, mpi_errno);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPID_END_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Convert MPI object handles to object pointers */
|
|
Packit Service |
c5cf8c |
MPIR_Group_get_ptr(group1, group_ptr1);
|
|
Packit Service |
c5cf8c |
MPIR_Group_get_ptr(group2, group_ptr2);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Validate parameters and objects (post conversion) */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPID_BEGIN_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
/* Validate group_ptr */
|
|
Packit Service |
c5cf8c |
MPIR_Group_valid_ptr(group_ptr1, mpi_errno);
|
|
Packit Service |
c5cf8c |
MPIR_Group_valid_ptr(group_ptr2, mpi_errno);
|
|
Packit Service |
c5cf8c |
/* If group_ptr is not valid, it will be reset to null */
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_ARGNULL(newgroup, "newgroup", mpi_errno);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPID_END_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif /* HAVE_ERROR_CHECKING */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Group_union_impl(group_ptr1, group_ptr2, &new_group_ptr);
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_OBJ_PUBLISH_HANDLE(*newgroup, new_group_ptr->handle);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... end of body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPI_GROUP_UNION);
|
|
Packit Service |
c5cf8c |
MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
mpi_errno =
|
|
Packit Service |
c5cf8c |
MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
|
|
Packit Service |
c5cf8c |
"**mpi_group_union", "**mpi_group_union %G %G %p", group1, group2,
|
|
Packit Service |
c5cf8c |
newgroup);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_return_comm(NULL, FCNAME, mpi_errno);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
}
|