-/* 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
*
*/
-#include "../colls_private.h"
+#include "../colls_private.hpp"
+#include <algorithm>
-int Coll_allreduce_mvapich2_rs::allreduce(void *sendbuf,
+namespace simgrid{
+namespace smpi{
+int Coll_allreduce_mvapich2_rs::allreduce(const void *sendbuf,
void *recvbuf,
int count,
MPI_Datatype datatype,
int mpi_errno = MPI_SUCCESS;
int newrank = 0;
int mask, pof2, i, send_idx, recv_idx, last_idx, send_cnt;
- int dst, is_commutative, rem, newdst,
- recv_cnt, *cnts, *disps;
+ int dst, is_commutative, rem, newdst, recv_cnt;
MPI_Aint true_lb, true_extent, extent;
void *tmp_buf, *tmp_buf_free;
datatype->extent(&true_lb, &true_extent);
extent = datatype->get_extent();
- tmp_buf_free= smpi_get_tmp_recvbuffer(count * (MAX(extent, true_extent)));
+ tmp_buf_free = smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent));
/* adjust for potential negative lower bound in datatype */
tmp_buf = (void *) ((char *) tmp_buf_free - true_lb);
/* for the reduce-scatter, calculate the count that
each process receives and the displacement within
the buffer */
- cnts = (int *)xbt_malloc(pof2 * sizeof (int));
- disps = (int *)xbt_malloc(pof2 * sizeof (int));
+ int* cnts = new int[pof2];
+ int* disps = new int[pof2];
for (i = 0; i < (pof2 - 1); i++) {
cnts[i] = count / pof2;
mask >>= 1;
}
- xbt_free(disps);
- xbt_free(cnts);
+ delete[] disps;
+ delete[] cnts;
}
}
return (mpi_errno);
}
+
+}
+}