* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
int level; /* location of my rank in the tree structure of size */
int delta; /* number of nodes on my level */
int level; /* location of my rank in the tree structure of size */
int delta; /* number of nodes on my level */
- tree = (ompi_coll_tree_t*)malloc(sizeof(ompi_coll_tree_t));
- if (!tree) {
- XBT_DEBUG("coll:tuned:topo_build_tree PANIC::out of memory");
- return NULL;
+ tree = new ompi_coll_tree_t;
+ if (not tree) {
+ XBT_DEBUG("coll:tuned:topo_build_tree PANIC::out of memory");
+ return NULL;
* operations.
* Root of this tree is always rank (size-1) and fanout is 2.
* Here are some of the examples of this tree:
* operations.
* Root of this tree is always rank (size-1) and fanout is 2.
* Here are some of the examples of this tree:
- tree = (ompi_coll_tree_t*)malloc(sizeof(ompi_coll_tree_t));
- if (!tree) {
- XBT_DEBUG(
- "coll:tuned:topo_build_tree PANIC::out of memory");
- return NULL;
+ tree = new ompi_coll_tree_t;
+ if (not tree) {
+ XBT_DEBUG("coll:tuned:topo_build_tree PANIC::out of memory");
+ return NULL;
- a parent,
- belong to the left subtree, or
- belong to the right subtee
Each of the cases need to be handled differently.
*/
- a parent,
- belong to the left subtree, or
- belong to the right subtee
Each of the cases need to be handled differently.
*/
if (myrank > rchild) {
/* I belong to the left subtree:
- If I am the left child, compute real rank of my parent
if (myrank > rchild) {
/* I belong to the left subtree:
- If I am the left child, compute real rank of my parent
} else {
/* I belong to the right subtree:
- If I am the right child, compute real rank of my parent
} else {
/* I belong to the right subtree:
- If I am the right child, compute real rank of my parent
- - Iterate down through tree:
- compute new size and parent,
+ - Iterate down through tree:
+ compute new size and parent,
if (tree->tree_next[0] >= 0) { tree->tree_nextsize = 1; }
if (tree->tree_next[1] >= 0) { tree->tree_nextsize += 1; }
if (tree->tree_next[0] >= 0) { tree->tree_nextsize = 1; }
if (tree->tree_next[1] >= 0) { tree->tree_nextsize += 1; }
- bmtree = (ompi_coll_tree_t*)malloc(sizeof(ompi_coll_tree_t));
- if (!bmtree) {
- XBT_DEBUG("coll:tuned:topo:build_bmtree PANIC out of memory");
- return NULL;
+ bmtree = new ompi_coll_tree_t;
+ if (not bmtree) {
+ XBT_DEBUG("coll:tuned:topo:build_bmtree PANIC out of memory");
+ return NULL;
if( remote >= size ) remote -= size;
if (childs==MAXTREEFANOUT) {
XBT_DEBUG("coll:tuned:topo:build_bmtree max fanout incorrect %d needed %d", MAXTREEFANOUT, childs);
if( remote >= size ) remote -= size;
if (childs==MAXTREEFANOUT) {
XBT_DEBUG("coll:tuned:topo:build_bmtree max fanout incorrect %d needed %d", MAXTREEFANOUT, childs);
ompi_coll_tree_t *bmtree;
int i;
XBT_DEBUG("coll:tuned:topo:build_in_order_bmtree rt %d", root);
ompi_coll_tree_t *bmtree;
int i;
XBT_DEBUG("coll:tuned:topo:build_in_order_bmtree rt %d", root);
- bmtree = (ompi_coll_tree_t*)xbt_malloc(sizeof(ompi_coll_tree_t));
- if (!bmtree) {
- XBT_DEBUG("coll:tuned:topo:build_bmtree PANIC out of memory");
- return NULL;
+ bmtree = new ompi_coll_tree_t;
+ if (not bmtree) {
+ XBT_DEBUG("coll:tuned:topo:build_bmtree PANIC out of memory");
+ delete bmtree;
+ return NULL;
- remote = vrank ^ mask;
- if (remote < vrank) {
- bmtree->tree_prev = (remote + root) % size;
- break;
- } else if (remote < size) {
- bmtree->tree_next[childs] = (remote + root) % size;
- childs++;
- if (childs==MAXTREEFANOUT) {
- XBT_DEBUG(
- "coll:tuned:topo:build_bmtree max fanout incorrect %d needed %d",
- MAXTREEFANOUT, childs);
- return NULL;
- }
- }
- mask <<= 1;
+ int remote = vrank ^ mask;
+ if (remote < vrank) {
+ bmtree->tree_prev = (remote + root) % size;
+ break;
+ } else if (remote < size) {
+ bmtree->tree_next[childs] = (remote + root) % size;
+ childs++;
+ if (childs == MAXTREEFANOUT) {
+ XBT_DEBUG("coll:tuned:topo:build_bmtree max fanout incorrect %d needed %d", MAXTREEFANOUT, childs);
+ delete bmtree;
+ return NULL;
+ }
+ }
+ mask <<= 1;
- 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 = new ompi_coll_tree_t;
+ if (not 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;
}
chain->tree_root = MPI_UNDEFINED;
chain->tree_nextsize = -1;
for(i=0;i<fanout;i++) chain->tree_next[i] = -1;
if( srank-1 < (mark * maxchainlen) ) {
column = (srank-1)/maxchainlen;
head = 1+column*maxchainlen;
if( srank-1 < (mark * maxchainlen) ) {
column = (srank-1)/maxchainlen;
head = 1+column*maxchainlen;
XBT_DEBUG("coll:tuned:topo:topo_dump_tree %1d tree root %d"
" fanout %d BM %1d nextsize %d prev %d",
rank, tree->tree_root, tree->tree_bmtree, tree->tree_fanout,
tree->tree_nextsize, tree->tree_prev);
if( tree->tree_nextsize ) {
XBT_DEBUG("coll:tuned:topo:topo_dump_tree %1d tree root %d"
" fanout %d BM %1d nextsize %d prev %d",
rank, tree->tree_root, tree->tree_bmtree, tree->tree_fanout,
tree->tree_nextsize, tree->tree_prev);
if( tree->tree_nextsize ) {
- for( i = 0; i < tree->tree_nextsize; i++ )
- XBT_DEBUG("[%1d] %d", i, tree->tree_next[i]);
+ for (int i = 0; i < tree->tree_nextsize; i++)
+ XBT_DEBUG("[%1d] %d", i, tree->tree_next[i]);