diff --git a/swiftmpiproxies.c b/swiftmpiproxies.c index 4de022a50a6f6d615e97ab772864f5ef89cb213e..e33e47e6e129a6c86ec85d061e57e3364b427ee1 100644 --- a/swiftmpiproxies.c +++ b/swiftmpiproxies.c @@ -266,7 +266,7 @@ int main(int argc, char *argv[]) { pcells_in[pid] = calloc(pcells_size[pid], 1); /* Fill data with a pattern for checking when overwritten. */ - datacheck_fill(1, log->size, log->data); + datacheck_fill(1, pcells_size[pid], pcells_in[pid]); res = MPI_Irecv(pcells_in[pid], pcells_size[pid], MPI_BYTE, log->otherrank, basetag + proxy_tag_cells, MPI_COMM_WORLD, &req_pcells_in[pid]); @@ -290,8 +290,8 @@ int main(int argc, char *argv[]) { /* Check the data received is correct. */ struct mpiuse_log_entry *log = send_pcells[pid]; - if (!datacheck_test(1, log->size, log->data)) { - if (datacheck_test(0, log->size, log->data)) { + if (!datacheck_test(0, pcells_size[pid], pcells_in[pid])) { + if (!datacheck_test(1, pcells_size[pid], pcells_in[pid])) { error("Received data is not modified"); } else { error("Received data is corrupt"); @@ -299,6 +299,7 @@ int main(int argc, char *argv[]) { } else { message("Received data is correct"); } + free(pcells_in[pid]); } message("All proxy cells have arrived"); @@ -306,6 +307,17 @@ int main(int argc, char *argv[]) { res = MPI_Waitall(nr_send_pcells, req_pcells_out, MPI_STATUSES_IGNORE); if (res != MPI_SUCCESS) error("Waitall for pcells Isend failed."); + /* Check data is unmodified. */ + for (int k = 0; k < nr_send_pcells; k++) { + struct mpiuse_log_entry *log = send_pcells[k]; + if (!datacheck_test(0, log->size, log->data)) { + error("Sent data has been corrupted"); + } else { + message("Sent data is correct"); + } + free(log->data); + } + /* Shutdown MPI. */ res = MPI_Finalize(); if (res != MPI_SUCCESS)