1
1

topo: do not cast way the const modifier when this is not necessary

update the topo framework and mpi c bindings
Этот коммит содержится в:
Gilles Gouaillardet 2015-08-31 08:46:55 +09:00
родитель 3a446c9797
Коммит 43ef261d46
20 изменённых файлов: 108 добавлений и 99 удалений

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

@ -13,7 +13,7 @@
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
@ -73,8 +73,8 @@ OMPI_DECLSPEC int
mca_topo_base_cart_create(mca_topo_base_module_t *topo_module,
ompi_communicator_t* old_comm,
int ndims,
int *dims,
int *periods,
const int *dims,
const int *periods,
bool reorder,
ompi_communicator_t** comm_topo);
@ -98,11 +98,11 @@ mca_topo_base_cart_get(ompi_communicator_t *comm,
OMPI_DECLSPEC int
mca_topo_base_cart_map(ompi_communicator_t * comm,
int ndims,
int *dims, int *periods, int *newrank);
const int *dims, const int *periods, int *newrank);
OMPI_DECLSPEC int
mca_topo_base_cart_rank(ompi_communicator_t *comm,
int *coords,
const int *coords,
int *rank);
OMPI_DECLSPEC int
@ -114,7 +114,7 @@ mca_topo_base_cart_shift(ompi_communicator_t *comm,
OMPI_DECLSPEC int
mca_topo_base_cart_sub(ompi_communicator_t *comm,
int *remain_dims,
const int *remain_dims,
ompi_communicator_t **new_comm);
OMPI_DECLSPEC int
@ -126,8 +126,8 @@ OMPI_DECLSPEC int
mca_topo_base_graph_create(mca_topo_base_module_t *topo_module,
ompi_communicator_t* old_comm,
int nnodes,
int *index,
int *edges,
const int *index,
const int *edges,
bool reorder,
ompi_communicator_t** new_comm);
@ -141,7 +141,7 @@ mca_topo_base_graph_get(ompi_communicator_t *comm,
OMPI_DECLSPEC int
mca_topo_base_graph_map(ompi_communicator_t * comm,
int nnodes,
int *index, int *edges, int *newrank);
const int *index, const int *edges, int *newrank);
OMPI_DECLSPEC int
mca_topo_base_graph_neighbors(ompi_communicator_t *comm,
@ -161,25 +161,25 @@ mca_topo_base_graph_neighbors_count(ompi_communicator_t *comm,
OMPI_DECLSPEC int
mca_topo_base_dist_graph_distribute(mca_topo_base_module_t* module,
ompi_communicator_t *comm,
int n, int nodes[],
int degrees[], int targets[],
int weights[],
int n, const int nodes[],
const int degrees[], const int targets[],
const int weights[],
mca_topo_base_comm_dist_graph_2_2_0_t** ptopo);
OMPI_DECLSPEC int
mca_topo_base_dist_graph_create(mca_topo_base_module_t* module,
ompi_communicator_t *old_comm,
int n, int nodes[],
int degrees[], int targets[], int weights[],
int n, const int nodes[],
const int degrees[], const int targets[], const int weights[],
ompi_info_t *info, int reorder,
ompi_communicator_t **new_comm);
OMPI_DECLSPEC int
mca_topo_base_dist_graph_create_adjacent(mca_topo_base_module_t* module,
ompi_communicator_t *old_comm,
int indegree, int sources[],
int sourceweights[], int outdegree,
int destinations[], int destweights[],
int indegree, const int sources[],
const int sourceweights[], int outdegree,
const int destinations[], const int destweights[],
ompi_info_t *info, int reorder,
ompi_communicator_t **comm_dist_graph);

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

@ -50,12 +50,12 @@
int mca_topo_base_cart_create(mca_topo_base_module_t *topo,
ompi_communicator_t* old_comm,
int ndims,
int *dims,
int *periods,
const int *dims,
const int *periods,
bool reorder,
ompi_communicator_t** comm_topo)
{
int nprocs = 1, i, *p, new_rank, num_procs, ret;
int nprocs = 1, i, new_rank, num_procs, ret;
ompi_communicator_t *new_comm;
ompi_proc_t **topo_procs = NULL;
mca_topo_base_comm_cart_2_2_0_t* cart;
@ -65,12 +65,11 @@ int mca_topo_base_cart_create(mca_topo_base_module_t *topo,
assert(topo->type == OMPI_COMM_CART);
/* Calculate the number of processes in this grid */
p = dims;
for (i = 0; i < ndims; ++i, ++p) {
if(*p <= 0) {
for (i = 0; i < ndims; ++i) {
if(dims[i] <= 0) {
return OMPI_ERROR;
}
nprocs *= *p;
nprocs *= dims[i];
}
/* check for the error condition */

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

@ -9,6 +9,8 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -38,19 +40,19 @@
int mca_topo_base_cart_map(ompi_communicator_t* comm,
int ndims,
int *dims, int *periods, int *newrank)
const int *dims, const int *periods, int *newrank)
{
int nprocs, rank, size, i, *p;
int nprocs, rank, size, i;
/*
* Compute the # of processes in the grid.
*/
nprocs = 1;
for (i = 0, p = dims; i < ndims; ++i, ++p) {
if (*p <= 0) {
for (i = 0 ; i < ndims; ++i) {
if (dims[i] <= 0) {
return MPI_ERR_DIMS;
}
nprocs *= *p;
nprocs *= dims[i];
}
/*
* Check that number of processes <= size of communicator.

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

@ -11,6 +11,8 @@
* All rights reserved.
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -38,7 +40,7 @@
*/
int mca_topo_base_cart_rank(ompi_communicator_t* comm,
int *coords,
const int *coords,
int *rank)
{
int prank;
@ -47,7 +49,6 @@ int mca_topo_base_cart_rank(ompi_communicator_t* comm,
int factor;
int i;
int *d;
int *c;
/*
* Loop over coordinates computing the rank.
@ -57,11 +58,10 @@ int mca_topo_base_cart_rank(ompi_communicator_t* comm,
i = comm->c_topo->mtc.cart->ndims - 1;
d = comm->c_topo->mtc.cart->dims + i;
c = coords + i;
for (; i >= 0; --i, --c, --d) {
for (; i >= 0; --i, --d) {
dim = *d;
ord = *c;
ord = coords[i];
/* Per MPI-2.1 7.5.4 (description of MPI_CART_RANK), if the
dimension is periodic and the coordinate is outside of 0 <=
coord(i) < dim, then normalize it. If the dimension is not

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

@ -43,14 +43,14 @@
* @retval MPI_ERR_COMM
*/
int mca_topo_base_cart_sub (ompi_communicator_t* comm,
int *remain_dims,
const int *remain_dims,
ompi_communicator_t** new_comm)
{
struct ompi_communicator_t *temp_comm;
mca_topo_base_comm_cart_2_2_0_t *old_cart;
int errcode, colour, key, colfactor, keyfactor;
int ndim, dim, i;
int *d, *dorig = NULL, *dold, *c, *r, *p, *porig = NULL, *pold;
int *d, *dorig = NULL, *dold, *c, *p, *porig = NULL, *pold;
mca_topo_base_module_t* topo;
mca_topo_base_comm_cart_2_2_0_t* cart;
@ -67,11 +67,10 @@ int mca_topo_base_cart_sub (ompi_communicator_t* comm,
i = old_cart->ndims - 1;
d = old_cart->dims + i;
c = comm->c_topo->mtc.cart->coords + i;
r = remain_dims + i;
for (; i >= 0; --i, --d, --c, --r) {
for (; i >= 0; --i, --d, --c) {
dim = *d;
if (*r == 0) {
if (remain_dims[i] == 0) {
colour += colfactor * (*c);
colfactor *= dim;
} else {
@ -110,9 +109,8 @@ int mca_topo_base_cart_sub (ompi_communicator_t* comm,
/* Copy the periods */
porig = p = (int*)malloc(ndim * sizeof(int));
pold = old_cart->periods;
r = remain_dims;
for (i = 0; i < old_cart->ndims; ++i, ++dold, ++pold, ++r) {
if (*r) {
for (i = 0; i < old_cart->ndims; ++i, ++dold, ++pold) {
if (remain_dims[i]) {
*d++ = *dold;
*p++ = *pold;
}

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

@ -33,9 +33,9 @@ typedef struct _dist_graph_elem {
int mca_topo_base_dist_graph_distribute(mca_topo_base_module_t* module,
ompi_communicator_t *comm,
int n, int nodes[],
int degrees[], int targets[],
int weights[],
int n, const int nodes[],
const int degrees[], const int targets[],
const int weights[],
mca_topo_base_comm_dist_graph_2_2_0_t** ptopo)
{
int i, j, err, count, left_over, pending_reqs, current_pos, index, csize;
@ -280,9 +280,9 @@ int mca_topo_base_dist_graph_distribute(mca_topo_base_module_t* module,
int mca_topo_base_dist_graph_create(mca_topo_base_module_t* module,
ompi_communicator_t *comm_old,
int n, int nodes[],
int degrees[], int targets[],
int weights[],
int n, const int nodes[],
const int degrees[], const int targets[],
const int weights[],
ompi_info_t *info, int reorder,
ompi_communicator_t **newcomm)
{

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

@ -21,11 +21,11 @@
int mca_topo_base_dist_graph_create_adjacent(mca_topo_base_module_t* module,
ompi_communicator_t *comm_old,
int indegree, int sources[],
int sourceweights[],
int indegree, const int sources[],
const int sourceweights[],
int outdegree,
int destinations[],
int destweights[],
const int destinations[],
const int destweights[],
ompi_info_t *info, int reorder,
ompi_communicator_t **newcomm)
{

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

@ -43,8 +43,8 @@
int mca_topo_base_graph_create(mca_topo_base_module_t *topo,
ompi_communicator_t* old_comm,
int nnodes,
int *index,
int *edges,
const int *index,
const int *edges,
bool reorder,
ompi_communicator_t** comm_topo)
{

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

@ -10,6 +10,8 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -38,7 +40,7 @@
int mca_topo_base_graph_map(ompi_communicator_t * comm,
int nnodes,
int *index, int *edges, int *newrank)
const int *index, const int *edges, int *newrank)
{
int myrank;

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

@ -12,7 +12,7 @@
* All rights reserved.
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
@ -155,8 +155,8 @@ typedef int (*mca_topo_base_module_cart_create_fn_t)
(mca_topo_base_module_t *topo_module,
ompi_communicator_t* old_comm,
int ndims,
int *dims,
int *periods,
const int *dims,
const int *periods,
bool reorder,
ompi_communicator_t** comm_topo);
@ -177,14 +177,14 @@ typedef int (*mca_topo_base_module_cartdim_get_fn_t)
typedef int (*mca_topo_base_module_cart_map_fn_t)
(struct ompi_communicator_t *comm,
int ndims,
int *dims,
int *periods,
const int *dims,
const int *periods,
int *newrank);
/* Back end for MPI_CART_RANK */
typedef int (*mca_topo_base_module_cart_rank_fn_t)
(struct ompi_communicator_t *comm,
int *coords,
const int *coords,
int *rank);
/* Back end for MPI_CART_SHIFT */
@ -198,7 +198,7 @@ typedef int (*mca_topo_base_module_cart_shift_fn_t)
/* Back end for MPI_CART_SUB */
typedef int (*mca_topo_base_module_cart_sub_fn_t)
(struct ompi_communicator_t *comm,
int *remain_dims,
const int *remain_dims,
struct ompi_communicator_t ** new_comm);
/* Back end for MPI_GRAPH_CREATE */
@ -206,8 +206,8 @@ typedef int (*mca_topo_base_module_graph_create_fn_t)
(mca_topo_base_module_t *topo_module,
ompi_communicator_t* old_comm,
int nnodes,
int *index,
int *edges,
const int *index,
const int *edges,
bool reorder,
ompi_communicator_t** new_comm);
@ -223,8 +223,8 @@ typedef int (*mca_topo_base_module_graph_get_fn_t)
typedef int (*mca_topo_base_module_graph_map_fn_t)
(struct ompi_communicator_t *comm,
int nnodes,
int *index,
int *edges,
const int *index,
const int *edges,
int *newrank);
/* Back end for MPI_GRAPHDIMS_GET */
@ -250,8 +250,8 @@ typedef int (*mca_topo_base_module_graph_neighbors_count_fn_t)
typedef int (*mca_topo_base_module_dist_graph_create_fn_t)
(struct mca_topo_base_module_t* module,
struct ompi_communicator_t *old_comm,
int n, int nodes[],
int degrees[], int targets[], int weights[],
int n, const int nodes[],
const int degrees[], const int targets[], const int weights[],
struct ompi_info_t *info, int reorder,
struct ompi_communicator_t **new_comm);
@ -259,11 +259,11 @@ typedef int (*mca_topo_base_module_dist_graph_create_fn_t)
typedef int (*mca_topo_base_module_dist_graph_create_adjacent_fn_t)
(struct mca_topo_base_module_t* module,
ompi_communicator_t *comm_old,
int indegree, int sources[],
int sourceweights[],
int indegree, const int sources[],
const int sourceweights[],
int outdegree,
int destinations[],
int destweights[],
const int destinations[],
const int destweights[],
struct ompi_info_t *info, int reorder,
ompi_communicator_t **comm_dist_graph);

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

@ -4,6 +4,8 @@
* reserved.
* Copyright (c) 2011-2015 INRIA. All rights reserved.
* Copyright (c) 2011-2015 Bordeaux Polytechnic Institute
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -64,9 +66,9 @@ OBJ_CLASS_DECLARATION(mca_topo_treematch_module_t);
int mca_topo_treematch_dist_graph_create(mca_topo_base_module_t* module,
ompi_communicator_t *comm_old,
int n, int nodes[],
int degrees[], int targets[],
int weights[],
int n, const int nodes[],
const int degrees[], const int targets[],
const int weights[],
struct ompi_info_t *info, int reorder,
ompi_communicator_t **newcomm);
/*

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

@ -5,6 +5,8 @@
* Copyright (c) 2011-2015 INRIA. All rights reserved.
* Copyright (c) 2012-2015 Bordeaux Poytechnic Institute
* Copyright (c) 2015 Intel, Inc. All rights reserved
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -97,9 +99,9 @@ static int check_oversubscribing(int rank,
int mca_topo_treematch_dist_graph_create(mca_topo_base_module_t* topo_module,
ompi_communicator_t *comm_old,
int n, int nodes[],
int degrees[], int targets[],
int weights[],
int n, const int nodes[],
const int degrees[], const int targets[],
const int weights[],
struct ompi_info_t *info, int reorder,
ompi_communicator_t **newcomm)
{

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

@ -14,6 +14,8 @@
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -100,9 +102,8 @@ int MPI_Cart_create(MPI_Comm old_comm, int ndims, const int dims[],
}
/* Now let that topology module rearrange procs/ranks if it wants to */
/* XXX -- CONST -- do not cast away const -- update mca/topo */
err = topo->topo.cart.cart_create(topo, old_comm,
ndims, (int *) dims, (int *) periods,
ndims, dims, periods,
(0 == reorder) ? false : true, comm_cart);
OPAL_CR_EXIT_LIBRARY();

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

@ -14,6 +14,8 @@
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -75,9 +77,8 @@ int MPI_Cart_map(MPI_Comm comm, int ndims, const int dims[],
newrank = rank */
*newrank = ompi_comm_rank(comm);
} else {
/* XXX -- CONST -- do not cast away const -- update mca/topo */
err = comm->c_topo->topo.cart.cart_map(comm, ndims, (int *) dims,
(int *) periods, newrank);
err = comm->c_topo->topo.cart.cart_map(comm, ndims, dims,
periods, newrank);
}
OPAL_CR_EXIT_LIBRARY();

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

@ -14,7 +14,7 @@
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
@ -100,8 +100,7 @@ int MPI_Cart_rank(MPI_Comm comm, const int coords[], int *rank)
}
OPAL_CR_ENTER_LIBRARY();
/* XXX -- CONST -- do not cast away const -- update mca/topo */
err = comm->c_topo->topo.cart.cart_rank(comm, (int *) coords, rank);
err = comm->c_topo->topo.cart.cart_rank(comm, coords, rank);
OPAL_CR_EXIT_LIBRARY();
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);

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

@ -14,7 +14,7 @@
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
@ -75,8 +75,7 @@ int MPI_Cart_sub(MPI_Comm comm, const int remain_dims[], MPI_Comm *new_comm)
}
OPAL_CR_ENTER_LIBRARY();
/* XXX -- CONST -- do not cast away const -- update mca/topo */
err = comm->c_topo->topo.cart.cart_sub(comm, (int *) remain_dims, new_comm);
err = comm->c_topo->topo.cart.cart_sub(comm, remain_dims, new_comm);
OPAL_CR_EXIT_LIBRARY();
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);

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

@ -6,6 +6,8 @@
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
*
*/
@ -83,9 +85,8 @@ int MPI_Dist_graph_create(MPI_Comm comm_old, int n, const int sources[],
return OMPI_ERRHANDLER_INVOKE(comm_old, err, FUNC_NAME);
}
/* XXX -- CONST -- do not cast away const -- update mca/topo */
err = topo->topo.dist_graph.dist_graph_create(topo, comm_old, n, (int *) sources, (int *) degrees,
(int *) destinations, (int *) weights, info,
err = topo->topo.dist_graph.dist_graph_create(topo, comm_old, n, sources, degrees,
destinations, weights, info,
reorder, newcomm);
OMPI_ERRHANDLER_RETURN(err, comm_old, err, FUNC_NAME);
}

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

@ -10,6 +10,8 @@
* Copyright (c) 2013-2014 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
*
* Author(s): Torsten Hoefler
*
@ -94,10 +96,9 @@ int MPI_Dist_graph_create_adjacent(MPI_Comm comm_old,
return OMPI_ERRHANDLER_INVOKE(comm_old, err, FUNC_NAME);
}
/* XXX -- CONST -- do not cast away const -- update mca/topo */
err = topo->topo.dist_graph.dist_graph_create_adjacent(topo, comm_old, indegree,
(int *) sources, (int *) sourceweights, outdegree,
(int *) destinations, (int *) destweights, info,
sources, sourceweights, outdegree,
destinations, destweights, info,
reorder, comm_dist_graph);
OMPI_ERRHANDLER_RETURN(err, comm_old, err, FUNC_NAME);
}

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

@ -14,6 +14,8 @@
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -100,9 +102,8 @@ int MPI_Graph_create(MPI_Comm old_comm, int nnodes, const int indx[],
}
/* Now let that topology module rearrange procs/ranks if it wants to */
/* XXX -- CONST -- do not cast away const -- update mca/topo */
err = topo->topo.graph.graph_create(topo, old_comm,
nnodes, (int *) indx, (int *) edges,
nnodes, indx, edges,
(0 == reorder) ? false : true, comm_graph);
OPAL_CR_EXIT_LIBRARY();

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

@ -14,6 +14,8 @@
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -75,8 +77,7 @@ int MPI_Graph_map(MPI_Comm comm, int nnodes, const int indx[], const int edges[]
newrank = rank */
*newrank = ompi_comm_rank(comm);
} else {
/* XXX -- CONST -- do not cast away const -- update mca/topo */
err = comm->c_topo->topo.graph.graph_map(comm, nnodes, (int *) indx, (int *) edges, newrank);
err = comm->c_topo->topo.graph.graph_map(comm, nnodes, indx, edges, newrank);
}
OPAL_CR_EXIT_LIBRARY();