2 #include "colls_private.h"
4 * Linear functions are copied from the basic coll module. For
5 * some small number of nodes and/or small data sizes they are just as
6 * fast as tuned/tree based segmenting operations and as such may be
7 * selected by the decision functions. These are copied into this module
8 * due to the way we select modules in V1. i.e. in V2 we will handle this
9 * differently and so will not have to duplicate code.
10 * GEF Oct05 after asking Jeff.
13 smpi_coll_tuned_alltoallv_ompi_basic_linear(void *sbuf, int *scounts, int *sdisps,
15 void *rbuf, int *rcounts, int *rdisps,
24 size = smpi_comm_size(comm);
25 rank = smpi_comm_rank(comm);
26 MPI_Request *ireqs= xbt_malloc(sizeof(MPI_Request) * size * 2);
28 "coll:tuned:alltoallv_intra_basic_linear rank %d", rank);
30 sext=smpi_datatype_get_extent(sdtype);
31 rext=smpi_datatype_get_extent(rdtype);
33 /* Simple optimization - handle send to self first */
34 psnd = ((char *) sbuf) + (sdisps[rank] * sext);
35 prcv = ((char *) rbuf) + (rdisps[rank] * rext);
36 if (0 != scounts[rank]) {
37 smpi_datatype_copy(psnd, scounts[rank], sdtype,
38 prcv, rcounts[rank], rdtype);
41 /* If only one process, we're done. */
46 /* Now, initiate all send/recv to/from others. */
50 /* Post all receives first */
51 for (i = 0; i < size; ++i) {
52 if (i == rank || 0 == rcounts[i]) {
56 prcv = ((char *) rbuf) + (rdisps[i] * rext);
58 *preq = smpi_irecv_init(prcv, rcounts[i], rdtype,
59 i, COLL_TAG_ALLTOALLV, comm
66 /* Now post all sends */
67 for (i = 0; i < size; ++i) {
68 if (i == rank || 0 == scounts[i]) {
72 psnd = ((char *) sbuf) + (sdisps[i] * sext);
73 *preq=smpi_isend_init(psnd, scounts[i], sdtype,
74 i, COLL_TAG_ALLTOALLV, comm
80 /* Start your engines. This will never return an error. */
81 smpi_mpi_startall(nreqs, ireqs);
83 /* Wait for them all. If there's an error, note that we don't care
84 * what the error was -- just that there *was* an error. The PML
85 * will finish all requests, even if one or more of them fail.
86 * i.e., by the end of this call, all the requests are free-able.
87 * So free them anyway -- even if there was an error, and return the
88 * error after we free everything. */
89 smpi_mpi_waitall(nreqs, ireqs,
92 /* Free the requests. */
93 for (i = 0; i < nreqs; ++i) {
94 if(ireqs[i]!=MPI_REQUEST_NULL)smpi_mpi_request_free(&ireqs[i]);