+/* Copyright (c) 2013-2014. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
- * $COPYRIGHT$
*
* Additional copyrights may follow
- *
- * $HEADER$
*/
#include "colls_private.h"
#include "coll_tuned_topo.h"
-#define MCA_COLL_BASE_TAG_BARRIER 100
/*
* Barrier is ment to be a synchronous operation, as some BTLs can mark
* a request done before its passed to the NIC and progress might not be made
size = smpi_comm_size(comm);
XBT_DEBUG("ompi_coll_tuned_barrier_ompi_doublering rank %d", rank);
-
- left = ((rank-1)%size);
+
+ left = ((rank-1+size)%size);
right = ((rank+1)%size);
if (rank > 0) { /* receive message from the left */
smpi_mpi_recv((void*)NULL, 0, MPI_BYTE, left,
- MCA_COLL_BASE_TAG_BARRIER, comm,
+ COLL_TAG_BARRIER, comm,
MPI_STATUS_IGNORE);
}
/* Send message to the right */
smpi_mpi_send((void*)NULL, 0, MPI_BYTE, right,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm);
/* root needs to receive from the last node */
if (rank == 0) {
smpi_mpi_recv((void*)NULL, 0, MPI_BYTE, left,
- MCA_COLL_BASE_TAG_BARRIER, comm,
+ COLL_TAG_BARRIER, comm,
MPI_STATUS_IGNORE);
}
/* Allow nodes to exit */
if (rank > 0) { /* post Receive from left */
smpi_mpi_recv((void*)NULL, 0, MPI_BYTE, left,
- MCA_COLL_BASE_TAG_BARRIER, comm,
+ COLL_TAG_BARRIER, comm,
MPI_STATUS_IGNORE);
}
/* send message to the right one */
smpi_mpi_send((void*)NULL, 0, MPI_BYTE, right,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm);
/* rank 0 post receive from the last node */
if (rank == 0) {
smpi_mpi_recv((void*)NULL, 0, MPI_BYTE, left,
- MCA_COLL_BASE_TAG_BARRIER, comm,
+ COLL_TAG_BARRIER, comm,
MPI_STATUS_IGNORE);
}
/* send message to lower ranked node */
remote = rank - adjsize;
smpi_mpi_sendrecv(NULL, 0, MPI_BYTE, remote,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
NULL, 0, MPI_BYTE, remote,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm, MPI_STATUS_IGNORE);
} else if (rank < (size - adjsize)) {
/* receive message from high level rank */
smpi_mpi_recv((void*)NULL, 0, MPI_BYTE, rank+adjsize,
- MCA_COLL_BASE_TAG_BARRIER, comm,
+ COLL_TAG_BARRIER, comm,
MPI_STATUS_IGNORE);
}
/* post receive from the remote node */
smpi_mpi_sendrecv(NULL, 0, MPI_BYTE, remote,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
NULL, 0, MPI_BYTE, remote,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm, MPI_STATUS_IGNORE);
}
}
/* send enter message to higher ranked node */
remote = rank + adjsize;
smpi_mpi_send((void*)NULL, 0, MPI_BYTE, remote,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm);
}
/* send message to lower ranked node */
smpi_mpi_sendrecv(NULL, 0, MPI_BYTE, to,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
NULL, 0, MPI_BYTE, from,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm, MPI_STATUS_IGNORE);
}
remote = (remote + 1) & 0x1;
smpi_mpi_sendrecv(NULL, 0, MPI_BYTE, remote,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
NULL, 0, MPI_BYTE, remote,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm, MPI_STATUS_IGNORE);
return (MPI_SUCCESS);
}
if (rank > 0) {
smpi_mpi_send (NULL, 0, MPI_BYTE, 0,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm);
smpi_mpi_recv (NULL, 0, MPI_BYTE, 0,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm, MPI_STATUS_IGNORE);
}
requests = (MPI_Request*)malloc( size * sizeof(MPI_Request) );
for (i = 1; i < size; ++i) {
requests[i] = smpi_mpi_irecv(NULL, 0, MPI_BYTE, MPI_ANY_SOURCE,
- MCA_COLL_BASE_TAG_BARRIER, comm
+ COLL_TAG_BARRIER, comm
);
}
smpi_mpi_waitall( size-1, requests+1, MPI_STATUSES_IGNORE );
for (i = 1; i < size; ++i) {
requests[i] = smpi_mpi_isend(NULL, 0, MPI_BYTE, i,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm
);
}
if (!(partner & (jump-1)) && partner < size) {
if (partner > rank) {
smpi_mpi_recv (NULL, 0, MPI_BYTE, partner,
- MCA_COLL_BASE_TAG_BARRIER, comm,
+ COLL_TAG_BARRIER, comm,
MPI_STATUS_IGNORE);
} else if (partner < rank) {
smpi_mpi_send (NULL, 0, MPI_BYTE, partner,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm);
}
}
if (!(partner & (jump-1)) && partner < size) {
if (partner > rank) {
smpi_mpi_send (NULL, 0, MPI_BYTE, partner,
- MCA_COLL_BASE_TAG_BARRIER,
+ COLL_TAG_BARRIER,
comm);
} else if (partner < rank) {
smpi_mpi_recv (NULL, 0, MPI_BYTE, partner,
- MCA_COLL_BASE_TAG_BARRIER, comm,
+ COLL_TAG_BARRIER, comm,
MPI_STATUS_IGNORE);
}
}