return retval;
}
+// TODO: cheinrich: Move declaration to other file? Rename function - they're used for PMPI_Wait*?
+static void trace_smpi_recv_helper(MPI_Request req, MPI_Status* status);
+static void trace_smpi_recv_helper(MPI_Request req, MPI_Status* status)
+{
+ 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)
+ int dst_traced = req->dst();
+ if (req->flags() & RECV) { // Is this request a wait for RECV?
+ if (src_traced == MPI_ANY_SOURCE)
+ src_traced = (status != MPI_STATUSES_IGNORE) ? req->comm()->group()->rank(status->MPI_SOURCE) : req->src();
+ TRACE_smpi_recv(src_traced, dst_traced, req->tag());
+ }
+ }
+}
+
int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
{
if (index == nullptr)
*index = simgrid::smpi::Request::waitany(count, requests, status);
if(*index!=MPI_UNDEFINED){
- MPI_Request req = requests[*index];
- 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)
- int dst_traced = req->dst();
- if (req->flags() & RECV) {
- if (src_traced == MPI_ANY_SOURCE)
- src_traced = (status != MPI_STATUSES_IGNORE) ? req->comm()->group()->rank(status->MPI_SOURCE) : req->src();
- TRACE_smpi_recv(src_traced, dst_traced, req->tag());
- }
- }
- TRACE_smpi_comm_out(rank_traced);
+ trace_smpi_recv_helper(requests[*index], status);
}
smpi_bench_begin();
int retval = simgrid::smpi::Request::waitall(count, requests, status);
for (int i = 0; i < count; i++) {
- MPI_Request req = requests[i];
- if (req != MPI_REQUEST_NULL) {
- // the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
- int src_traced = req->src();
- int dst_traced = req->dst();
- if ((req->flags() & RECV)) {
- if(src_traced==MPI_ANY_SOURCE)
- src_traced = (status != MPI_STATUSES_IGNORE) ? req->comm()->group()->rank(status[i].MPI_SOURCE) : req->src();
- TRACE_smpi_recv(src_traced, dst_traced, req->tag());
- }
- }
+ trace_smpi_recv_helper(requests[i], &status[i]);
}
TRACE_smpi_comm_out(rank_traced);