1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2017 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
13 * Copyright (c) 2015 Research Organization for Information Science
14 * and Technology (RIST). All rights reserved.
15 * $COPYRIGHT$
16 *
17 * Additional copyrights may follow
18 *
19 * $HEADER$
20 */
21
22 #include "ompi_config.h"
23 #include "coll_basic.h"
24
25 #include "mpi.h"
26 #include "ompi/datatype/ompi_datatype.h"
27 #include "ompi/constants.h"
28 #include "ompi/mca/coll/coll.h"
29 #include "ompi/mca/coll/base/coll_tags.h"
30 #include "coll_basic.h"
31
32
33 /*
34 * allgatherv_inter
35 *
36 * Function: - allgatherv using other MPI collectives
37 * Accepts: - same as MPI_Allgatherv()
38 * Returns: - MPI_SUCCESS or error code
39 */
40 int
41 mca_coll_basic_allgatherv_inter(const void *sbuf, int scount,
42 struct ompi_datatype_t *sdtype,
43 void *rbuf, const int *rcounts, const int *disps,
44 struct ompi_datatype_t *rdtype,
45 struct ompi_communicator_t *comm,
46 mca_coll_base_module_t *module)
47 {
48 int rsize, err, i;
49 int *scounts, *sdisps;
50
51 rsize = ompi_comm_remote_size(comm);
52
53 scounts = (int *) malloc(2 * rsize * sizeof(int));
54 sdisps = scounts + rsize;
55 if (NULL == scounts) {
56 return OMPI_ERR_OUT_OF_RESOURCE;
57 }
58
59 for (i = 0; i < rsize; i++) {
60 scounts[i] = scount;
61 sdisps[i] = 0;
62 }
63
64 err = comm->c_coll->coll_alltoallv(sbuf, scounts, sdisps, sdtype,
65 rbuf, rcounts, disps, rdtype, comm,
66 comm->c_coll->coll_alltoallv_module);
67
68 if (NULL != scounts) {
69 free(scounts);
70 }
71
72 return err;
73 }