-/* Copyright (c) 2013-2019. 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
* Descrp: Function realizes the alltoall operation using the bruck algorithm.
- * Auther: MPICH / modified by Ahmad Faraj
+ * Author: MPICH / modified by Ahmad Faraj
****************************************************************************/
#include "../colls_private.hpp"
-namespace simgrid{
-namespace smpi{
-
+namespace simgrid::smpi {
int
-Coll_alltoall_bruck::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)
+alltoall__bruck(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 status;
MPI_Aint extent;
MPI_Datatype new_type;
- int *blocks_length, *disps;
int i, src, dst, rank, num_procs, count, block, position;
int pack_size, tag = COLL_TAG_ALLTOALL, pof2 = 1;
-
- char *tmp_buff;
char *send_ptr = (char *) send_buff;
char *recv_ptr = (char *) recv_buff;
extent = recv_type->get_extent();
- tmp_buff = (char *) smpi_get_tmp_sendbuffer(num_procs * recv_count * extent);
- disps = (int *) xbt_malloc(sizeof(int) * num_procs);
- blocks_length = (int *) xbt_malloc(sizeof(int) * num_procs);
+ unsigned char* tmp_buff = smpi_get_tmp_sendbuffer(num_procs * recv_count * extent);
+ int* disps = new int[num_procs];
+ int* blocks_length = new int[num_procs];
Request::sendrecv(send_ptr + rank * send_count * extent,
(num_procs - rank) * send_count, send_type, rank, tag,
pof2 *= 2;
}
- free(disps);
- free(blocks_length);
+ delete[] disps;
+ delete[] blocks_length;
Request::sendrecv(recv_ptr + (rank + 1) * recv_count * extent,
(num_procs - rank - 1) * recv_count, send_type,
return MPI_SUCCESS;
}
-}
-}
+} // namespace simgrid::smpi