XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
+static int getPid(MPI_Comm, int);
+static int getPid(MPI_Comm comm, int id)
+{
+ simgrid::s4u::ActorPtr actor = comm->group()->actor(id);
+ return (actor == nullptr) ? MPI_UNDEFINED : actor->getPid() - 1;
+}
+
/* PMPI User level calls */
extern "C" { // Obviously, the C MPI interface should use the C linkage
} else {
int rank = smpi_process()->index();
+ int src_traced = getPid(comm, src);
TRACE_smpi_comm_in(rank, __FUNCTION__,
- new simgrid::instr::Pt2PtTIData("Irecv", comm->group()->actor(src)->getPid()-1, // TODO cheinrich was before: index(src); -- make the "-1" go away
+ new simgrid::instr::Pt2PtTIData("Irecv", src_traced,
datatype->is_replayable() ? count : count * datatype->size(),
encode_datatype(datatype)));
retval = MPI_ERR_TAG;
} else {
int rank = smpi_process()->index();
- int trace_dst = comm->group()->actor(dst)->getPid()-1; // TODO cheinrich
+ int trace_dst = getPid(comm, dst);
TRACE_smpi_comm_in(rank, __FUNCTION__,
new simgrid::instr::Pt2PtTIData("Isend", trace_dst,
datatype->is_replayable() ? count : count * datatype->size(),
retval = MPI_ERR_TAG;
} else {
int rank = smpi_process()->index();
- int trace_dst = comm->group()->actor(dst)->getPid()-1; // TODO cheinrich
+ int trace_dst = getPid(comm, dst);
TRACE_smpi_comm_in(rank, __FUNCTION__,
new simgrid::instr::Pt2PtTIData("ISsend", trace_dst,
datatype->is_replayable() ? count : count * datatype->size(),
retval = MPI_ERR_TAG;
} else {
int rank = smpi_process()->index();
- int src_traced = comm->group()->actor(src)->getPid()-1; // TODO cheinrich
+ int src_traced = getPid(comm, src);
TRACE_smpi_comm_in(rank, __FUNCTION__,
new simgrid::instr::Pt2PtTIData("recv", src_traced,
datatype->is_replayable() ? count : count * datatype->size(),
// the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
if (status != MPI_STATUS_IGNORE) {
- src_traced = comm->group()->actor(status->MPI_SOURCE)->getPid()-1;
+ src_traced = getPid(comm, status->MPI_SOURCE);
if (not TRACE_smpi_view_internals()) {
TRACE_smpi_recv(src_traced, rank, tag);
}
retval = MPI_ERR_TAG;
} else {
int rank = smpi_process()->index();
- int dst_traced = comm->group()->actor(dst)->getPid()-1; // TODO cheinrich
+ int dst_traced = getPid(comm, dst);
TRACE_smpi_comm_in(rank, __FUNCTION__,
new simgrid::instr::Pt2PtTIData("send", dst_traced,
datatype->is_replayable() ? count : count * datatype->size(),
retval = MPI_ERR_TAG;
} else {
int rank = smpi_process()->index();
- int dst_traced = comm->group()->actor(dst)->getPid()-1;
+ int dst_traced = getPid(comm, dst);
TRACE_smpi_comm_in(rank, __FUNCTION__,
new simgrid::instr::Pt2PtTIData("Ssend", dst_traced,
datatype->is_replayable() ? count : count * datatype->size(),
retval = MPI_ERR_TAG;
} else {
int rank = smpi_process()->index();
- int dst_traced = comm->group()->actor(dst)->getPid()-1;
- int src_traced = comm->group()->actor(src)->getPid()-1;
+ int dst_traced = getPid(comm, dst);
+ int src_traced = getPid(comm, src);
// FIXME: Hack the way to trace this one
std::vector<int>* dst_hack = new std::vector<int>;