|
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_range_excl */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_Group_range_excl = PMPI_Group_range_excl
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_Group_range_excl MPI_Group_range_excl
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_Group_range_excl as PMPI_Group_range_excl
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MPI_Group * newgroup)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPI_Group_range_excl")));
|
|
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_range_excl
|
|
Packit Service |
c5cf8c |
#define MPI_Group_range_excl PMPI_Group_range_excl
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPIR_Group_range_excl_impl
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
int MPIR_Group_range_excl_impl(MPIR_Group * group_ptr, int n, int ranges[][3],
|
|
Packit Service |
c5cf8c |
MPIR_Group ** new_group_ptr)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
int size, i, j, k, nnew, first, last, stride;
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPIR_GROUP_RANGE_EXCL_IMPL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPIR_GROUP_RANGE_EXCL_IMPL);
|
|
Packit Service |
c5cf8c |
/* Compute size, assuming that included ranks are valid (and distinct) */
|
|
Packit Service |
c5cf8c |
size = group_ptr->size;
|
|
Packit Service |
c5cf8c |
nnew = 0;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < n; i++) {
|
|
Packit Service |
c5cf8c |
first = ranges[i][0];
|
|
Packit Service |
c5cf8c |
last = ranges[i][1];
|
|
Packit Service |
c5cf8c |
stride = ranges[i][2];
|
|
Packit Service |
c5cf8c |
/* works for stride of either sign. Error checking above
|
|
Packit Service |
c5cf8c |
* has already guaranteed stride != 0 */
|
|
Packit Service |
c5cf8c |
nnew += 1 + (last - first) / stride;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
nnew = size - nnew;
|
|
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 |
/* --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 |
|
|
Packit Service |
c5cf8c |
/* Group members are taken in rank order from the original group,
|
|
Packit Service |
c5cf8c |
* with the specified members removed. Use the flag array for that
|
|
Packit Service |
c5cf8c |
* purpose. If this was a critical routine, we could use the
|
|
Packit Service |
c5cf8c |
* flag values set in the error checking part, if the error checking
|
|
Packit Service |
c5cf8c |
* was enabled *and* we are not MPI_THREAD_MULTIPLE, but since this
|
|
Packit Service |
c5cf8c |
* is a low-usage routine, we haven't taken that optimization. */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* First, mark the members to exclude */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++)
|
|
Packit Service |
c5cf8c |
group_ptr->lrank_to_lpid[i].flag = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (i = 0; i < n; i++) {
|
|
Packit Service |
c5cf8c |
first = ranges[i][0];
|
|
Packit Service |
c5cf8c |
last = ranges[i][1];
|
|
Packit Service |
c5cf8c |
stride = ranges[i][2];
|
|
Packit Service |
c5cf8c |
if (stride > 0) {
|
|
Packit Service |
c5cf8c |
for (j = first; j <= last; j += stride) {
|
|
Packit Service |
c5cf8c |
group_ptr->lrank_to_lpid[j].flag = 1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
for (j = first; j >= last; j += stride) {
|
|
Packit Service |
c5cf8c |
group_ptr->lrank_to_lpid[j].flag = 1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* Now, run through the group and pick up the members that were
|
|
Packit Service |
c5cf8c |
* not excluded */
|
|
Packit Service |
c5cf8c |
k = 0;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++) {
|
|
Packit Service |
c5cf8c |
if (!group_ptr->lrank_to_lpid[i].flag) {
|
|
Packit Service |
c5cf8c |
(*new_group_ptr)->lrank_to_lpid[k].lpid = group_ptr->lrank_to_lpid[i].lpid;
|
|
Packit Service |
c5cf8c |
if (group_ptr->rank == i) {
|
|
Packit Service |
c5cf8c |
(*new_group_ptr)->rank = k;
|
|
Packit Service |
c5cf8c |
}
|
|
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 |
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPIR_GROUP_RANGE_EXCL_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 |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPI_Group_range_excl
|
|
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_range_excl - Produces a group by excluding ranges of processes from
|
|
Packit Service |
c5cf8c |
an existing group
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
+ group - group (handle)
|
|
Packit Service |
c5cf8c |
. n - number of elements in array 'ranks' (integer)
|
|
Packit Service |
c5cf8c |
- ranges - a one-dimensional array of integer triplets of the
|
|
Packit Service |
c5cf8c |
form (first rank, last rank, stride), indicating the ranks in
|
|
Packit Service |
c5cf8c |
'group' of processes to be excluded from the output group 'newgroup' .
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Output Parameters:
|
|
Packit Service |
c5cf8c |
. newgroup - new group derived from above, preserving the
|
|
Packit Service |
c5cf8c |
order in 'group' (handle)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Note:
|
|
Packit Service |
c5cf8c |
The MPI standard requires that each of the ranks to be excluded must be
|
|
Packit Service |
c5cf8c |
a valid rank in the group and all elements must be distinct or the
|
|
Packit Service |
c5cf8c |
function is erroneous.
|
|
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 |
.N MPI_ERR_RANK
|
|
Packit Service |
c5cf8c |
.N MPI_ERR_ARG
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.seealso: MPI_Group_free
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MPI_Group * newgroup)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
MPIR_Group *group_ptr = NULL, *new_group_ptr;
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_GROUP_RANGE_EXCL);
|
|
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_RANGE_EXCL);
|
|
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(group, 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(group, group_ptr);
|
|
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_ptr, mpi_errno);
|
|
Packit Service |
c5cf8c |
/* If group_ptr is not valid, it will be reset to null */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Check the exclusion array. Ensure that all ranges are
|
|
Packit Service |
c5cf8c |
* valid and that the specified exclusions are unique */
|
|
Packit Service |
c5cf8c |
if (group_ptr) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Group_check_valid_ranges(group_ptr, ranges, n);
|
|
Packit Service |
c5cf8c |
}
|
|
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_range_excl_impl(group_ptr, n, ranges, &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_RANGE_EXCL);
|
|
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_range_excl", "**mpi_group_range_excl %G %d %p %p",
|
|
Packit Service |
c5cf8c |
group, n, ranges, 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 |
}
|