Blame src/mpi/topo/dist_gr_neighb.c

Packit Service c5cf8c
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit Service c5cf8c
/*
Packit Service c5cf8c
 *
Packit Service c5cf8c
 *  (C) 2009 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
Packit Service c5cf8c
/* -- Begin Profiling Symbol Block for routine MPI_Dist_graph_neighbors */
Packit Service c5cf8c
#if defined(HAVE_PRAGMA_WEAK)
Packit Service c5cf8c
#pragma weak MPI_Dist_graph_neighbors = PMPI_Dist_graph_neighbors
Packit Service c5cf8c
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
Packit Service c5cf8c
#pragma _HP_SECONDARY_DEF PMPI_Dist_graph_neighbors  MPI_Dist_graph_neighbors
Packit Service c5cf8c
#elif defined(HAVE_PRAGMA_CRI_DUP)
Packit Service c5cf8c
#pragma _CRI duplicate MPI_Dist_graph_neighbors as PMPI_Dist_graph_neighbors
Packit Service c5cf8c
#elif defined(HAVE_WEAK_ATTRIBUTE)
Packit Service c5cf8c
int MPI_Dist_graph_neighbors(MPI_Comm comm, int maxindegree, int sources[], int sourceweights[],
Packit Service c5cf8c
                             int maxoutdegree, int destinations[], int destweights[])
Packit Service c5cf8c
    __attribute__ ((weak, alias("PMPI_Dist_graph_neighbors")));
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_Dist_graph_neighbors
Packit Service c5cf8c
#define MPI_Dist_graph_neighbors PMPI_Dist_graph_neighbors
Packit Service c5cf8c
/* any utility functions should go here, usually prefixed with PMPI_LOCAL to
Packit Service c5cf8c
 * correctly handle weak symbols and the profiling interface */
Packit Service c5cf8c
Packit Service c5cf8c
#undef FUNCNAME
Packit Service c5cf8c
#define FUNCNAME MPIR_Dist_graph_neighbors_impl
Packit Service c5cf8c
#undef FCNAME
Packit Service c5cf8c
#define FCNAME MPL_QUOTE(FUNCNAME)
Packit Service c5cf8c
int MPIR_Dist_graph_neighbors_impl(MPIR_Comm * comm_ptr,
Packit Service c5cf8c
                                   int maxindegree, int sources[], int sourceweights[],
Packit Service c5cf8c
                                   int maxoutdegree, int destinations[], int destweights[])
Packit Service c5cf8c
{
Packit Service c5cf8c
    int mpi_errno = MPI_SUCCESS;
Packit Service c5cf8c
    MPIR_Topology *topo_ptr = NULL;
Packit Service c5cf8c
Packit Service c5cf8c
    topo_ptr = MPIR_Topology_get(comm_ptr);
Packit Service c5cf8c
    MPIR_ERR_CHKANDJUMP(!topo_ptr ||
Packit Service c5cf8c
                        topo_ptr->kind != MPI_DIST_GRAPH, mpi_errno, MPI_ERR_TOPOLOGY,
Packit Service c5cf8c
                        "**notdistgraphtopo");
Packit Service c5cf8c
Packit Service c5cf8c
    MPIR_Memcpy(sources, topo_ptr->topo.dist_graph.in, maxindegree * sizeof(int));
Packit Service c5cf8c
    MPIR_Memcpy(destinations, topo_ptr->topo.dist_graph.out, maxoutdegree * sizeof(int));
Packit Service c5cf8c
Packit Service c5cf8c
    if (sourceweights != MPI_UNWEIGHTED && topo_ptr->topo.dist_graph.is_weighted) {
Packit Service c5cf8c
        MPIR_Memcpy(sourceweights, topo_ptr->topo.dist_graph.in_weights, maxindegree * sizeof(int));
Packit Service c5cf8c
    }
Packit Service c5cf8c
    if (destweights != MPI_UNWEIGHTED && topo_ptr->topo.dist_graph.is_weighted) {
Packit Service c5cf8c
        MPIR_Memcpy(destweights, topo_ptr->topo.dist_graph.out_weights, maxoutdegree * sizeof(int));
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
  fn_exit:
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_Dist_graph_neighbors
Packit Service c5cf8c
#undef FCNAME
Packit Service c5cf8c
#define FCNAME MPL_QUOTE(FUNCNAME)
Packit Service c5cf8c
/*@
Packit Service c5cf8c
MPI_Dist_graph_neighbors - Provides adjacency information for a distributed graph topology.
Packit Service c5cf8c
Packit Service c5cf8c
Input Parameters:
Packit Service c5cf8c
+ comm - communicator with distributed graph topology (handle)
Packit Service c5cf8c
. maxindegree - size of sources and sourceweights arrays (non-negative integer)
Packit Service c5cf8c
- maxoutdegree - size of destinations and destweights arrays (non-negative integer)
Packit Service c5cf8c
Packit Service c5cf8c
Output Parameters:
Packit Service c5cf8c
+ sources - processes for which the calling process is a destination (array of non-negative integers)
Packit Service c5cf8c
. sourceweights - weights of the edges into the calling process (array of non-negative integers)
Packit Service c5cf8c
. destinations - processes for which the calling process is a source (array of non-negative integers)
Packit Service c5cf8c
- destweights - weights of the edges out of the calling process (array of non-negative integers)
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
@*/
Packit Service c5cf8c
int MPI_Dist_graph_neighbors(MPI_Comm comm,
Packit Service c5cf8c
                             int maxindegree, int sources[], int sourceweights[],
Packit Service c5cf8c
                             int maxoutdegree, int destinations[], int destweights[])
Packit Service c5cf8c
{
Packit Service c5cf8c
    int mpi_errno = MPI_SUCCESS;
Packit Service c5cf8c
    MPIR_Comm *comm_ptr = NULL;
Packit Service c5cf8c
    MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_DIST_GRAPH_NEIGHBORS);
Packit Service c5cf8c
Packit Service c5cf8c
    MPIR_ERRTEST_INITIALIZED_ORDIE();
Packit Service c5cf8c
Packit Service c5cf8c
    /* FIXME: Why does this routine need a CS */
Packit Service c5cf8c
    MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
Packit Service c5cf8c
    MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPI_DIST_GRAPH_NEIGHBORS);
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_COMM(comm, 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_Comm_get_ptr(comm, comm_ptr);
Packit Service c5cf8c
Packit Service c5cf8c
    /* Validate parameters */
Packit Service c5cf8c
#ifdef HAVE_ERROR_CHECKING
Packit Service c5cf8c
    {
Packit Service c5cf8c
        MPID_BEGIN_ERROR_CHECKS;
Packit Service c5cf8c
        {
Packit Service c5cf8c
            MPIR_Topology *topo_ptr = NULL;
Packit Service c5cf8c
            topo_ptr = MPIR_Topology_get(comm_ptr);
Packit Service c5cf8c
            MPIR_ERR_CHKANDJUMP(!topo_ptr ||
Packit Service c5cf8c
                                topo_ptr->kind != MPI_DIST_GRAPH, mpi_errno, MPI_ERR_TOPOLOGY,
Packit Service c5cf8c
                                "**notdistgraphtopo");
Packit Service c5cf8c
Packit Service c5cf8c
            MPIR_ERRTEST_ARGNEG(maxindegree, "maxindegree", mpi_errno);
Packit Service c5cf8c
            MPIR_ERRTEST_ARGNEG(maxoutdegree, "maxoutdegree", mpi_errno);
Packit Service c5cf8c
            MPIR_ERR_CHKANDJUMP3((maxindegree < topo_ptr->topo.dist_graph.indegree), mpi_errno,
Packit Service c5cf8c
                                 MPI_ERR_ARG, "**argtoosmall", "**argtoosmall %s %d %d",
Packit Service c5cf8c
                                 "maxindegree", maxindegree, topo_ptr->topo.dist_graph.indegree);
Packit Service c5cf8c
            MPIR_ERR_CHKANDJUMP3((maxoutdegree < topo_ptr->topo.dist_graph.outdegree), mpi_errno,
Packit Service c5cf8c
                                 MPI_ERR_ARG, "**argtoosmall", "**argtoosmall %s %d %d",
Packit Service c5cf8c
                                 "maxoutdegree", maxoutdegree, topo_ptr->topo.dist_graph.outdegree);
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
Packit Service c5cf8c
    /* ... body of routine ...  */
Packit Service c5cf8c
Packit Service c5cf8c
    mpi_errno = MPIR_Dist_graph_neighbors_impl(comm_ptr,
Packit Service c5cf8c
                                               maxindegree, sources, sourceweights,
Packit Service c5cf8c
                                               maxoutdegree, destinations, destweights);
Packit Service c5cf8c
    if (mpi_errno)
Packit Service c5cf8c
        MPIR_ERR_POP(mpi_errno);
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_DIST_GRAPH_NEIGHBORS);
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
    mpi_errno =
Packit Service c5cf8c
        MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
Packit Service c5cf8c
                             "**mpi_dist_graph_neighbors",
Packit Service c5cf8c
                             "**mpi_dist_graph_neighbors %C %d %p %p %d %p %p", comm, maxindegree,
Packit Service c5cf8c
                             sources, sourceweights, maxoutdegree, destinations, destweights);
Packit Service c5cf8c
#endif
Packit Service c5cf8c
    mpi_errno = MPIR_Err_return_comm(comm_ptr, FCNAME, mpi_errno);
Packit Service c5cf8c
    goto fn_exit;
Packit Service c5cf8c
    /* --END ERROR HANDLING-- */
Packit Service c5cf8c
}