X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/19b3962253112b19308537bc2400de141c119d99..HEAD:/src/smpi/colls/allgather/allgather-spreading-simple.cpp diff --git a/src/smpi/colls/allgather/allgather-spreading-simple.cpp b/src/smpi/colls/allgather/allgather-spreading-simple.cpp index fb7f12fb79..d5c59b03bb 100644 --- a/src/smpi/colls/allgather/allgather-spreading-simple.cpp +++ b/src/smpi/colls/allgather/allgather-spreading-simple.cpp @@ -1,10 +1,10 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. +/* Copyright (c) 2013-2023. 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" /***************************************************************************** @@ -64,21 +64,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * order of communications for node i is i -> i + 1, i -> i + 2, ..., * i -> (i + p -1) % P. * - * Auther: Ahmad Faraj + * Author: Ahmad Faraj ****************************************************************************/ -namespace simgrid{ -namespace smpi{ - +namespace simgrid::smpi { int -Coll_allgather_spreading_simple::allgather(void *send_buff, int send_count, - MPI_Datatype send_type, - void *recv_buff, int recv_count, - MPI_Datatype recv_type, - MPI_Comm comm) +allgather__spreading_simple(const void *send_buff, int send_count, + MPI_Datatype send_type, + void *recv_buff, int recv_count, + MPI_Datatype recv_type, + MPI_Comm comm) { - MPI_Request *reqs, *req_ptr; MPI_Aint extent; int i, src, dst, rank, num_procs, num_reqs; int tag = COLL_TAG_ALLGATHER; @@ -90,14 +87,8 @@ Coll_allgather_spreading_simple::allgather(void *send_buff, int send_count, extent = send_type->get_extent(); num_reqs = (2 * num_procs) - 2; - reqs = (MPI_Request *) xbt_malloc(num_reqs * sizeof(MPI_Request)); - if (!reqs) { - printf("allgather-spreading-simple.c:40: cannot allocate memory\n"); - MPI_Finalize(); - exit(0); - } - - req_ptr = reqs; + auto* reqs = new MPI_Request[num_reqs]; + MPI_Request* req_ptr = reqs; Request::sendrecv(send_buff, send_count, send_type, rank, tag, (char *) recv_buff + rank * recv_count * extent, recv_count, recv_type, rank, tag, comm, &status); @@ -118,10 +109,9 @@ Coll_allgather_spreading_simple::allgather(void *send_buff, int send_count, } Request::waitall(num_reqs, reqs, MPI_STATUSES_IGNORE); - free(reqs); + delete[] reqs; return MPI_SUCCESS; } -} -} +} // namespace simgrid::smpi