MPI_User_function* func_;
bool is_commutative_;
bool is_fortran_op_ = false;
+ int refcount_ = 1;
public:
Op(MPI_User_function* function, bool commutative) : func_(function), is_commutative_(commutative) {}
void set_fortran_op() { is_fortran_op_ = true; }
void apply(void* invec, void* inoutvec, int* len, MPI_Datatype datatype);
static Op* f2c(int id);
+ void ref();
+ static void unref(MPI_Op* op);
};
}
public:
Request() = default;
- Request(void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags);
+ Request(void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags, MPI_Op op = MPI_REPLACE);
MPI_Comm comm() { return comm_; }
size_t size() { return size_; }
size_t real_size() { return real_size_; }
namespace simgrid{
namespace smpi{
-Request::Request(void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags)
- : buf_(buf), old_type_(datatype), src_(src), dst_(dst), tag_(tag), comm_(comm), flags_(flags)
+Request::Request(void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags, MPI_Op op)
+ : buf_(buf), old_type_(datatype), src_(src), dst_(dst), tag_(tag), comm_(comm), flags_(flags), op_(op)
{
void *old_buf = nullptr;
// FIXME Handle the case of a partial shared malloc.
size_ = datatype->size() * count;
datatype->ref();
comm_->ref();
+ if(op != MPI_REPLACE && op != MPI_OP_NULL)
+ op_->ref();
action_ = nullptr;
detached_ = 0;
detached_sender_ = nullptr;
refcount_ = 1;
else
refcount_ = 0;
- op_ = MPI_REPLACE;
cancelled_ = 0;
generalized_funcs=nullptr;
nbc_requests_=nullptr;
Comm::unref((*request)->comm_);
Datatype::unref((*request)->old_type_);
}
+ if ((*request)->op_!=MPI_REPLACE && (*request)->op_!=MPI_OP_NULL)
+ Op::unref(&(*request)->op_);
+
(*request)->print_request("Destroying");
delete *request;
*request = MPI_REQUEST_NULL;
request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, comm->group()->actor(src)->get_pid(),
comm->group()->actor(dst)->get_pid(), tag, comm,
MPI_REQ_RMA | MPI_REQ_NON_PERSISTENT | MPI_REQ_ISEND | MPI_REQ_SEND | MPI_REQ_PREPARED |
- MPI_REQ_ACCUMULATE);
- request->op_ = op;
+ MPI_REQ_ACCUMULATE, op);
}
return request;
}
}else{
request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, comm->group()->actor(src)->get_pid(),
comm->group()->actor(dst)->get_pid(), tag, comm,
- MPI_REQ_RMA | MPI_REQ_NON_PERSISTENT | MPI_REQ_RECV | MPI_REQ_PREPARED | MPI_REQ_ACCUMULATE);
- request->op_ = op;
+ MPI_REQ_RMA | MPI_REQ_NON_PERSISTENT | MPI_REQ_RECV | MPI_REQ_PREPARED | MPI_REQ_ACCUMULATE, op);
}
return request;
}