Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sanitize the OOP of kernel::profile
[simgrid.git] / src / smpi / colls / coll_tuned_topo.cpp
index 06a23b4..c952770 100644 (file)
@@ -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
@@ -52,10 +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) */
-  if(fanout > 1)  
-   return ((pown(fanout,level) - 1)/(fanout - 1));
-  else
-   return 0; // is this right ?
+    if (fanout > 1)
+      return ((pown(fanout, level) - 1) / (fanout - 1));
+    else
+      return 0; // is this right ?
 }
 
 /*
@@ -101,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;
@@ -201,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;
@@ -304,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;
@@ -345,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;
@@ -424,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;
@@ -494,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);