1
1

ompi: clean up topo helper functions

This commit removes the communicator topo helper functions in favor
of functions in mca/topo/base.

Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Этот коммит содержится в:
Nathan Hjelm 2017-07-12 14:13:12 -06:00 коммит произвёл Nathan Hjelm
родитель b0692c6836
Коммит 9b702fb9bd
7 изменённых файлов: 19 добавлений и 158 удалений

Просмотреть файл

@ -10,7 +10,7 @@
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2013 Los Alamos National Security, LLC. All rights
# Copyright (c) 2013-2017 Los Alamos National Security, LLC. All rights
# reserved.
# Copyright (c) 2014 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
@ -26,13 +26,11 @@
headers += \
communicator/communicator.h \
communicator/comm_request.h \
communicator/comm_helpers.h
communicator/comm_request.h
lib@OMPI_LIBMPI_NAME@_la_SOURCES += \
communicator/comm_init.c \
communicator/comm.c \
communicator/comm_cid.c \
communicator/comm_request.c \
communicator/comm_helpers.c
communicator/comm_request.c

Просмотреть файл

@ -1,92 +0,0 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All
* rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
*
* Author(s): Torsten Hoefler <htor@cs.indiana.edu>
*
*/
#include "comm_helpers.h"
int ompi_comm_neighbors_count(MPI_Comm comm, int *indegree, int *outdegree, int *weighted) {
int res;
if (OMPI_COMM_IS_CART(comm)) {
int ndims;
res = MPI_Cartdim_get(comm, &ndims) ;
if (MPI_SUCCESS != res) {
return res;
}
/* outdegree is always 2*ndims because we need to iterate over empty buffers for MPI_PROC_NULL */
*outdegree = *indegree = 2*ndims;
*weighted = 0;
} else if (OMPI_COMM_IS_GRAPH(comm)) {
int rank, nneighbors;
rank = ompi_comm_rank ((ompi_communicator_t *) comm);
res = MPI_Graph_neighbors_count(comm, rank, &nneighbors);
if (MPI_SUCCESS != res) {
return res;
}
*outdegree = *indegree = nneighbors;
*weighted = 0;
} else if (OMPI_COMM_IS_DIST_GRAPH(comm)) {
res = MPI_Dist_graph_neighbors_count(comm, indegree, outdegree, weighted);
} else {
return MPI_ERR_ARG;
}
return MPI_SUCCESS;
}
int ompi_comm_neighbors(MPI_Comm comm, int maxindegree, int sources[], int sourceweights[], int maxoutdegree, int destinations[], int destweights[]) {
int res;
int index = 0;
int indeg, outdeg, wgtd;
res = ompi_comm_neighbors_count(comm, &indeg, &outdeg, &wgtd);
if (MPI_SUCCESS != res) {
return res;
}
if(indeg > maxindegree && outdeg > maxoutdegree) return MPI_ERR_TRUNCATE; /* we want to return *all* neighbors */
if (OMPI_COMM_IS_CART(comm)) {
int ndims, i, rpeer, speer;
res = MPI_Cartdim_get(comm, &ndims);
if (MPI_SUCCESS != res) {
return res;
}
for(i = 0; i<ndims; i++) {
res = MPI_Cart_shift(comm, i, 1, &rpeer, &speer);
if (MPI_SUCCESS != res) {
return res;
}
sources[index] = destinations[index] = rpeer; index++;
sources[index] = destinations[index] = speer; index++;
}
} else if (OMPI_COMM_IS_GRAPH(comm)) {
int rank = ompi_comm_rank ((ompi_communicator_t *) comm);
res = MPI_Graph_neighbors(comm, rank, maxindegree, sources);
if (MPI_SUCCESS != res) {
return res;
}
for(int i=0; i<maxindegree; i++) destinations[i] = sources[i];
} else if (OMPI_COMM_IS_DIST_GRAPH(comm)) {
res = MPI_Dist_graph_neighbors(comm, maxindegree, sources, sourceweights, maxoutdegree, destinations, destweights);
if (MPI_SUCCESS != res) {
return res;
}
} else {
return MPI_ERR_ARG;
}
return MPI_SUCCESS;
}

Просмотреть файл

@ -1,41 +0,0 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* Author(s): Torsten Hoefler <htor@cs.indiana.edu>
*
* $HEADER$
*/
#ifndef __TOPO_HELPERS_H__
#define __TOPO_HELPERS_H__
#include "ompi_config.h"
#include "mpi.h"
#include "ompi/include/ompi/constants.h"
#include "ompi/communicator/communicator.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <math.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
int ompi_comm_neighbors_count(MPI_Comm comm, int *indegree, int *outdegree, int *weighted);
int ompi_comm_neighbors(MPI_Comm comm, int maxindegree, int sources[], int sourceweights[], int maxoutdegree, int destinations[], int destweights[]);
#ifdef __cplusplus
}
#endif
#endif

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
@ -29,7 +29,6 @@
#include "ompi/mpi/c/bindings.h"
#include "ompi/runtime/params.h"
#include "ompi/communicator/communicator.h"
#include "ompi/communicator/comm_helpers.h"
#include "ompi/errhandler/errhandler.h"
#include "ompi/datatype/ompi_datatype.h"
#include "ompi/memchecker.h"
@ -52,7 +51,7 @@ int MPI_Ineighbor_alltoallv(const void *sendbuf, const int sendcounts[], const i
MPI_Request *request)
{
int i, err;
int indegree, outdegree, weighted;
int indegree, outdegree;
MEMCHECKER(
ptrdiff_t recv_ext;
@ -68,7 +67,7 @@ int MPI_Ineighbor_alltoallv(const void *sendbuf, const int sendcounts[], const i
memchecker_datatype(recvtype);
ompi_datatype_type_extent(sendtype, &send_ext);
err = ompi_comm_neighbors_count(comm, &indegree, &outdegree, &weighted);
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
if (MPI_SUCCESS == err) {
if (MPI_IN_PLACE != sendbuf) {
for ( i = 0; i < outdegree; i++ ) {
@ -105,7 +104,7 @@ int MPI_Ineighbor_alltoallv(const void *sendbuf, const int sendcounts[], const i
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
}
err = ompi_comm_neighbors_count(comm, &indegree, &outdegree, &weighted);
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
for (i = 0; i < outdegree; ++i) {
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
@ -29,7 +29,6 @@
#include "ompi/mpi/c/bindings.h"
#include "ompi/runtime/params.h"
#include "ompi/communicator/communicator.h"
#include "ompi/communicator/comm_helpers.h"
#include "ompi/errhandler/errhandler.h"
#include "ompi/datatype/ompi_datatype.h"
#include "ompi/memchecker.h"
@ -52,7 +51,7 @@ int MPI_Ineighbor_alltoallw(const void *sendbuf, const int sendcounts[], const M
MPI_Request *request)
{
int i, err;
int indegree, outdegree, weighted;
int indegree, outdegree;
MEMCHECKER(
ptrdiff_t recv_ext;
@ -60,7 +59,7 @@ int MPI_Ineighbor_alltoallw(const void *sendbuf, const int sendcounts[], const M
memchecker_comm(comm);
err = ompi_comm_neighbors_count(comm, &indegree, &outdegree, &weighted);
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
if (MPI_SUCCESS == err) {
if (MPI_IN_PLACE != sendbuf) {
for ( i = 0; i < outdegree; i++ ) {
@ -105,7 +104,7 @@ int MPI_Ineighbor_alltoallw(const void *sendbuf, const int sendcounts[], const M
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
}
err = ompi_comm_neighbors_count(comm, &indegree, &outdegree, &weighted);
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
for (i = 0; i < outdegree; ++i) {
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]);

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
@ -32,7 +32,6 @@
#include "ompi/errhandler/errhandler.h"
#include "ompi/datatype/ompi_datatype.h"
#include "ompi/memchecker.h"
#include "ompi/communicator/comm_helpers.h"
#include "ompi/mca/topo/topo.h"
#include "ompi/mca/topo/base/base.h"
@ -52,7 +51,7 @@ int MPI_Neighbor_alltoallv(const void *sendbuf, const int sendcounts[], const in
MPI_Datatype recvtype, MPI_Comm comm)
{
int i, err;
int indegree, outdegree, weighted;
int indegree, outdegree;
MEMCHECKER(
ptrdiff_t recv_ext;
@ -68,7 +67,7 @@ int MPI_Neighbor_alltoallv(const void *sendbuf, const int sendcounts[], const in
memchecker_datatype(recvtype);
ompi_datatype_type_extent(sendtype, &send_ext);
err = ompi_comm_neighbors_count(comm, &indegree, &outdegree, &weighted);
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
if (MPI_SUCCESS == err) {
if (MPI_IN_PLACE != sendbuf) {
for ( i = 0; i < outdegree; i++ ) {
@ -105,7 +104,7 @@ int MPI_Neighbor_alltoallv(const void *sendbuf, const int sendcounts[], const in
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
}
err = ompi_comm_neighbors_count(comm, &indegree, &outdegree, &weighted);
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
for (i = 0; i < outdegree; ++i) {
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
@ -32,7 +32,6 @@
#include "ompi/errhandler/errhandler.h"
#include "ompi/datatype/ompi_datatype.h"
#include "ompi/memchecker.h"
#include "ompi/communicator/comm_helpers.h"
#include "ompi/mca/topo/topo.h"
#include "ompi/mca/topo/base/base.h"
@ -52,7 +51,7 @@ int MPI_Neighbor_alltoallw(const void *sendbuf, const int sendcounts[], const MP
const MPI_Datatype recvtypes[], MPI_Comm comm)
{
int i, err;
int indegree, outdegree, weighted;
int indegree, outdegree;
MEMCHECKER(
ptrdiff_t recv_ext;
@ -60,7 +59,7 @@ int MPI_Neighbor_alltoallw(const void *sendbuf, const int sendcounts[], const MP
memchecker_comm(comm);
err = ompi_comm_neighbors_count(comm, &indegree, &outdegree, &weighted);
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
if (MPI_SUCCESS == err) {
if (MPI_IN_PLACE != sendbuf) {
for ( i = 0; i < outdegree; i++ ) {
@ -101,7 +100,7 @@ int MPI_Neighbor_alltoallw(const void *sendbuf, const int sendcounts[], const MP
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
}
err = ompi_comm_neighbors_count(comm, &indegree, &outdegree, &weighted);
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
for (i = 0; i < outdegree; ++i) {
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]);