X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/863aeead864a309c494893a1b06ec33ed2b7daf1..96cedde3cdbc0b8ffc3f096a1b65d021b0226f99:/src/smpi/colls/coll_tuned_topo.cpp diff --git a/src/smpi/colls/coll_tuned_topo.cpp b/src/smpi/colls/coll_tuned_topo.cpp index aa797a9884..c9527705db 100644 --- a/src/smpi/colls/coll_tuned_topo.cpp +++ b/src/smpi/colls/coll_tuned_topo.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. +/* Copyright (c) 2013-2019. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -19,8 +19,8 @@ * 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. */ @@ -52,7 +52,10 @@ static int calculate_num_nodes_up_to_level( int fanout, int level ) { /* 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 ? } /* @@ -98,7 +101,7 @@ ompi_coll_tuned_topo_build_tree( int fanout, 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; @@ -198,7 +201,7 @@ ompi_coll_tuned_topo_build_in_order_bintree( MPI_Comm comm ) 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; @@ -301,7 +304,7 @@ int ompi_coll_tuned_topo_destroy_tree( ompi_coll_tree_t** tree ) ptr = *tree; - free (ptr); + delete ptr; *tree = NULL; /* mark tree as gone */ return MPI_SUCCESS; @@ -342,7 +345,7 @@ ompi_coll_tuned_topo_build_bmtree( MPI_Comm comm, 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; @@ -421,7 +424,7 @@ ompi_coll_tree_t* ompi_coll_tuned_topo_build_in_order_bmtree(MPI_Comm comm, int 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; @@ -491,7 +494,7 @@ ompi_coll_tuned_topo_build_chain( int fanout, /* * 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);