-/* 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"
//#include <star-reduction.c>
+namespace simgrid{
+namespace smpi{
// this requires that count >= NP
-int Coll_allreduce_rab2::allreduce(void *sbuff, void *rbuff,
+int Coll_allreduce_rab2::allreduce(const void *sbuff, void *rbuff,
int count, MPI_Datatype dtype,
MPI_Op op, MPI_Comm comm)
{
MPI_Aint s_extent;
int i, rank, nprocs;
int nbytes, send_size, s_offset, r_offset;
- void *recv, *send, *tmp;
/*
#ifdef MPICH2_REDUCTION
MPI_User_function * uop = MPIR_Op_table[op % 16 - 1];
#else
MPI_User_function *uop;
- struct MPIR_OP *op_ptr;
+ MPIR_OP *op_ptr;
op_ptr = MPIR_ToPointer(op);
uop = op_ptr->op;
#endif
send_size = (count + nprocs) / nprocs;
nbytes = send_size * s_extent;
- send = (void *) smpi_get_tmp_sendbuffer(s_extent * send_size * nprocs);
- recv = (void *) smpi_get_tmp_recvbuffer(s_extent * send_size * nprocs);
- tmp = (void *) smpi_get_tmp_sendbuffer(nbytes);
+ void* send = smpi_get_tmp_sendbuffer(s_extent * send_size * nprocs);
+ void* recv = smpi_get_tmp_recvbuffer(s_extent * send_size * nprocs);
+ void* tmp = smpi_get_tmp_sendbuffer(nbytes);
memcpy(send, sbuff, s_extent * count);
smpi_free_tmp_buffer(tmp);
smpi_free_tmp_buffer(send);
} else {
- send = sbuff;
+ const void* send = sbuff;
send_size = count / nprocs;
nbytes = send_size * s_extent;
r_offset = rank * nbytes;
- recv = (void *) smpi_get_tmp_recvbuffer(s_extent * send_size * nprocs);
+ void* recv = smpi_get_tmp_recvbuffer(s_extent * send_size * nprocs);
Colls::alltoall(send, send_size, dtype, recv, send_size, dtype, comm);
return MPI_SUCCESS;
}
+}
+}