- #include "colls_private.h"
-
-
-#define MAXTREEFANOUT 32
-
-#define COLL_TUNED_COMPUTED_SEGCOUNT(SEGSIZE, TYPELNG, SEGCOUNT) \
- if( ((SEGSIZE) >= (TYPELNG)) && \
- ((SEGSIZE) < ((TYPELNG) * (SEGCOUNT))) ) { \
- size_t residual; \
- (SEGCOUNT) = (int)((SEGSIZE) / (TYPELNG)); \
- residual = (SEGSIZE) - (SEGCOUNT) * (TYPELNG); \
- if( residual > ((TYPELNG) >> 1) ) \
- (SEGCOUNT)++; \
- } \
-
- typedef struct ompi_coll_tree_t {
- int32_t tree_root;
- int32_t tree_fanout;
- int32_t tree_bmtree;
- int32_t tree_prev;
- int32_t tree_next[MAXTREEFANOUT];
- int32_t tree_nextsize;
- } ompi_coll_tree_t;
-
- ompi_coll_tree_t*
- ompi_coll_tuned_topo_build_chain( int fanout,
- MPI_Comm com,
- int root );
-
-ompi_coll_tree_t*
-ompi_coll_tuned_topo_build_chain( int fanout,
- MPI_Comm comm,
- int root )
-{
- int rank, size;
- int srank; /* shifted rank */
- int i,maxchainlen;
- int mark,head,len;
- ompi_coll_tree_t *chain;
-
- XBT_DEBUG("coll:tuned:topo:build_chain fo %d rt %d", fanout, root);
-
- /*
- * Get size and rank of the process in this communicator
- */
- size = smpi_comm_size(comm);
- rank = smpi_comm_rank(comm);
-
- if( fanout < 1 ) {
- XBT_DEBUG("coll:tuned:topo:build_chain WARNING invalid fanout of ZERO, forcing to 1 (pipeline)!");
- fanout = 1;
- }
- if (fanout>MAXTREEFANOUT) {
- XBT_DEBUG("coll:tuned:topo:build_chain WARNING invalid fanout %d bigger than max %d, forcing to max!", fanout, MAXTREEFANOUT);
- fanout = MAXTREEFANOUT;
- }
-
- /*
- * Allocate space for topology arrays if needed
- */
- chain = (ompi_coll_tree_t*)malloc( sizeof(ompi_coll_tree_t) );
- if (!chain) {
- XBT_DEBUG("coll:tuned:topo:build_chain PANIC out of memory");
- fflush(stdout);
- return NULL;
- }
- chain->tree_root = MPI_UNDEFINED;
- chain->tree_nextsize = -1;
- for(i=0;i<fanout;i++) chain->tree_next[i] = -1;
-
- /*
- * Set root & numchain
- */
- chain->tree_root = root;
- if( (size - 1) < fanout ) {
- chain->tree_nextsize = size-1;
- fanout = size-1;
- } else {
- chain->tree_nextsize = fanout;
- }
-
- /*
- * Shift ranks
- */
- srank = rank - root;
- if (srank < 0) srank += size;