X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b7ed19dfcc221d7b3eca182abb5c4a3946671172..d5cc61332edae35867a41bb38ad9401faaab2716:/src/smpi/colls/reduce/reduce-scatter-gather.cpp?ds=sidebyside diff --git a/src/smpi/colls/reduce/reduce-scatter-gather.cpp b/src/smpi/colls/reduce/reduce-scatter-gather.cpp index b8ac14235c..07eb4bdd30 100644 --- a/src/smpi/colls/reduce/reduce-scatter-gather.cpp +++ b/src/smpi/colls/reduce/reduce-scatter-gather.cpp @@ -1,17 +1,18 @@ -/* Copyright (c) 2013-2014. 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 * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "../colls_private.h" +#include "../colls_private.hpp" /* reduce Author: MPICH */ - -int Coll_reduce_scatter_gather::reduce(void *sendbuf, void *recvbuf, +namespace simgrid{ +namespace smpi{ +int Coll_reduce_scatter_gather::reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) { @@ -33,13 +34,13 @@ int Coll_reduce_scatter_gather::reduce(void *sendbuf, void *recvbuf, return 0; rank = comm->rank(); comm_size = comm->size(); - + extent = datatype->get_extent(); /* If I'm not the root, then my recvbuf may not be valid, therefore I have to allocate a temporary one */ - if (rank != root && !recvbuf) { + if (rank != root && not recvbuf) { temporary_buffer=1; recvbuf = (void *)smpi_get_tmp_recvbuffer(count * extent); } @@ -74,8 +75,8 @@ int Coll_reduce_scatter_gather::reduce(void *sendbuf, void *recvbuf, } else /* rank >= 2*rem */ newrank = rank - rem; - cnts = (int *) xbt_malloc(pof2 * sizeof(int)); - disps = (int *) xbt_malloc(pof2 * sizeof(int)); + cnts = new int[pof2]; + disps = new int[pof2]; if (newrank != -1) { for (i = 0; i < (pof2 - 1); i++) @@ -251,8 +252,8 @@ int Coll_reduce_scatter_gather::reduce(void *sendbuf, void *recvbuf, } else /* rank >= 2*rem */ newrank = rank - rem; - cnts = (int *) xbt_malloc(pof2 * sizeof(int)); - disps = (int *) xbt_malloc(pof2 * sizeof(int)); + cnts = new int[pof2]; + disps = new int[pof2]; if (newrank != -1) { for (i = 0; i < (pof2 - 1); i++) @@ -403,10 +404,10 @@ int Coll_reduce_scatter_gather::reduce(void *sendbuf, void *recvbuf, if (tmp_buf) smpi_free_tmp_buffer(tmp_buf); if(temporary_buffer==1) smpi_free_tmp_buffer(recvbuf); - if (cnts) - free(cnts); - if (disps) - free(disps); + delete[] cnts; + delete[] disps; return 0; } +} +}