Skip to content

Commit ee7d4c5

Browse files
committed
Add regression test for PR#300, p2p msg overtaking
1 parent 8f2eea5 commit ee7d4c5

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

mpi-proxy-split/test/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ FILES=mpi_hello_world \
4444
File_read_write_test File_characteristics_test File_size_test \
4545
File_read_write_all_test \
4646
Type_dup_test Type_create_hindexed_test \
47-
Type_create_resized_test Type_create_hindexed_block_test
47+
Type_create_resized_test Type_create_hindexed_block_test \
48+
overtake
4849

4950
OBJS=$(addsuffix .o, ${FILES})
5051

mpi-proxy-split/test/overtake.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <mpi.h>
2+
#include <string.h>
3+
#include <stdio.h>
4+
#include <unistd.h>
5+
#include <stdlib.h>
6+
7+
#define MSG_SIZE 1024 * 1024 * 1024 / sizeof(int)
8+
9+
int main (int argc, char **argv) {
10+
int rank;
11+
int *bufs[10];
12+
int size;
13+
MPI_Request reqs[10];
14+
MPI_Init(&argc, &argv);
15+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
16+
MPI_Comm_size(MPI_COMM_WORLD, &size);
17+
18+
if (size != 2) {
19+
printf("This test case requires 2 MPI ranks.\n");
20+
MPI_Abort();
21+
}
22+
23+
if (rank == 0) {
24+
for (int i = 0; i < 10; i++) {
25+
bufs[i] = (int*) malloc(sizeof(int) * MSG_SIZE);
26+
*bufs[i] = i;
27+
}
28+
} else {
29+
for (int i = 0; i < 10; i++) {
30+
bufs[i] = (int*) malloc(sizeof(int) * MSG_SIZE);
31+
*bufs[i] = 0;
32+
}
33+
}
34+
35+
int round = 0;
36+
while (1) {
37+
printf("round %d\n", round++);
38+
fflush(stdout);
39+
for (int i = 0; i < 10; i++) {
40+
if (i == 5) {
41+
// checkpoitn here
42+
printf("process %d sleeping\n", rank);
43+
fflush(stdout);
44+
sleep(5);
45+
}
46+
if (rank == 0) {
47+
MPI_Isend(bufs[i], MSG_SIZE, MPI_INT, 1, 0, MPI_COMM_WORLD, &reqs[i]);
48+
printf("Isend %d initiated\n", i);
49+
fflush(stdout);
50+
} else {
51+
MPI_Irecv(bufs[i], MSG_SIZE, MPI_INT, 0, 0, MPI_COMM_WORLD, &reqs[i]);
52+
printf("Irecv %d initiated\n", i);
53+
fflush(stdout);
54+
}
55+
}
56+
MPI_Waitall(10, reqs, MPI_STATUS_IGNORE);
57+
if (rank == 1) {
58+
for (int i = 0; i < 10; i++) {
59+
printf("recv buf %d: %d\n", i, *bufs[i]);
60+
fflush(stdout);
61+
}
62+
}
63+
}
64+
for (int i = 0; i < 10; i++) {
65+
free(bufs[i]);
66+
}
67+
MPI_Finalize();
68+
return 0;
69+
}

0 commit comments

Comments
 (0)