-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2023. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include "../coll_tuned_topo.hpp"
#include "../colls_private.hpp"
#define MAXTREEFANOUT 32
-namespace simgrid{
-namespace smpi{
-
-int
-Coll_bcast_ompi_split_bintree::bcast ( void* buffer,
- int count,
- MPI_Datatype datatype,
- int root,
- MPI_Comm comm)
+namespace simgrid::smpi {
+
+int bcast__ompi_split_bintree( void* buffer,
+ int count,
+ MPI_Datatype datatype,
+ int root,
+ MPI_Comm comm)
{
unsigned int segsize ;
int rank, size;
int segindex, i, lr, pair;
int segcount[2]; /* Number ompi_request_wait_allof elements sent with each segment */
uint32_t counts[2];
- int num_segments[2]; /* Number of segmenets */
+ int num_segments[2]; /* Number of segments */
int sendcount[2]; /* the same like segcount, except for the last segment */
size_t realsegsize[2];
char *tmpbuf[2];
counts[0] = count/2;
if (count % 2 != 0) counts[0]++;
counts[1] = count - counts[0];
- if ( segsize > 0 ) {
- /* Note that ompi_datatype_type_size() will never return a negative
- value in typelng; it returns an int [vs. an unsigned type]
- because of the MPI spec. */
- if (segsize < ((uint32_t)type_size)) {
- segsize = type_size; /* push segsize up to hold one type */
- }
- segcount[0] = segcount[1] = segsize / type_size;
- num_segments[0] = counts[0]/segcount[0];
- if ((counts[0] % segcount[0]) != 0) num_segments[0]++;
- num_segments[1] = counts[1]/segcount[1];
- if ((counts[1] % segcount[1]) != 0) num_segments[1]++;
- } else {
- segcount[0] = counts[0];
- segcount[1] = counts[1];
- num_segments[0] = num_segments[1] = 1;
+
+ /* Note that ompi_datatype_type_size() will never return a negative
+ value in typelng; it returns an int [vs. an unsigned type]
+ because of the MPI spec. */
+ if (segsize < ((uint32_t)type_size)) {
+ segsize = type_size; /* push segsize up to hold one type */
}
+ segcount[0] = segcount[1] = segsize / type_size;
+ num_segments[0] = counts[0] / segcount[0];
+ if ((counts[0] % segcount[0]) != 0)
+ num_segments[0]++;
+ num_segments[1] = counts[1] / segcount[1];
+ if ((counts[1] % segcount[1]) != 0)
+ num_segments[1]++;
/* if the message is too small to be split into segments */
if( (counts[0] == 0 || counts[1] == 0) ||
(segsize > counts[0] * type_size) ||
(segsize > counts[1] * type_size) ) {
/* call linear version here ! */
- return (Coll_bcast_SMP_linear::bcast ( buffer, count, datatype,
- root, comm));
+ return bcast__SMP_linear( buffer, count, datatype, root, comm);
}
type_extent = datatype->get_extent();
Request::send(tmpbuf[lr], segcount[lr], datatype, tree->tree_next[i], COLL_TAG_BCAST, comm);
} /* end of for each child */
- /* upate the base request */
+ /* update the base request */
base_req = new_req;
/* go to the next buffer (ie. the one corresponding to the next recv) */
tmpbuf[lr] += realsegsize[lr];
}
-}
-}
-
+} // namespace simgrid::smpi