Skip to content
Snippets Groups Projects
Commit 606ff3ae authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Add check that data received is as expected

parent b0605d19
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,42 @@ int nr_send_pcells = 0; ...@@ -54,6 +54,42 @@ int nr_send_pcells = 0;
struct mpiuse_log_entry **recv_pcells; struct mpiuse_log_entry **recv_pcells;
int nr_recv_pcells = 0; int nr_recv_pcells = 0;
/**
* @brief fill a data area with a pattern that can be checked for changes.
*
* @param offset use offset bit pattern 01010101 otherwise 10101010.
* @param size size of data in bytes.
* @param data the data to fill.
*/
static void datacheck_fill(int offset, size_t size, void *data) {
unsigned char fill = 170;
if (offset) fill = fill >> 1;
unsigned char *p = (unsigned char *)data;
for (size_t i = 0; i < size; i++) {
p[i] = fill;
}
}
/**
* @brief test a filled data area for our pattern.
*
* @param offset check for offset bit pattern 01010101 otherwise 10101010.
* @param size size of data in bytes.
* @param data the data to fill.
*
* @result 1 on success, 0 otherwise.
*/
static int datacheck_test(int offset, size_t size, void *data) {
unsigned char fill = 170;
if (offset) fill = fill >> 1;
unsigned char *p = (unsigned char *)data;
for (size_t i = 0; i < size; i++) {
if (p[i] != fill) return 0;
}
return 1;
}
/** /**
* @brief Pick out the relevant logging data for our rank, i.e. all * @brief Pick out the relevant logging data for our rank, i.e. all
* activations of sends and recvs. We ignore the original completion logs, * activations of sends and recvs. We ignore the original completion logs,
...@@ -195,6 +231,9 @@ int main(int argc, char *argv[]) { ...@@ -195,6 +231,9 @@ int main(int argc, char *argv[]) {
/* Start Isend of pcells. */ /* Start Isend of pcells. */
log->data = calloc(log->size, 1); log->data = calloc(log->size, 1);
/* Fill data with a pattern for checking on arrival. */
datacheck_fill(0, log->size, log->data);
res = MPI_Isend(log->data, log->size, MPI_BYTE, log->otherrank, res = MPI_Isend(log->data, log->size, MPI_BYTE, log->otherrank,
basetag + proxy_tag_cells, MPI_COMM_WORLD, basetag + proxy_tag_cells, MPI_COMM_WORLD,
&req_pcells_out[k]); &req_pcells_out[k]);
...@@ -225,6 +264,9 @@ int main(int argc, char *argv[]) { ...@@ -225,6 +264,9 @@ int main(int argc, char *argv[]) {
int basetag = log->otherrank * proxy_tag_shift; int basetag = log->otherrank * proxy_tag_shift;
pcells_in[pid] = calloc(pcells_size[pid], 1); pcells_in[pid] = calloc(pcells_size[pid], 1);
/* Fill data with a pattern for checking when overwritten. */
datacheck_fill(1, log->size, log->data);
res = MPI_Irecv(pcells_in[pid], pcells_size[pid], MPI_BYTE, log->otherrank, res = MPI_Irecv(pcells_in[pid], pcells_size[pid], MPI_BYTE, log->otherrank,
basetag + proxy_tag_cells, MPI_COMM_WORLD, basetag + proxy_tag_cells, MPI_COMM_WORLD,
&req_pcells_in[pid]); &req_pcells_in[pid]);
...@@ -246,7 +288,17 @@ int main(int argc, char *argv[]) { ...@@ -246,7 +288,17 @@ int main(int argc, char *argv[]) {
if (res != MPI_SUCCESS || pid == MPI_UNDEFINED) if (res != MPI_SUCCESS || pid == MPI_UNDEFINED)
error("MPI_Waitany failed."); error("MPI_Waitany failed.");
/* XXX check the data received is correct? */ /* 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)) {
error("Received data is not modified");
} else {
error("Received data is corrupt");
}
} else {
message("Received data is correct");
}
} }
message("All proxy cells have arrived"); message("All proxy cells have arrived");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment