2006-08-04 18:41:31 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2006-08-24 20:38:08 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2006-08-04 18:41:31 +04:00
|
|
|
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
|
2007-02-09 23:17:37 +03:00
|
|
|
* Copyright (c) 2007 Los Alamos National Security, LLC. All rights
|
2015-06-24 06:59:57 +03:00
|
|
|
* reserved.
|
2006-08-04 18:41:31 +04:00
|
|
|
* $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2006-08-04 18:41:31 +04:00
|
|
|
* Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2006-08-04 18:41:31 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2007-05-01 08:49:36 +04:00
|
|
|
#include "ompi/constants.h"
|
2006-08-04 18:41:31 +04:00
|
|
|
#include "ompi/mca/pml/pml.h"
|
|
|
|
#include "ompi/communicator/communicator.h"
|
|
|
|
#include "ompi/request/request.h"
|
|
|
|
#include "ompi/runtime/mpiruntime.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2007-05-01 08:49:36 +04:00
|
|
|
int
|
|
|
|
ompi_init_preconnect_mpi(void)
|
2006-08-04 18:41:31 +04:00
|
|
|
{
|
|
|
|
int comm_size = ompi_comm_size(MPI_COMM_WORLD);
|
2007-05-01 08:49:36 +04:00
|
|
|
int comm_rank = ompi_comm_rank(MPI_COMM_WORLD);
|
2013-03-28 01:09:41 +04:00
|
|
|
int param, next, prev, i, ret = OMPI_SUCCESS;
|
2006-12-21 04:36:57 +03:00
|
|
|
struct ompi_request_t * requests[2];
|
2007-05-01 08:49:36 +04:00
|
|
|
char inbuf[1], outbuf[1];
|
2013-03-28 01:09:41 +04:00
|
|
|
const bool *value;
|
2007-05-01 08:49:36 +04:00
|
|
|
|
2013-03-28 01:09:41 +04:00
|
|
|
param = mca_base_var_find("ompi", "mpi", NULL, "preconnect_mpi");
|
2010-05-19 00:54:11 +04:00
|
|
|
if (0 > param) return OMPI_SUCCESS;
|
2013-03-28 01:09:41 +04:00
|
|
|
ret = mca_base_var_get_value(param, &value, NULL, NULL);
|
|
|
|
if (OMPI_SUCCESS != ret || 0 == value[0]) {
|
2008-11-05 22:41:16 +03:00
|
|
|
return OMPI_SUCCESS;
|
2006-08-04 18:41:31 +04:00
|
|
|
}
|
2007-05-01 08:49:36 +04:00
|
|
|
|
|
|
|
inbuf[0] = outbuf[0] = '\0';
|
|
|
|
|
|
|
|
/* Each iteration, every process sends to its neighbor i hops to
|
|
|
|
the right and receives from its neighbor i hops to the left.
|
|
|
|
Because send_complete is used, there will only ever be one
|
|
|
|
outstanding send and one outstanding receive in the network at
|
|
|
|
a time for any given process. This limits any "flooding"
|
|
|
|
effect that can occur with other connection algorithms. While
|
|
|
|
the flooding algorithms may be a more efficient use of
|
|
|
|
resources, they can overwhelm the out-of-band connection system
|
|
|
|
used to wire up some networks, leading to poor performance and
|
|
|
|
hangs. */
|
|
|
|
for (i = 1 ; i <= comm_size / 2 ; ++i) {
|
|
|
|
next = (comm_rank + i) % comm_size;
|
|
|
|
prev = (comm_rank - i + comm_size) % comm_size;
|
|
|
|
|
|
|
|
ret = MCA_PML_CALL(isend(outbuf, 1, MPI_CHAR,
|
|
|
|
next, 1,
|
|
|
|
MCA_PML_BASE_SEND_COMPLETE,
|
2015-06-24 06:59:57 +03:00
|
|
|
MPI_COMM_WORLD,
|
2007-05-01 08:49:36 +04:00
|
|
|
&requests[1]));
|
|
|
|
if (OMPI_SUCCESS != ret) return ret;
|
|
|
|
|
|
|
|
ret = MCA_PML_CALL(irecv(inbuf, 1, MPI_CHAR,
|
|
|
|
prev, 1,
|
2015-06-24 06:59:57 +03:00
|
|
|
MPI_COMM_WORLD,
|
2007-05-01 08:49:36 +04:00
|
|
|
&requests[0]));
|
|
|
|
if(OMPI_SUCCESS != ret) return ret;
|
|
|
|
|
|
|
|
ret = ompi_request_wait_all(2, requests, MPI_STATUSES_IGNORE);
|
|
|
|
if (OMPI_SUCCESS != ret) return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-04 18:41:31 +04:00
|
|
|
return ret;
|
|
|
|
}
|