request->complete = 0;
request->match = MPI_REQUEST_NULL;
request->flags = flags;
+#ifdef HAVE_TRACING
+ request->send = 0;
+ request->recv = 0;
+#endif
return request;
}
}
}
+int smpi_mpi_get_count(MPI_Status* status, MPI_Datatype datatype) {
+ return status->count / smpi_datatype_size(datatype);
+}
+
static void finish_wait(MPI_Request* request, MPI_Status* status) {
if(status != MPI_STATUS_IGNORE) {
status->MPI_SOURCE = (*request)->src;
status->MPI_TAG = (*request)->tag;
status->MPI_ERROR = MPI_SUCCESS;
+ status->count = SIMIX_communication_get_dst_buf_size((*request)->pair);
}
print_request("finishing wait", *request);
if((*request)->complete == 1) {
int flag = (*request)->complete;
if(flag) {
- SIMIX_communication_destroy((*request)->pair);
- finish_wait(request, status);
+ smpi_mpi_wait(request, status);
}
return flag;
}
flag = 0;
for(i = 0; i < count; i++) {
if(requests[i] != MPI_REQUEST_NULL && requests[i]->complete) {
- SIMIX_communication_destroy(requests[i]->pair);
- finish_wait(&requests[i], status);
+ smpi_mpi_wait(&requests[i], status);
*index = i;
flag = 1;
break;
void smpi_mpi_wait(MPI_Request* request, MPI_Status* status) {
print_request("wait", *request);
- // data is null if receiver waits before sender enters the rdv
- if((*request)->complete) {
- SIMIX_communication_destroy((*request)->pair);
- } else {
- SIMIX_network_wait((*request)->pair, -1.0);
- }
+ SIMIX_network_wait((*request)->pair, -1.0);
finish_wait(request, status);
}
for(i = 0; i < count; i++) {
if(requests[i] != MPI_REQUEST_NULL && requests[i]->complete) {
index = i;
- SIMIX_communication_destroy(requests[index]->pair); // always succeeds (but cleans the simix layer)
+ smpi_mpi_wait(&requests[index], status);
break;
}
}
if(size > 0) {
index = SIMIX_network_waitany(comms);
index = map[index];
+ finish_wait(&requests[index], status);
}
xbt_free(map);
xbt_dynar_free(&comms);
}
- if(index != MPI_UNDEFINED) {
- finish_wait(&requests[index], status);
- }
}
return index;
}
count = 0;
for(i = 0; i < incount; i++) {
if(requests[i] != MPI_REQUEST_NULL && requests[i]->complete) {
- SIMIX_communication_destroy(requests[i]->pair);
- finish_wait(&requests[i], status != MPI_STATUS_IGNORE ? &status[i] : MPI_STATUS_IGNORE);
+ smpi_mpi_wait(&requests[i], status != MPI_STATUS_IGNORE ? &status[i] : MPI_STATUS_IGNORE);
indices[count] = i;
count++;
}