- int retval = 0;
-
- smpi_bench_end();
- if (request == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (dst == MPI_PROC_NULL) {
- *request = MPI_REQUEST_NULL;
- retval = MPI_SUCCESS;
- } else if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else if ((count < 0) || (buf==nullptr && count > 0)) {
- retval = MPI_ERR_COUNT;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if(tag<0 && tag != MPI_ANY_TAG){
- retval = MPI_ERR_TAG;
- } 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);
- }
-
- smpi_bench_begin();
- if (retval != MPI_SUCCESS && request!=nullptr)
- *request = MPI_REQUEST_NULL;
- return retval;
+ CHECK_ISEND_INPUTS
+
+ const SmpiBenchGuard suspend_bench;
+ aid_t my_proc_id = simgrid::s4u::this_actor::get_pid();
+ aid_t trace_dst = getPid(comm, dst);
+ int bsend_buf_size = 0;
+ void* bsend_buf = nullptr;
+ smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
+ if (bsend_buf == nullptr || bsend_buf_size < datatype->get_extent() * count + MPI_BSEND_OVERHEAD)
+ return MPI_ERR_BUFFER;
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("ibsend", MPI_COMM_WORLD->group()->rank(trace_dst),
+ count,
+ 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);
+ return MPI_SUCCESS;