Skip to content

Commit 47288c5

Browse files
authored
[MANA-95] Add test case to reproduce the infinite loop issue (mpickpt#96)
1 parent e55730b commit 47288c5

3 files changed

Lines changed: 80 additions & 1 deletion

File tree

contrib/mpi-proxy-split/mpi-wrappers/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ clean: tidy
141141
rm -f ${LIBNAME}.a libmpistub.so
142142
rm -f ${DMTCP_ROOT}/lib/dmtcp/libmpistub.so
143143
rm -f mpi_stub_wrappers.c
144+
rm -f p2p-deterministic.h
144145
rm -f mpi_unimplemented_wrappers.cpp
145146
rm -f mpi_fortran_wrappers.cpp
146147
rm -f libmpich_intel.so.3.0.1 libmpich_intel.so.3

contrib/mpi-proxy-split/test/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ FILES=mpi_hello_world \
3535
Allgather_test Group_size_rank Type_commit_contiguous \
3636
Irecv_test Alloc_mem \
3737
f_ibarrier \
38-
wave_mpi day1_mpi quad_mpi poisson_nonblock_mpi
38+
wave_mpi day1_mpi quad_mpi poisson_nonblock_mpi \
39+
send_recv_loop
3940

4041
OBJS=$(addsuffix .o, ${FILES})
4142

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Author: Wes Kendall
2+
// Copyright 2011 www.mpitutorial.com
3+
// This code is provided freely with the tutorials on mpitutorial.com. Feel
4+
// free to modify it for your own use. Any distribution of the code must
5+
// either provide a link to www.mpitutorial.com or keep this header in tact.
6+
//
7+
// MPI_Send, MPI_Recv example. Communicates the number -1 from process 0
8+
// to processe 1.
9+
//
10+
#include <mpi.h>
11+
#include <stdio.h>
12+
#include <stdlib.h>
13+
#include <assert.h>
14+
#include <unistd.h>
15+
#include <limits.h>
16+
#include <time.h>
17+
18+
int main(int argc, char** argv) {
19+
int iteration = 10;
20+
if (argc > 1) {
21+
iteration = atoi(argv[1]);
22+
}
23+
24+
// Initialize the MPI environment
25+
MPI_Init(NULL, NULL);
26+
// Find out rank, size
27+
int world_rank;
28+
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
29+
int world_size;
30+
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
31+
32+
// We are assuming at least 2 processes for this task
33+
if (world_size < 3) {
34+
fprintf(stderr, "World size must be greater than or equal to 3 for %s\n", argv[0]);
35+
MPI_Abort(MPI_COMM_WORLD, 1);
36+
}
37+
38+
// rank 0 wait a while then send messages to rank 1
39+
if (world_rank == 0) {
40+
int number = 0;
41+
for (int i = 0; i < iteration; i++) {
42+
sleep(10);
43+
MPI_Send(&number, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
44+
number++;
45+
MPI_Barrier(MPI_COMM_WORLD);
46+
printf("Rank 0 have successfully sent %d messages to rank 1\n", i + 1);
47+
fflush(stdout);
48+
}
49+
} else if (world_rank == 1) {
50+
// rank 1 receive message from 0 first and then 2
51+
int number = 0;
52+
for (int i = 0; i < iteration; i++) {
53+
int recv_number = -1;
54+
MPI_Recv(&recv_number, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
55+
assert(number == recv_number);
56+
MPI_Recv(&recv_number, 1, MPI_INT, 2, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
57+
assert(number == recv_number);
58+
number++;
59+
MPI_Barrier(MPI_COMM_WORLD);
60+
printf("Rank 1 have successfully received %d messages\n", (i + 1) * 2);
61+
fflush(stdout);
62+
}
63+
} else {
64+
// rank 2 send messages to rank 1 right away
65+
int number = 0;
66+
for (int i = 0; i < iteration; i++) {
67+
MPI_Send(&number, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
68+
number++;
69+
MPI_Barrier(MPI_COMM_WORLD);
70+
printf("Rank 2 have successfully sent %d messages to rank 1\n", i + 1);
71+
fflush(stdout);
72+
}
73+
74+
}
75+
MPI_Finalize();
76+
return 0;
77+
}

0 commit comments

Comments
 (0)