Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpich3 test suite, to replace older one.
[simgrid.git] / teshsuite / smpi / mpich-test / pt2pt / sendrecv.c
1 /* 
2  * Program to test all of the features of MPI_Send and MPI_Recv
3  *
4  * *** What is tested? ***
5  * 1. Sending and receiving all basic types and many sizes - check
6  * 2. Tag selectivity - check
7  * 3. Error return codes for
8  *    a. Invalid Communicator
9  *    b. Invalid destination or source
10  *    c. Count out of range
11  *    d. Invalid type
12  *
13  * Define VERBOSE to get noisier output
14  */
15
16 #include "test.h"
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include "mpi.h"
21
22 #ifdef HAVE_MPICHCONF_H
23 #include "mpichconf.h"
24 #endif
25
26 static int src = 1;
27 static int dest = 0;
28
29 static int do_test1 = 1;
30 static int do_test2 = 1;
31 static int do_test3 = 1;
32
33 static int verbose = 0;
34
35 #define MAX_TYPES 13
36 static int ntypes = 0;
37 static int nolongdouble = 0;
38 static MPI_Datatype BasicTypes[MAX_TYPES];
39
40 static int maxbufferlen = 10000;
41 static char *(BasicNames[MAX_TYPES]);
42
43 /* In order to quiet noisy C compilers, we provide ANSI-style prototypes
44    where possible */
45
46 void AllocateBuffers ( void **, MPI_Datatype *, int, int );
47 void FreeBuffers ( void **, int );
48 void FillBuffers ( void **, MPI_Datatype *, int, int );
49 int CheckBuffer ( void *, MPI_Datatype, int );
50 void SetupBasicTypes (void);
51 void SenderTest1 (void);
52 void ReceiverTest1 (void);
53 void SenderTest2 (void);
54 void ReceiverTest2 (void);
55 void SenderTest3 (void);
56 void ReceiverTest3 (void);
57
58 void 
59 AllocateBuffers(bufferspace, buffertypes, num_types, bufferlen)
60      void **bufferspace;
61      MPI_Datatype *buffertypes;
62      int num_types;
63      int bufferlen;
64 {
65   int i;
66   for (i = 0; i < ntypes; i++) {
67     if (buffertypes[i] == MPI_CHAR)
68             bufferspace[i] = malloc(bufferlen * sizeof(char));
69     else if (buffertypes[i] == MPI_SHORT)
70             bufferspace[i] = malloc(bufferlen * sizeof(short));
71     else if (buffertypes[i] == MPI_INT)
72             bufferspace[i] = malloc(bufferlen * sizeof(int));
73     else if (buffertypes[i] == MPI_LONG)
74             bufferspace[i] = malloc(bufferlen * sizeof(long));
75     else if (buffertypes[i] == MPI_UNSIGNED_CHAR)
76             bufferspace[i] = malloc(bufferlen * sizeof(unsigned char));
77     else if (buffertypes[i] == MPI_UNSIGNED_SHORT)
78             bufferspace[i] = malloc(bufferlen * sizeof(unsigned short));
79     else if (buffertypes[i] == MPI_UNSIGNED)
80             bufferspace[i] = malloc(bufferlen * sizeof(unsigned int));
81     else if (buffertypes[i] == MPI_UNSIGNED_LONG)
82             bufferspace[i] = malloc(bufferlen * sizeof(unsigned long));
83     else if (buffertypes[i] == MPI_FLOAT)
84             bufferspace[i] = malloc(bufferlen * sizeof(float));
85     else if (buffertypes[i] == MPI_DOUBLE)
86             bufferspace[i] = malloc(bufferlen * sizeof(double));
87 #if defined(HAVE_LONG_DOUBLE) && !defined(HAS_XDR) 
88     else if (buffertypes[i] == MPI_LONG_DOUBLE) {
89             int dlen;
90             MPI_Type_size( MPI_LONG_DOUBLE, &dlen );
91             bufferspace[i] = malloc(bufferlen * dlen);
92     }
93 #endif
94 #if defined(HAVE_LONG_LONG_INT) && !defined(HAS_XDR)
95     else if (buffertypes[i] == MPI_LONG_LONG_INT) 
96             bufferspace[i] = malloc(bufferlen * sizeof(long long) );
97 #endif
98     else if (buffertypes[i] == MPI_BYTE)
99             bufferspace[i] = malloc(bufferlen * sizeof(unsigned char));
100   }
101 }
102
103 void FreeBuffers(void **buffers, int nbuffers)
104 {
105   int i;
106   for (i = 0; i < nbuffers; i++)
107     free(buffers[i]);
108 }
109
110 void FillBuffers(bufferspace, buffertypes, num_types, bufferlen)
111      void **bufferspace; 
112      MPI_Datatype *buffertypes;
113      int num_types;
114      int bufferlen;
115 {
116   int i, j;
117   for (i = 0; i < ntypes; i++) {
118     for (j = 0; j < bufferlen; j++) {
119             if (buffertypes[i] == MPI_CHAR)
120         ((char *)bufferspace[i])[j] = (char)(j & 0x7f);
121             else if (buffertypes[i] == MPI_SHORT)
122         ((short *)bufferspace[i])[j] = (short)j;
123             else if (buffertypes[i] == MPI_INT)
124         ((int *)bufferspace[i])[j] = (int)j;
125             else if (buffertypes[i] == MPI_LONG)
126         ((long *)bufferspace[i])[j] = (long)j;
127             else if (buffertypes[i] == MPI_UNSIGNED_CHAR)
128         ((unsigned char *)bufferspace[i])[j] = (unsigned char)j;
129             else if (buffertypes[i] == MPI_UNSIGNED_SHORT)
130         ((unsigned short *)bufferspace[i])[j] = (unsigned short)j;
131             else if (buffertypes[i] == MPI_UNSIGNED)
132         ((unsigned int *)bufferspace[i])[j] = (unsigned int)j;
133             else if (buffertypes[i] == MPI_UNSIGNED_LONG)
134         ((unsigned long *)bufferspace[i])[j] = (unsigned long)j;
135             else if (buffertypes[i] == MPI_FLOAT)
136         ((float *)bufferspace[i])[j] = (float)j;
137             else if (buffertypes[i] == MPI_DOUBLE)
138         ((double *)bufferspace[i])[j] = (double)j;
139 #if defined(HAVE_LONG_DOUBLE) && !defined(HAS_XDR) 
140             else if (buffertypes[i] == MPI_LONG_DOUBLE)
141         ((long double *)bufferspace[i])[j] = (long double)j;
142 #endif
143 #if defined(HAVE_LONG_LONG_INT) && !defined(HAS_XDR) 
144             else if (buffertypes[i] == MPI_LONG_LONG_INT)
145         ((long long *)bufferspace[i])[j] = (long long)j;
146 #endif
147             else if (buffertypes[i] == MPI_BYTE)
148         ((unsigned char *)bufferspace[i])[j] = (unsigned char)j;
149     }
150   }
151 }
152
153 int
154 CheckBuffer(bufferspace, buffertype, bufferlen)
155      void *bufferspace; 
156      MPI_Datatype buffertype; 
157      int bufferlen;
158 {
159   int j;
160   char valerr[256];
161   valerr[0] = 0;
162   for (j = 0; j < bufferlen; j++) {
163     if (buffertype == MPI_CHAR) {
164             if (((char *)bufferspace)[j] != (char)(j & 0x7f)) {
165         sprintf( valerr, "%x != %x", 
166                  ((char *)bufferspace)[j], (char)(j&0x7f) );
167         break;
168       }
169     } else if (buffertype == MPI_SHORT) {
170             if (((short *)bufferspace)[j] != (short)j) {
171         sprintf( valerr, "%d != %d", 
172                  ((short *)bufferspace)[j], (short)j );
173         break;
174       }
175     } else if (buffertype == MPI_INT) {
176             if (((int *)bufferspace)[j] != (int)j) {
177         sprintf( valerr, "%d != %d", 
178                  ((int *)bufferspace)[j], (int)j );
179         break;
180       }
181     } else if (buffertype == MPI_LONG) {
182             if (((long *)bufferspace)[j] != (long)j) {
183         break;
184       }
185     } else if (buffertype == MPI_UNSIGNED_CHAR) {
186             if (((unsigned char *)bufferspace)[j] != (unsigned char)j) {
187         break;
188       }
189     } else if (buffertype == MPI_UNSIGNED_SHORT) {
190             if (((unsigned short *)bufferspace)[j] != (unsigned short)j) {
191         break;
192       }
193     } else if (buffertype == MPI_UNSIGNED) {
194             if (((unsigned int *)bufferspace)[j] != (unsigned int)j) {
195         break;
196       }
197     } else if (buffertype == MPI_UNSIGNED_LONG) {
198             if (((unsigned long *)bufferspace)[j] != (unsigned long)j) {
199         break;
200       }
201     } else if (buffertype == MPI_FLOAT) {
202             if (((float *)bufferspace)[j] != (float)j) {
203         break;
204       }
205     } else if (buffertype == MPI_DOUBLE) {
206             if (((double *)bufferspace)[j] != (double)j) {
207         break;
208       }
209 #if defined(HAVE_LONG_DOUBLE) && !defined(HAS_XDR) 
210     } else if (buffertype == MPI_LONG_DOUBLE) {
211             if (((long double *)bufferspace)[j] != (long double)j) {
212         break;
213       }
214 #endif
215 #if defined(HAVE_LONG_LONG_INT) && !defined(HAS_XDR) 
216     } else if (buffertype == MPI_LONG_LONG_INT) {
217             if (((long long *)bufferspace)[j] != (long long)j) {
218         break;
219       }
220 #endif
221     } else if (buffertype == MPI_BYTE) {
222             if (((unsigned char *)bufferspace)[j] != (unsigned char)j) {
223         break;
224       }
225     }
226   }
227   /* Return +1 so an error in the first location is > 0 */
228   if (j < bufferlen) {
229     if (valerr[0]) fprintf( stderr, "Different value[%d] = %s\n", 
230                             j, valerr );
231     else
232             fprintf( stderr, "Different value[%d]\n", j );
233     return j+1;
234         }
235   return 0;
236 }
237
238 void 
239 SetupBasicTypes()
240 {
241   BasicTypes[0] = MPI_CHAR;        BasicNames[0] = (char*)"MPI_CHAR" ;
242   BasicTypes[1] = MPI_SHORT;       BasicNames[1] = (char*)"MPI_SHORT";
243   BasicTypes[2] = MPI_INT;         BasicNames[2] = (char*)"MPI_INT"  ;
244   BasicTypes[3] = MPI_LONG;        BasicNames[3] = (char*)"MPI_LONG" ;
245   BasicTypes[4] = MPI_UNSIGNED_CHAR; BasicNames[4] = (char*)"MPI_UNSIGNED_CHAR";
246   BasicTypes[5] = MPI_UNSIGNED_SHORT; BasicNames[5] = (char*)"MPI_UNSIGNED_SHORT";
247   BasicTypes[6] = MPI_UNSIGNED;    BasicNames[6] = (char*)"MPI_UNSIGNED";
248   BasicTypes[7] = MPI_UNSIGNED_LONG; BasicNames[7] = (char*)"MPI_UNSIGNED_LONG";
249   BasicTypes[8] = MPI_FLOAT;       BasicNames[8] = (char*)"MPI_FLOAT";
250   BasicTypes[9] = MPI_DOUBLE;      BasicNames[9] = (char*)"MPI_DOUBLE";
251   BasicTypes[10] = MPI_BYTE;       BasicNames[10] = (char*)"MPI_BYTE";
252   /* By making the BYTE type LAST, we make it easier to handle heterogeneous
253      systems that may not support all of the types */
254   ntypes = 11;
255 #if defined (HAVE_LONG_DOUBLE) && !defined(HAS_XDR) 
256   /* This test allows us to use MPI_LONG_DOUBLE, but rely on size > 0 
257      for "actually implemented" */
258   if (!nolongdouble) { 
259     int l;
260     MPI_Type_size( MPI_LONG_DOUBLE, &l );
261     if (l > 0) {
262             BasicTypes[ntypes] = MPI_LONG_DOUBLE; 
263             BasicNames[ntypes] = (char*)"MPI_LONG_DOUBLE";
264             ntypes++;
265     }
266   }
267 #endif
268 #if defined(HAVE_LONG_LONG_INT) && !defined(HAS_XDR)
269   BasicTypes[ntypes] = MPI_LONG_LONG_INT;
270   BasicNames[ntypes] = (char*)"MPI_LONG_LONG_INT";
271   ntypes++;
272 #endif
273 }
274
275 void 
276 SenderTest1()
277 {
278   void *bufferspace[MAX_TYPES];
279   int i, j;
280
281   AllocateBuffers(bufferspace, BasicTypes, ntypes, maxbufferlen);
282   FillBuffers(bufferspace, BasicTypes, ntypes, maxbufferlen);
283   for (i = 0; i < ntypes; i++) {
284     MPI_Send( (void *)0, 0, BasicTypes[i], dest, 2000, MPI_COMM_WORLD );
285     for (j = 0; j < maxbufferlen; j += 500)
286             MPI_Send(bufferspace[i], j, BasicTypes[i], dest, 
287                2000, MPI_COMM_WORLD);
288   }
289   FreeBuffers(bufferspace, ntypes);
290 }
291
292 void
293 ReceiverTest1()
294 {
295   void *bufferspace[MAX_TYPES];
296   int i, j;
297   char message[81];
298   MPI_Status Stat;
299   int dummy, passed;
300
301   AllocateBuffers(bufferspace, BasicTypes, ntypes, maxbufferlen);
302   for (i = 0; i < ntypes; i++) {
303     passed = 1;
304     MPI_Recv( (void *)0, 0, BasicTypes[i], src, 
305               2000, MPI_COMM_WORLD, &Stat);
306     if (Stat.MPI_SOURCE != src) {
307             fprintf(stderr, "*** Incorrect Source returned. ***\n");
308             Test_Failed(message);
309             passed = 0;
310     } else if (Stat.MPI_TAG != 2000) {  
311             fprintf(stderr, "*** Incorrect Tag returned. ***\n");           
312             Test_Failed(message);
313             passed = 0;
314     } else if (MPI_Get_count(&Stat, BasicTypes[i], &dummy) ||
315                dummy != 0) {
316             fprintf(stderr, 
317               "*** Incorrect Count returned, Count = %d. ***\n", 
318               dummy);
319             Test_Failed(message);
320             passed = 0;
321     }
322     /* Try different sized messages */
323     for (j = 0; j < maxbufferlen; j += 500) {
324             MPI_Recv(bufferspace[i], j, BasicTypes[i], src, 
325                2000, MPI_COMM_WORLD, &Stat);
326             sprintf(message, "Send-Receive Test, Type %d, Count %d",
327               i, j);
328             if (Stat.MPI_SOURCE != src) {
329         fprintf(stderr, "*** Incorrect Source returned. ***\n");
330         Test_Failed(message);
331         passed = 0;
332             } else if (Stat.MPI_TAG != 2000) {  
333         fprintf(stderr, "*** Incorrect Tag returned. ***\n");       
334         Test_Failed(message);
335         passed = 0;
336             } else if (MPI_Get_count(&Stat, BasicTypes[i], &dummy) ||
337                  dummy != j) {
338         fprintf(stderr, 
339                 "*** Incorrect Count returned, Count = %d (should be %d). ***\n", 
340                 dummy, j);
341         Test_Failed(message);
342         passed = 0;
343             } else if(CheckBuffer(bufferspace[i], BasicTypes[i], j)) {
344         fprintf(stderr, 
345                 "*** Incorrect Message received (type = %d (%s), count = %d). ***\n",
346                 i, BasicNames[i], j );
347         Test_Failed(message);
348         passed = 0;
349             } 
350 #ifdef VERBOSE          
351             else {
352         fprintf(stderr, 
353                 "Message of count %d, type %d received correctly.\n", 
354                 j, i );
355             }
356 #endif
357     }
358     sprintf(message, "Send-Receive Test, Type %d (%s)",
359             i, BasicNames[i] );
360     if (passed) 
361             Test_Passed(message);
362     else 
363             Test_Failed(message);
364   }
365   FreeBuffers(bufferspace, ntypes);
366 }
367
368 #define MAX_ORDER_TAG 2010
369 /* Test Tag Selectivity.
370    Note that we must use non-blocking sends here, since otherwise we could 
371    deadlock waiting to receive/send the first message
372 */
373 void 
374 SenderTest2()
375 {
376   int *buffer;
377   int i;
378   MPI_Request r[10];
379   MPI_Status  s[10];
380
381   buffer = (int *)malloc(maxbufferlen * sizeof(int));
382   for (i = 0; i < maxbufferlen; i++)
383     buffer[i] = i;
384     
385   for (i = 2001; i <= MAX_ORDER_TAG; i++)
386     MPI_Isend(buffer, maxbufferlen, MPI_INT, dest,
387               i, MPI_COMM_WORLD, &r[i-2001] );
388     
389   MPI_Waitall( MAX_ORDER_TAG-2001+1, r, s );
390   free(buffer);
391     
392   return;
393 }
394
395 void
396 ReceiverTest2()
397 {
398   int *buffer;
399   int i, j;
400   char message[81];
401   MPI_Status Stat;
402   int dummy, passed;
403   int errloc;
404
405   buffer = (int *)calloc(maxbufferlen,sizeof(int));
406   passed = 1;
407
408   for (i = MAX_ORDER_TAG; i >= 2001; i--) {
409     MPI_Recv(buffer, maxbufferlen, MPI_INT, src, 
410              i, MPI_COMM_WORLD, &Stat);
411     sprintf(message, "Tag Selectivity Test, Tag %d",
412             i);
413     if (Stat.MPI_SOURCE != src) {
414             fprintf(stderr, "*** Incorrect Source returned. ***\n");
415             Test_Failed(message);
416     } else if (Stat.MPI_TAG != i) {     
417             fprintf(stderr, "*** Incorrect Tag returned. ***\n");           
418             Test_Failed(message);
419     } else if (MPI_Get_count(&Stat, MPI_INT, &dummy) ||
420                dummy != maxbufferlen) {
421             fprintf(stderr, 
422               "*** Incorrect Count returned, Count = %d. ***\n", 
423               dummy);
424             Test_Failed(message);
425     } else if((errloc = 
426                CheckBuffer((void*)buffer, MPI_INT, maxbufferlen))) {
427             fprintf(stderr, 
428               "*** Incorrect Message received at %d (tag=%d). ***\n",
429               errloc-1, i);
430             Test_Failed(message);
431             passed = 0;
432     }
433     /* Clear out the buffer */
434     for (j = 0; j < maxbufferlen; j++)
435             buffer[j] = -1;
436   }
437   strncpy(message, "Tag Selectivity Test", 81);
438   if (passed)
439     Test_Passed(message);
440   else
441     Test_Failed(message);
442   free(buffer);
443   return;
444 }
445
446 void
447 SenderTest3()
448 {
449   int ibuf[10];
450
451   /* A receive test might not fail until it is triggered... */
452   MPI_Send( ibuf, 10, MPI_INT, dest, 15, MPI_COMM_WORLD);
453
454   return;
455 }
456
457 void
458 ReceiverTest3( void )
459 {
460   int buffer[20];
461   MPI_Datatype bogus_type = MPI_DATATYPE_NULL;
462   MPI_Status status;
463   int myrank;
464   int small_tag;
465   /*
466     if (verbose) 
467     MPI_Errhandler_set(MPI_COMM_WORLD, TEST_ERRORS_WARN);
468     else 
469     MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN );
470   */
471   MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
472
473   if (myrank == 0 && verbose) {
474     fprintf( stderr, 
475              "There should be eight error messages about invalid communicator\n\
476 count argument, datatype argument, tag, rank, buffer send and buffer recv\n" );
477         }
478   if (MPI_Send(buffer, 20, MPI_INT, dest,
479                1, MPI_COMM_NULL) == MPI_SUCCESS){
480     Test_Failed("NULL Communicator Test");
481   }
482   else
483     Test_Passed("NULL Communicator Test");
484
485   if (MPI_Send(buffer, -1, MPI_INT, dest,
486                1, MPI_COMM_WORLD) == MPI_SUCCESS){
487     Test_Failed("Invalid Count Test");
488   }
489   else
490     Test_Passed("Invalid Count Test");
491
492   if (MPI_Send(buffer, 20, bogus_type, dest,
493                1, MPI_COMM_WORLD) == MPI_SUCCESS){
494     Test_Failed("Invalid Type Test");
495   }
496   else
497     Test_Passed("Invalid Type Test");
498
499   small_tag = -1;
500   if (small_tag == MPI_ANY_TAG) small_tag = -2;
501   if (MPI_Send(buffer, 20, MPI_INT, dest, 
502                small_tag, MPI_COMM_WORLD) == MPI_SUCCESS) {
503     Test_Failed("Invalid Tag Test");
504   }
505   else
506     Test_Passed("Invalid Tag Test");
507
508   /* Form a tag that is too large */
509   /*MPI_Attr_get( MPI_COMM_WORLD, MPI_TAG_UB, (void **)&tag_ubp, &flag );
510     if (!flag) Test_Failed("Could not get tag ub!" );
511     large_tag = *tag_ubp + 1;
512     if (large_tag > *tag_ubp) {
513     if (MPI_Send(buffer, 20, MPI_INT, dest, 
514     large_tag, MPI_COMM_WORLD) == MPI_SUCCESS) {
515     Test_Failed("Invalid Tag Test");
516     }
517     else
518     Test_Passed("Invalid Tag Test");
519     }
520   */
521   if (MPI_Send(buffer, 20, MPI_INT, 300,
522                1, MPI_COMM_WORLD) == MPI_SUCCESS) {
523     Test_Failed("Invalid Destination Test");
524   }
525   else
526     Test_Passed("Invalid Destination Test");
527
528   if (MPI_Send((void *)0, 10, MPI_INT, dest,
529                1, MPI_COMM_WORLD) == MPI_SUCCESS){
530     Test_Failed("Invalid Buffer Test (send)");
531   }
532   else
533     Test_Passed("Invalid Buffer Test (send)");
534
535   /* A receive test might not fail until it is triggered... */
536   if (MPI_Recv((void *)0, 10, MPI_INT, src,
537                15, MPI_COMM_WORLD, &status) == MPI_SUCCESS){
538     Test_Failed("Invalid Buffer Test (recv)");
539   }
540   else
541     Test_Passed("Invalid Buffer Test (recv)");
542
543   /* Just to keep things happy, see if there is a message to receive */
544   { //int flag, 
545     int ibuf[10];
546
547     //MPI_Iprobe( src, 15, MPI_COMM_WORLD, &flag, &status );
548     //if (flag) 
549     MPI_Recv( ibuf, 10, MPI_INT, src, 15, MPI_COMM_WORLD, &status );
550   }
551   MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
552   return;
553 }
554
555 /* Allow -nolongdouble to suppress long double testing */
556 int main( int argc, char **argv )
557 {
558   int myrank, mysize;
559   int rc, itemp, i;
560
561   MPI_Init(&argc, &argv);
562   MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
563   MPI_Comm_size(MPI_COMM_WORLD, &mysize);
564   Test_Init("sendrecv", myrank);
565   SetupBasicTypes();
566
567   if (mysize != 2) {
568     fprintf(stderr, 
569             "*** This test program requires exactly 2 processes.\n");
570     MPI_Abort( MPI_COMM_WORLD, 1 );
571   }
572
573   /* Get the min of the basic types */
574   itemp = ntypes;
575   MPI_Allreduce( &itemp, &ntypes, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD );
576
577   /* dest writes out the received stats; for the output to be
578      consistant (with the final check), it should be procees 0 */
579   for (i=1; i<argc; i++) {
580     if (argv[i] && strcmp( "-alt", argv[i] ) == 0) {
581             dest = 1;
582             src  = 0;
583     } 
584     else if (argv[i] && strcmp( "-nolongdouble", argv[i] ) == 0) {
585             nolongdouble = 1;
586     }
587     else if (argv[i] && strcmp( "-test1", argv[i] ) == 0) {
588             do_test2 = do_test3 = 0;
589     }
590     else if (argv[i] && strcmp( "-test2", argv[i] ) == 0) {
591             do_test1 = do_test3 = 0;
592     }
593     else if (argv[i] && strcmp( "-test3", argv[i] ) == 0) {
594             do_test2 = do_test1 = 0;
595     }
596     else {
597             printf( "Unrecognized argument %s\n", argv[i] );
598     }
599   }
600
601   /* Turn stdout's buffering to line buffered so it mixes right with
602      stderr in output files. (hopefully) */
603   setvbuf(stdout, NULL, _IOLBF, 0);
604   setvbuf(stderr, NULL, _IOLBF, 0);
605
606   if (myrank == src) {
607     if (do_test1)
608             SenderTest1();
609     if (do_test2)
610             SenderTest2();
611     if (do_test3)
612             SenderTest3(); 
613   } else if (myrank == dest) {
614     if (do_test1)
615             ReceiverTest1();
616     if (do_test2)
617             ReceiverTest2();
618     if (do_test3) 
619             ReceiverTest3();
620   } else {
621     fprintf(stderr, "*** This program uses exactly 2 processes! ***\n");
622     MPI_Abort( MPI_COMM_WORLD, 1 );
623   }
624   if (myrank == dest) {
625     rc = Summarize_Test_Results();
626   }
627   else {
628     rc = 0;
629   }
630   Test_Finalize();
631   Test_Waitforall( );
632   MPI_Finalize();
633   return rc;
634 }
635