-/* Copyright (c) 2013-2017. The SimGrid Team.
+/* Copyright (c) 2013-2018. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* Additional copyrights may follow
*/
-#include "colls_private.h"
-#include "coll_tuned_topo.h"
+#include "coll_tuned_topo.hpp"
+#include "colls_private.hpp"
/*
* Some static helpers.
*/
{
/* just use geometric progression formula for sum:
a^0+a^1+...a^(n-1) = (a^n-1)/(a-1) */
- return ((pown(fanout,level) - 1)/(fanout - 1));
+ if (fanout > 1)
+ return ((pown(fanout, level) - 1) / (fanout - 1));
+ else
+ return 0; // is this right ?
}
/*
size = comm->size();
rank = comm->rank();
- tree = (ompi_coll_tree_t*)malloc(sizeof(ompi_coll_tree_t));
+ tree = new ompi_coll_tree_t;
if (not tree) {
XBT_DEBUG("coll:tuned:topo_build_tree PANIC::out of memory");
return NULL;
size = comm->size();
rank = comm->rank();
- tree = (ompi_coll_tree_t*)malloc(sizeof(ompi_coll_tree_t));
+ tree = new ompi_coll_tree_t;
if (not tree) {
XBT_DEBUG("coll:tuned:topo_build_tree PANIC::out of memory");
return NULL;
ptr = *tree;
- free (ptr);
+ delete ptr;
*tree = NULL; /* mark tree as gone */
return MPI_SUCCESS;
index = rank -root;
- bmtree = (ompi_coll_tree_t*)malloc(sizeof(ompi_coll_tree_t));
+ bmtree = new ompi_coll_tree_t;
if (not bmtree) {
XBT_DEBUG("coll:tuned:topo:build_bmtree PANIC out of memory");
return NULL;
vrank = (rank - root + size) % size;
- bmtree = (ompi_coll_tree_t*)xbt_malloc(sizeof(ompi_coll_tree_t));
+ bmtree = new ompi_coll_tree_t;
if (not bmtree) {
XBT_DEBUG("coll:tuned:topo:build_bmtree PANIC out of memory");
return NULL;
/*
* Allocate space for topology arrays if needed
*/
- chain = (ompi_coll_tree_t*)malloc( sizeof(ompi_coll_tree_t) );
+ chain = new ompi_coll_tree_t;
if (not chain) {
XBT_DEBUG("coll:tuned:topo:build_chain PANIC out of memory");
fflush(stdout);