XBT_LOG_EXTERNAL_CATEGORY(smpi_sender);
XBT_LOG_EXTERNAL_CATEGORY(smpi_util);
-#define EAGER_LIMIT 65536
-#define RDV_TAG (-10)
-
void smpi_process_init(int* argc, char*** argv) {
int index;
smpi_process_data_t data;
request->complete = 0;
request->match = MPI_REQUEST_NULL;
request->flags = flags;
- if(request->size < EAGER_LIMIT) {
- request->ack = MPI_REQUEST_NULL;
- } else {
- request->ack = xbt_new(s_smpi_mpi_request_t, 1);
- request->ack->buf = NULL;
- request->ack->size = 0;
- request->ack->src = dst;
- request->ack->dst = src;
- request->ack->tag = RDV_TAG;
- request->ack->comm = comm;
- request->ack->rdv = NULL;
- request->ack->pair = NULL;
- request->ack->complete = 0;
- request->ack->match = MPI_REQUEST_NULL;
- request->ack->flags = NON_PERSISTENT | ((request->flags & RECV) == RECV ? SEND : RECV);
- smpi_mpi_start(request->ack);
- }
+#ifdef HAVE_TRACING
+ request->send = 0;
+ request->recv = 0;
+#endif
return request;
}
void smpi_mpi_start(MPI_Request request) {
xbt_assert0(request->complete == 0, "Cannot start a non-finished communication");
- if(request->size >= EAGER_LIMIT) {
- print_request("RDV ack", request->ack);
- smpi_mpi_wait(&request->ack, MPI_STATUS_IGNORE);
- }
if((request->flags & RECV) == RECV) {
smpi_process_post_recv(request);
print_request("New recv", 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++;
}