|
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_difference */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_Group_difference = PMPI_Group_difference
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_Group_difference MPI_Group_difference
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_Group_difference as PMPI_Group_difference
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPI_Group_difference")));
|
|
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_difference
|
|
Packit Service |
c5cf8c |
#define MPI_Group_difference PMPI_Group_difference
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPIR_Group_difference_impl
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
int MPIR_Group_difference_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 size1, i, k, g1_idx, g2_idx, l1_pid, l2_pid, nnew;
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPIR_GROUP_DIFFERENCE_IMPL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPIR_GROUP_DIFFERENCE_IMPL);
|
|
Packit Service |
c5cf8c |
/* Return a group consisting of the members of group1 that are *not*
|
|
Packit Service |
c5cf8c |
* in group2 */
|
|
Packit Service |
c5cf8c |
size1 = group_ptr1->size;
|
|
Packit Service |
c5cf8c |
/* Insure that the lpid lists are setup */
|
|
Packit Service |
c5cf8c |
MPIR_Group_setup_lpid_pairs(group_ptr1, group_ptr2);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size1; i++)
|
|
Packit Service |
c5cf8c |
group_ptr1->lrank_to_lpid[i].flag = 0;
|
|
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 |
nnew = size1;
|
|
Packit Service |
c5cf8c |
while (g1_idx >= 0 && g2_idx >= 0) {
|
|
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 |
g1_idx = group_ptr1->lrank_to_lpid[g1_idx].next_lpid;
|
|
Packit Service |
c5cf8c |
} else if (l1_pid > l2_pid) {
|
|
Packit Service |
c5cf8c |
g2_idx = group_ptr2->lrank_to_lpid[g2_idx].next_lpid;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
/* Equal */
|
|
Packit Service |
c5cf8c |
group_ptr1->lrank_to_lpid[g1_idx].flag = 1;
|
|
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 |
nnew--;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* Create the group */
|
|
Packit Service |
c5cf8c |
if (nnew == 0) {
|
|
Packit Service |
c5cf8c |
/* See 5.3.2, Group Constructors. For many group routines,
|
|
Packit Service |
c5cf8c |
* the standard explicitly says to return MPI_GROUP_EMPTY;
|
|
Packit Service |
c5cf8c |
* for others it is implied */
|
|
Packit Service |
c5cf8c |
*new_group_ptr = MPIR_Group_empty;
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Group_create(nnew, new_group_ptr);
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (mpi_errno) {
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
(*new_group_ptr)->rank = MPI_UNDEFINED;
|
|
Packit Service |
c5cf8c |
k = 0;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size1; i++) {
|
|
Packit Service |
c5cf8c |
if (!group_ptr1->lrank_to_lpid[i].flag) {
|
|
Packit Service |
c5cf8c |
(*new_group_ptr)->lrank_to_lpid[k].lpid = group_ptr1->lrank_to_lpid[i].lpid;
|
|
Packit Service |
c5cf8c |
if (i == group_ptr1->rank)
|
|
Packit Service |
c5cf8c |
(*new_group_ptr)->rank = k;
|
|
Packit Service |
c5cf8c |
k++;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* TODO calculate is_local_dense_monotonic */
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPIR_GROUP_DIFFERENCE_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_difference
|
|
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_difference - Makes a group from the difference of 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 - difference group (handle)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Notes:
|
|
Packit Service |
c5cf8c |
The generated group containc the members of 'group1' that are not in 'group2'.
|
|
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_difference(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_DIFFERENCE);
|
|
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_DIFFERENCE);
|
|
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 either 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_difference_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_DIFFERENCE);
|
|
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_difference", "**mpi_group_difference %G %G %p",
|
|
Packit Service |
c5cf8c |
group1, group2, 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 |
}
|