if (is_commutative || (src < rank)) {
if (sendbuf != MPI_IN_PLACE) {
if (op != MPI_OP_NULL)
- op->apply(tmp_recvbuf, recvbuf, &((const_cast<int*>(recvcounts))[rank]), datatype);
+ op->apply(tmp_recvbuf, recvbuf, &recvcounts[rank], datatype);
}
else {
if (op != MPI_OP_NULL)
- op->apply(tmp_recvbuf, ((char*)recvbuf + disps[rank] * extent), &((const_cast<int*>(recvcounts))[rank]), datatype);
+ op->apply(tmp_recvbuf, ((char*)recvbuf + disps[rank] * extent), &recvcounts[rank], datatype);
/* we can't store the result at the beginning of
recvbuf right here because there is useful data
there that other process/processes need. at the
else {
if (sendbuf != MPI_IN_PLACE) {
if (op != MPI_OP_NULL)
- op->apply(recvbuf, tmp_recvbuf, &((const_cast<int*>(recvcounts))[rank]), datatype);
+ op->apply(recvbuf, tmp_recvbuf, &recvcounts[rank], datatype);
/* copy result back into recvbuf */
mpi_errno =
Datatype::copy(tmp_recvbuf, recvcounts[rank], datatype, recvbuf, recvcounts[rank], datatype);
}
else {
if (op != MPI_OP_NULL)
- op->apply(((char*)recvbuf + disps[rank] * extent), tmp_recvbuf, &((const_cast<int*>(recvcounts))[rank]), datatype);
+ op->apply(((char*)recvbuf + disps[rank] * extent), tmp_recvbuf, &recvcounts[rank], datatype);
/* copy result back into recvbuf */
mpi_errno = Datatype::copy(tmp_recvbuf, recvcounts[rank], datatype,
((char*)recvbuf + disps[rank] * extent), recvcounts[rank], datatype);
rbuf[prevblock] = inbuf[inbi ^ 0x1] (op) rbuf[prevblock]
*/
tmprecv = accumbuf + (ptrdiff_t)displs[prevblock] * extent;
- if(op!=MPI_OP_NULL) op->apply( inbuf[inbi ^ 0x1], tmprecv, &((const_cast<int*>(rcounts))[prevblock]), dtype);
+ if (op != MPI_OP_NULL)
+ op->apply(inbuf[inbi ^ 0x1], tmprecv, &rcounts[prevblock], dtype);
/* send previous block to send_to */
Request::send(tmprecv, rcounts[prevblock], dtype, send_to,
/* Apply operation on the last block (my block)
rbuf[rank] = inbuf[inbi] (op) rbuf[rank] */
tmprecv = accumbuf + (ptrdiff_t)displs[rank] * extent;
- if(op!=MPI_OP_NULL) op->apply( inbuf[inbi], tmprecv, &((const_cast<int*>(rcounts))[rank]), dtype);
+ if (op != MPI_OP_NULL)
+ op->apply(inbuf[inbi], tmprecv, &rcounts[rank], dtype);
/* Copy result from tmprecv to rbuf */
ret = Datatype::copy(tmprecv, rcounts[rank], dtype, (char*)rbuf, rcounts[rank], dtype);
bool is_fortran_op() { return is_fortran_op_; }
// tell that we were created from fortran, so we need to translate the type to fortran when called
void set_fortran_op() { is_fortran_op_ = true; }
- void apply(const void* invec, void* inoutvec, int* len, MPI_Datatype datatype);
+ void apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype);
static Op* f2c(int id);
void ref();
static void unref(MPI_Op* op);
namespace simgrid{
namespace smpi{
-void Op::apply(const void *invec, void *inoutvec, int *len, MPI_Datatype datatype)
+void Op::apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype)
{
if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
// we need to switch as the called function may silently touch global variables
if (not smpi_process()->replaying() && *len > 0) {
if (not is_fortran_op_)
- this->func_(const_cast<void*>(invec), inoutvec, len, &datatype);
+ this->func_(const_cast<void*>(invec), inoutvec, const_cast<int*>(len), &datatype);
else{
XBT_DEBUG("Applying operation of length %d from %p and from/to %p", *len, invec, inoutvec);
int tmp = datatype->c2f();
/* Unfortunately, the C and Fortran version of the MPI standard do not agree on the type here,
thus the reinterpret_cast. */
- this->func_(const_cast<void*>(invec), inoutvec, len, reinterpret_cast<MPI_Datatype*>(&tmp) );
+ this->func_(const_cast<void*>(invec), inoutvec, const_cast<int*>(len), reinterpret_cast<MPI_Datatype*>(&tmp));
}
}
}