-
-/*
-FIXME: buggy implementation
-
- int system_tag = 666;
- int rank, size, other, index, datasize;
- MPI_Request* requests;
- void** tmpbufs;
-
- rank = smpi_comm_rank(comm);
- size = smpi_comm_size(comm);
- datasize = smpi_datatype_size(datatype);
- // Local copy from self
- memcpy(recvbuf, sendbuf, count * datasize * sizeof(char));
- // Send/Recv buffers to/from others;
- //TODO: make a MPI_barrier here ?
- requests = xbt_new(MPI_Request, 2 * (size - 1));
- tmpbufs = xbt_new(void*, size - 1);
- index = 0;
- for(other = 0; other < size; other++) {
- if(other != rank) {
- tmpbufs[index / 2] = xbt_malloc(count * datasize);
- requests[index] = smpi_mpi_isend(sendbuf, count, datatype, other, system_tag, comm);
- requests[index + 1] = smpi_mpi_irecv(tmpbufs[index / 2], count, datatype, other, system_tag, comm);
- index += 2;
- }
- }
- // Wait for completion of all comms.
- for(other = 0; other < 2 * (size - 1); other++) {
- index = smpi_mpi_waitany(size - 1, requests, MPI_STATUS_IGNORE);
- if(index == MPI_UNDEFINED) {
- break;
- }
- if((index & 1) == 1) {
- // Request is odd: it's a irecv
- smpi_op_apply(op, tmpbufs[index / 2], recvbuf, &count, &datatype);
- }
- }
- for(index = 0; index < size - 1; index++) {
- xbt_free(tmpbufs[index]);
- }
- xbt_free(tmpbufs);
- xbt_free(requests);
-*/