X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9335baa2b23f940577448a84168eb0b50d3dd966..d5cc61332edae35867a41bb38ad9401faaab2716:/src/smpi/colls/alltoall/alltoall-2dmesh.cpp?ds=sidebyside diff --git a/src/smpi/colls/alltoall/alltoall-2dmesh.cpp b/src/smpi/colls/alltoall/alltoall-2dmesh.cpp index 6b6c841c7d..41c2cef9d5 100644 --- a/src/smpi/colls/alltoall/alltoall-2dmesh.cpp +++ b/src/smpi/colls/alltoall/alltoall-2dmesh.cpp @@ -1,11 +1,11 @@ -/* 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 * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "../colls_private.h" -#include +#include "../colls_private.hpp" +#include /***************************************************************************** @@ -26,7 +26,7 @@ algorithm. It actually performs allgather operation in x dimension then in the y dimension. Each node then extracts the needed data. The communication in each dimension follows "simple." - + * Auther: Ahmad Faraj ****************************************************************************/ @@ -55,13 +55,12 @@ static int alltoall_check_is_2dmesh(int num, int *i, int *j) namespace simgrid{ namespace smpi{ -int Coll_alltoall_2dmesh::alltoall(void *send_buff, int send_count, +int Coll_alltoall_2dmesh::alltoall(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_Status *statuses, s; - MPI_Request *reqs, *req_ptr;; + MPI_Status s; MPI_Aint extent; char *tmp_buff1, *tmp_buff2; @@ -74,7 +73,7 @@ int Coll_alltoall_2dmesh::alltoall(void *send_buff, int send_count, num_procs = comm->size(); extent = send_type->get_extent(); - if (!alltoall_check_is_2dmesh(num_procs, &X, &Y)) + if (not alltoall_check_is_2dmesh(num_procs, &X, &Y)) return MPI_ERR_OTHER; my_row_base = (rank / Y) * Y; @@ -89,10 +88,9 @@ int Coll_alltoall_2dmesh::alltoall(void *send_buff, int send_count, if (Y > X) num_reqs = Y; - statuses = (MPI_Status *) xbt_malloc(num_reqs * sizeof(MPI_Status)); - reqs = (MPI_Request *) xbt_malloc(num_reqs * sizeof(MPI_Request)); - - req_ptr = reqs; + MPI_Status* statuses = new MPI_Status[num_reqs]; + MPI_Request* reqs = new MPI_Request[num_reqs]; + MPI_Request* req_ptr = reqs; count = send_count * num_procs; @@ -168,8 +166,8 @@ int Coll_alltoall_2dmesh::alltoall(void *send_buff, int send_count, Request::send(tmp_buff2, send_count * Y, send_type, dst, tag, comm); } Request::waitall(X - 1, reqs, statuses); - free(reqs); - free(statuses); + delete[] reqs; + delete[] statuses; smpi_free_tmp_buffer(tmp_buff1); smpi_free_tmp_buffer(tmp_buff2); return MPI_SUCCESS;