1 /* Copyright (c) 2013-2019. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "../colls_private.hpp"
9 int flattree_segment_in_byte = 8192;
13 Coll_bcast_flattree_pipeline::bcast(void *buff, int count,
14 MPI_Datatype data_type, int root,
17 int i, j, rank, num_procs;
18 int tag = COLL_TAG_BCAST;
21 extent = data_type->get_extent();
23 int segment = flattree_segment_in_byte / extent;
24 segment = segment == 0 ? 1 :segment;
25 int pipe_length = count / segment;
26 int increment = segment * extent;
28 XBT_WARN("MPI_bcast_flattree_pipeline use default MPI_bcast_flattree.");
29 return Coll_bcast_flattree::bcast(buff, count, data_type, root, comm);
32 num_procs = comm->size();
34 MPI_Request* request_array = new MPI_Request[pipe_length];
35 MPI_Status* status_array = new MPI_Status[pipe_length];
38 for (i = 0; i < pipe_length; i++) {
39 request_array[i] = Request::irecv((char *)buff + (i * increment), segment, data_type, root, tag, comm);
41 Request::waitall(pipe_length, request_array, status_array);
45 // Root sends data to all others
46 for (j = 0; j < num_procs; j++) {
50 for (i = 0; i < pipe_length; i++) {
51 Request::send((char *)buff + (i * increment), segment, data_type, j, tag, comm);
58 delete[] request_array;
59 delete[] status_array;