#include "simix/smx_private.h"
#include "surf/surf.h"
#include "simgrid/sg_config.h"
-
+#include "colls/colls.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_base, smpi, "Logging specific to SMPI (base)");
xbt_assert(ref, "Cannot match recv against null reference");
xbt_assert(req, "Cannot match recv against null request");
if((ref->src == MPI_ANY_SOURCE || req->src == ref->src)
- && (ref->tag == MPI_ANY_TAG || req->tag == ref->tag)){
+ && ((ref->tag == MPI_ANY_TAG && req->tag >=0) || req->tag == ref->tag)){
//we match, we can transfer some values
// FIXME : move this to the copy function ?
if(ref->src == MPI_ANY_SOURCE)ref->real_src = req->src;
if(req->detached==1){
ref->detached_sender=req; //tie the sender to the receiver, as it is detached and has to be freed in the receiver
}
+ XBT_DEBUG("match succeeded");
return 1;
}else return 0;
}
xbt_assert(req, "Cannot match send against null request");
if((req->src == MPI_ANY_SOURCE || req->src == ref->src)
- && (req->tag == MPI_ANY_TAG || req->tag == ref->tag))
+ && ((req->tag == MPI_ANY_TAG && ref->tag >=0)|| req->tag == ref->tag))
{
if(req->src == MPI_ANY_SOURCE)req->real_src = ref->src;
if(req->tag == MPI_ANY_TAG)req->real_tag = ref->tag;
if(ref->detached==1){
req->detached_sender=ref; //tie the sender to the receiver, as it is detached and has to be freed in the receiver
}
-
+ XBT_DEBUG("match succeeded");
return 1;
} else return 0;
}
{
MPI_Request requests[2];
MPI_Status stats[2];
-
+ int myid=smpi_process_index();
+ if ((smpi_group_index(smpi_comm_group(comm), dst) == myid) && (smpi_group_index(smpi_comm_group(comm), src) == myid)) {
+ smpi_datatype_copy(sendbuf, sendcount, sendtype,
+ recvbuf, recvcount, recvtype);
+ return;
+ }
requests[0] =
smpi_isend_init(sendbuf, sendcount, sendtype, dst, sendtag, comm);
requests[1] =
if (TRACE_smpi_view_internals()) {
if(req->flags & RECV){
int rank = smpi_process_index();
- int src_traced = smpi_group_index(smpi_comm_group(req->comm), req->src == MPI_ANY_SOURCE ? req->real_src : req->src);
+ int src_traced = (req->src == MPI_ANY_SOURCE ? req->real_src : req->src);
TRACE_smpi_recv(rank, src_traced, rank);
}
}
void *recvbuf, int recvcount, MPI_Datatype recvtype,
int root, MPI_Comm comm)
{
- int system_tag = 666;
+ int system_tag = COLL_TAG_GATHER;
int rank, size, src, index;
MPI_Aint lb = 0, recvext = 0;
MPI_Request *requests;
void *recvbuf, int *recvcounts, int *displs,
MPI_Datatype recvtype, int root, MPI_Comm comm)
{
- int system_tag = 666;
+ int system_tag = COLL_TAG_GATHERV;
int rank, size, src, index;
MPI_Aint lb = 0, recvext = 0;
MPI_Request *requests;
int recvcount, MPI_Datatype recvtype,
MPI_Comm comm)
{
- int system_tag = 666;
+ int system_tag = COLL_TAG_ALLGATHER;
int rank, size, other, index;
MPI_Aint lb = 0, recvext = 0;
MPI_Request *requests;
int *recvcounts, int *displs,
MPI_Datatype recvtype, MPI_Comm comm)
{
- int system_tag = 666;
+ int system_tag = COLL_TAG_ALLGATHERV;
int rank, size, other, index;
MPI_Aint lb = 0, recvext = 0;
MPI_Request *requests;
void *recvbuf, int recvcount, MPI_Datatype recvtype,
int root, MPI_Comm comm)
{
- int system_tag = 666;
+ int system_tag = COLL_TAG_SCATTER;
int rank, size, dst, index;
MPI_Aint lb = 0, sendext = 0;
MPI_Request *requests;
MPI_Datatype sendtype, void *recvbuf, int recvcount,
MPI_Datatype recvtype, int root, MPI_Comm comm)
{
- int system_tag = 666;
+ int system_tag = COLL_TAG_SCATTERV;
int rank, size, dst, index;
MPI_Aint lb = 0, sendext = 0;
MPI_Request *requests;
MPI_Datatype datatype, MPI_Op op, int root,
MPI_Comm comm)
{
- int system_tag = 666;
+ int system_tag = COLL_TAG_REDUCE;
int rank, size, src, index;
MPI_Aint lb = 0, dataext = 0;
MPI_Request *requests;
void **tmpbufs;
+ char* sendtmpbuf = (char*) sendbuf;
+ if( sendbuf == MPI_IN_PLACE ) {
+ sendtmpbuf = (char *)recvbuf;
+ }
+
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
+ //non commutative case, use a working algo from openmpi
+ if(!smpi_op_is_commute(op)){
+ smpi_coll_tuned_reduce_ompi_basic_linear(sendtmpbuf, recvbuf, count,
+ datatype, op, root, comm);
+ return;
+ }
+
if(rank != root) {
// Send buffer to root
- smpi_mpi_send(sendbuf, count, datatype, root, system_tag, comm);
+ smpi_mpi_send(sendtmpbuf, count, datatype, root, system_tag, comm);
} else {
// FIXME: check for errors
smpi_datatype_extent(datatype, &lb, &dataext);
// Local copy from root
- if (sendbuf && recvbuf)
- smpi_datatype_copy(sendbuf, count, datatype, recvbuf, count, datatype);
+ if (sendtmpbuf && recvbuf)
+ smpi_datatype_copy(sendtmpbuf, count, datatype, recvbuf, count, datatype);
// Receive buffers from senders
//TODO: make a MPI_barrier here ?
requests = xbt_new(MPI_Request, size - 1);
void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
- int system_tag = 666;
+ int system_tag = 888;
int rank, size, other, index;
MPI_Aint lb = 0, dataext = 0;
MPI_Request *requests;