-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2021. 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. */
CHECK_COUNT(2, count)\
CHECK_TYPE(3, datatype)\
CHECK_PROC(4, dst)\
+ CHECK_RANK(4, dst, comm)\
CHECK_TAG(5, tag)\
CHECK_COMM(6)\
CHECK_COUNT(2, count)\
CHECK_TYPE(3, datatype)\
CHECK_PROC(4, src)\
+ if(src!=MPI_ANY_SOURCE)\
+ CHECK_RANK(4, src, comm)\
CHECK_TAG(5, tag)\
CHECK_COMM(6)
/* PMPI User level calls */
TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Startall"));
if (not TRACE_smpi_view_internals())
for (int i = 0; i < count; i++) {
- MPI_Request req = requests[i];
+ const simgrid::smpi::Request* req = requests[i];
if (req->flags() & MPI_REQ_SEND)
TRACE_smpi_send(my_proc_id, my_proc_id, getPid(req->comm(), req->dst()), req->tag(), req->size());
}
if (not TRACE_smpi_view_internals())
for (int i = 0; i < count; i++) {
- MPI_Request req = requests[i];
+ const simgrid::smpi::Request* req = requests[i];
if (req->flags() & MPI_REQ_RECV)
TRACE_smpi_recv(getPid(req->comm(), req->src()), my_proc_id, req->tag());
}
CHECK_IRECV_INPUTS
smpi_bench_end();
- int retval = 0;
- if (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0)){
- retval = MPI_ERR_RANK;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
-
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("irecv", src,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
-
- *request = simgrid::smpi::Request::irecv(buf, count, datatype, src, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
- }
-
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("irecv", src,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ *request = simgrid::smpi::Request::irecv(buf, count, datatype, src, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
smpi_bench_end();
int retval = 0;
- if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int trace_dst = getPid(comm, dst);
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("isend", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
-
- TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
-
- *request = simgrid::smpi::Request::isend(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
- }
-
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int trace_dst = getPid(comm, dst);
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("isend", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
+ *request = simgrid::smpi::Request::isend(buf, count, datatype, dst, tag, comm);
+ retval = MPI_SUCCESS;
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
CHECK_ISEND_INPUTS
smpi_bench_end();
- int retval = 0;
- if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int trace_dst = getPid(comm, dst);
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("ISsend", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
- TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
-
- *request = simgrid::smpi::Request::issend(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
- }
-
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int trace_dst = getPid(comm, dst);
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("ISsend", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
+ *request = simgrid::smpi::Request::issend(buf, count, datatype, dst, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status)
CHECK_SEND_INPUTS
smpi_bench_end();
- int retval = 0;
- if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int dst_traced = getPid(comm, dst);
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("send", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
- if (not TRACE_smpi_view_internals()) {
- TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
- }
-
- simgrid::smpi::Request::send(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int dst_traced = getPid(comm, dst);
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("send", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ if (not TRACE_smpi_view_internals()) {
+ TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
}
-
+ simgrid::smpi::Request::send(buf, count, datatype, dst, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Rsend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
CHECK_SEND_INPUTS
smpi_bench_end();
- int retval = 0;
- if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int dst_traced = getPid(comm, dst);
- int bsend_buf_size = 0;
- void* bsend_buf = nullptr;
- smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
- int size = datatype->get_extent() * count;
- if(bsend_buf==nullptr || bsend_buf_size < size + MPI_BSEND_OVERHEAD )
- return MPI_ERR_BUFFER;
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("bsend", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
- if (not TRACE_smpi_view_internals()) {
- TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
- }
-
- simgrid::smpi::Request::bsend(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int dst_traced = getPid(comm, dst);
+ int bsend_buf_size = 0;
+ void* bsend_buf = nullptr;
+ smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
+ int size = datatype->get_extent() * count;
+ if(bsend_buf==nullptr || bsend_buf_size < size + MPI_BSEND_OVERHEAD )
+ return MPI_ERR_BUFFER;
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("bsend", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ if (not TRACE_smpi_view_internals()) {
+ TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
}
-
+ simgrid::smpi::Request::bsend(buf, count, datatype, dst, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Ibsend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request)
CHECK_ISEND_INPUTS
smpi_bench_end();
- int retval = 0;
- if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int trace_dst = getPid(comm, dst);
- int bsend_buf_size = 0;
- void* bsend_buf = nullptr;
- smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
- int size = datatype->get_extent() * count;
- if(bsend_buf==nullptr || bsend_buf_size < size + MPI_BSEND_OVERHEAD )
- return MPI_ERR_BUFFER;
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("ibsend", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
-
- TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
-
- *request = simgrid::smpi::Request::ibsend(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
- }
-
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int trace_dst = getPid(comm, dst);
+ int bsend_buf_size = 0;
+ void* bsend_buf = nullptr;
+ smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
+ int size = datatype->get_extent() * count;
+ if(bsend_buf==nullptr || bsend_buf_size < size + MPI_BSEND_OVERHEAD )
+ return MPI_ERR_BUFFER;
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("ibsend", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
+ *request = simgrid::smpi::Request::ibsend(buf, count, datatype, dst, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request!=nullptr)
- *request = MPI_REQUEST_NULL;
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Bsend_init(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request)
CHECK_SEND_INPUTS
smpi_bench_end();
- int retval = 0;
- if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int dst_traced = getPid(comm, dst);
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("Ssend", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
- TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
-
- simgrid::smpi::Request::ssend(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
- }
-
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int dst_traced = getPid(comm, dst);
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("Ssend", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
+ simgrid::smpi::Request::ssend(buf, count, datatype, dst, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Sendrecv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf,
int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status)
{
int retval = 0;
-
- smpi_bench_end();
CHECK_BUFFER(1, sendbuf, sendcount)
CHECK_COUNT(2, sendcount)
CHECK_TYPE(3, sendtype)
CHECK_TYPE(8, recvtype)
CHECK_TAG(10, recvtag)
CHECK_COMM(11)
+ smpi_bench_end();
+
if (src == MPI_PROC_NULL) {
if(status!=MPI_STATUS_IGNORE){
simgrid::smpi::Status::empty(status);
int src_traced = getPid(comm, src);
// FIXME: Hack the way to trace this one
- std::vector<int>* dst_hack = new std::vector<int>;
- std::vector<int>* src_hack = new std::vector<int>;
+ auto dst_hack = std::make_shared<std::vector<int>>();
+ auto src_hack = std::make_shared<std::vector<int>>();
dst_hack->push_back(dst_traced);
src_hack->push_back(src_traced);
TRACE_smpi_comm_in(my_proc_id, __func__,
CHECK_TYPE(3, datatype)
int size = datatype->get_extent() * count;
- void* recvbuf = xbt_new0(char, size);
- retval = MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count, datatype, src, recvtag, comm, status);
+ xbt_assert(size > 0);
+ std::vector<char> recvbuf(size);
+ retval =
+ MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf.data(), count, datatype, src, recvtag, comm, status);
if(retval==MPI_SUCCESS){
- simgrid::smpi::Datatype::copy(recvbuf, count, datatype, buf, count, datatype);
+ simgrid::smpi::Datatype::copy(recvbuf.data(), count, datatype, buf, count, datatype);
}
- xbt_free(recvbuf);
return retval;
}
}
// TODO: cheinrich: Move declaration to other file? Rename this function - it's used for PMPI_Wait*?
-static void trace_smpi_recv_helper(MPI_Request* request, MPI_Status* status);
static void trace_smpi_recv_helper(MPI_Request* request, MPI_Status* status)
{
- MPI_Request req = *request;
+ const simgrid::smpi::Request* req = *request;
if (req != MPI_REQUEST_NULL) { // Received requests become null
int src_traced = req->src();
// the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
simgrid::smpi::Status::empty(status);
- CHECK_REQUEST(1)
+ CHECK_NULL(1, MPI_ERR_ARG, request)
if (*request == MPI_REQUEST_NULL) {
retval = MPI_SUCCESS;
} else {
MPI_Request savedreq = *request;
if (savedreq != MPI_REQUEST_NULL && not(savedreq->flags() & MPI_REQ_FINISHED)
&& not(savedreq->flags() & MPI_REQ_GENERALIZED))
- savedreq->ref();//don't erase te handle in Request::wait, we'll need it later
+ savedreq->ref();//don't erase the handle in Request::wait, we'll need it later
else
savedreq = MPI_REQUEST_NULL;
*flag=1;
simgrid::smpi::Status::empty(status);
return MPI_SUCCESS;
- } else if (flag==NULL || status ==NULL){
+ } else if (flag == nullptr || status == nullptr) {
return MPI_ERR_ARG;
}
return simgrid::smpi::Request::get_status(request,flag,status);
MPI_Request PMPI_Request_f2c(MPI_Fint request){
if(request==-1)
return MPI_REQUEST_NULL;
- return static_cast<MPI_Request>(simgrid::smpi::Request::f2c(request));
+ return simgrid::smpi::Request::f2c(request);
}
MPI_Fint PMPI_Request_c2f(MPI_Request request) {