1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2008 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
12 * Run this test with 8 processes. This test was submitted by xxx
13 * as a result of problems seen with the ch3:shm device on a Solaris
14 * system. The symptom is that the test hangs; this is due to losing
15 * a message, probably due to a race condition in a message-queue update.
16 * As a test for race conditions, it may need to be run multiple times
17 * to expose a problem if a problem does exist.
20 #define LOOP_COUNT 10000
24 #define PROGRESS_COUNT 0xfff
25 static int verbose = 0;
26 static int loopProgress = 0;
28 int main(int argc, char *argv[])
34 MPI_Init(&argc, &argv);
35 MPI_Comm_size(MPI_COMM_WORLD, &nProc);
36 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
38 for (i = 1; i < argc; i++) {
39 if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0)
41 else if (strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "--progress") == 0)
45 fprintf(stderr, "%s: [ -v | --verbose ] [ -p | --progress ]\n", argv[0]);
53 sprintf(buf, "fast_mpi_%d.dmp", rank);
56 else if (loopProgress) {
63 psend = (int **) calloc(nProc, sizeof(int *));
64 precv = (int **) calloc(nProc, sizeof(int *));
65 for (i = 0; i < nProc; i++) {
66 psend[i] = (int *) calloc(DATA_SIZE, sizeof(int));
67 precv[i] = (int *) calloc(DATA_SIZE, sizeof(int));
69 for (i = 0; i < LOOP_COUNT; i++) {
71 fprintf(pf, "Master : loop %d\n", i);
74 else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
75 fprintf(pf, "Master: loop %d\n", i);
78 for (j = 1; j < nProc; j++) {
80 fprintf(pf, " read from child %d\n", j);
83 status = MPI_Recv(precv[j], DATA_SIZE, MPI_INT, j, MP_TAG,
84 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
86 fprintf(pf, " read from child %d done, status = %d\n", j, status);
90 for (j = 1; j < nProc; j++) {
92 fprintf(pf, " send to child %d\n", j);
95 status = MPI_Send(psend[j], DATA_SIZE - 1, MPI_INT, j, MP_TAG, MPI_COMM_WORLD);
97 fprintf(pf, " send to child %d done, status = %d\n", j, status);
102 for (i = 0; i < nProc; i++) {
112 psend = (int *) calloc(DATA_SIZE, sizeof(int));
113 precv = (int *) calloc(DATA_SIZE, sizeof(int));
114 for (i = 0; i < LOOP_COUNT; i++) {
116 fprintf(pf, " send to master\n");
120 * else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
121 * fprintf(pf, "Slave: loop %d\n", i); fflush(pf);
124 status = MPI_Send(psend, DATA_SIZE - 1, MPI_INT, 0, MP_TAG, MPI_COMM_WORLD);
126 fprintf(pf, " send to master done, status = %d\n", status);
128 fprintf(pf, " read from master\n");
131 status = MPI_Recv(precv, DATA_SIZE, MPI_INT, 0, MP_TAG,
132 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
134 fprintf(pf, " read from master done, status = %d\n", status);
146 /* This test fails if it hangs */
148 printf(" No Errors\n");