1 /* selector with default/naive Simgrid algorithms. These should not be trusted for performance evaluations */
3 /* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "colls_private.hpp"
9 #include "src/smpi/include/smpi_actor.hpp"
14 int Coll_bcast_default::bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
16 return Coll_bcast_binomial_tree::bcast(buf, count, datatype, root, comm);
19 int Coll_barrier_default::barrier(MPI_Comm comm)
21 return Coll_barrier_ompi_basic_linear::barrier(comm);
25 int Coll_gather_default::gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
26 void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
29 Colls::igather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, &request);
30 return Request::wait(&request, MPI_STATUS_IGNORE);
33 int Coll_reduce_scatter_default::reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, MPI_Datatype datatype, MPI_Op op,
36 int rank = comm->rank();
38 /* arbitrarily choose root as rank 0 */
39 int size = comm->size();
41 int *displs = xbt_new(int, size);
42 for (int i = 0; i < size; i++) {
44 count += recvcounts[i];
46 void *tmpbuf = static_cast<void*>(smpi_get_tmp_sendbuffer(count*datatype->get_extent()));
48 int ret = Coll_reduce_default::reduce(sendbuf, tmpbuf, count, datatype, op, 0, comm);
50 ret = Colls::scatterv(tmpbuf, recvcounts, displs, datatype, recvbuf, recvcounts[rank], datatype, 0, comm);
52 smpi_free_tmp_buffer(tmpbuf);
57 int Coll_allgather_default::allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
58 void *recvbuf,int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
61 Colls::iallgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, &request);
62 return Request::wait(&request, MPI_STATUS_IGNORE);
65 int Coll_allgatherv_default::allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf,
66 int *recvcounts, int *displs, MPI_Datatype recvtype, MPI_Comm comm)
69 Colls::iallgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm, &request);
70 MPI_Request* requests = request->get_nbc_requests();
71 int count = request->get_nbc_requests_size();
72 Request::waitall(count, requests, MPI_STATUS_IGNORE);
73 for (int other = 0; other < count; other++) {
74 Request::unref(&requests[other]);
77 Request::unref(&request);
81 int Coll_scatter_default::scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
82 void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
85 Colls::iscatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, &request);
86 return Request::wait(&request, MPI_STATUS_IGNORE);
89 int Coll_reduce_default::reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root,
92 //non commutative case, use a working algo from openmpi
93 if (op != MPI_OP_NULL && not op->is_commutative()) {
94 return Coll_reduce_ompi_basic_linear::reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
97 Colls::ireduce(sendbuf, recvbuf, count, datatype, op, root, comm, &request);
98 return Request::wait(&request, MPI_STATUS_IGNORE);
101 int Coll_allreduce_default::allreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
104 ret = Coll_reduce_default::reduce(sendbuf, recvbuf, count, datatype, op, 0, comm);
106 ret = Coll_bcast_default::bcast(recvbuf, count, datatype, 0, comm);
110 int Coll_alltoall_default::alltoall( void *sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount, MPI_Datatype rdtype, MPI_Comm comm)
112 return Coll_alltoall_ompi::alltoall(sbuf, scount, sdtype, rbuf, rcount, rdtype, comm);
115 int Coll_alltoallv_default::alltoallv(void *sendbuf, int *sendcounts, int *senddisps, MPI_Datatype sendtype,
116 void *recvbuf, int *recvcounts, int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
119 Colls::ialltoallv(sendbuf, sendcounts, senddisps, sendtype, recvbuf, recvcounts, recvdisps, recvtype, comm, &request);
120 return Request::wait(&request, MPI_STATUS_IGNORE);