Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
added tesh tests for DVFS
[simgrid.git] / src / smpi / colls / bcast-flattree.c
1 #include "colls_private.h"
2
3 int
4 smpi_coll_tuned_bcast_flattree(void *buff, int count, MPI_Datatype data_type,
5                                int root, MPI_Comm comm)
6 {
7   MPI_Request *req_ptr;
8   MPI_Request *reqs;
9
10   int i, rank, num_procs;
11   int tag = 1;
12
13   rank = smpi_comm_rank(comm);
14   num_procs = smpi_comm_size(comm);
15
16   if (rank != root) {
17     smpi_mpi_recv(buff, count, data_type, root, tag, comm, MPI_STATUS_IGNORE);
18   }
19
20   else {
21     reqs = (MPI_Request *) xbt_malloc((num_procs - 1) * sizeof(MPI_Request));
22     req_ptr = reqs;
23
24     // Root sends data to all others
25     for (i = 0; i < num_procs; i++) {
26       if (i == rank)
27         continue;
28       *(req_ptr++) = smpi_mpi_isend(buff, count, data_type, i, tag, comm);
29     }
30
31     // wait on all requests
32     smpi_mpi_waitall(num_procs - 1, reqs, MPI_STATUSES_IGNORE);
33
34     free(reqs);
35   }
36   return MPI_SUCCESS;
37 }