Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
handle nested datatypes in smpi (structs of vectors for example), which previously...
[simgrid.git] / teshsuite / smpi / mpich-test / pt2pt / htmsg.c
1 #include "mpi.h"
2 #include <stdio.h>
3 #include <string.h>
4
5 #if defined(NEEDS_STDLIB_PROTOTYPES)
6 #include "protofix.h"
7 #endif
8
9 /* 
10    This is a very simple MPI program which can be used to check things
11    like the behavior of the ADI or heterogeneous code
12  */
13 int main( int argc, char **argv )
14 {
15 char msg[10];
16 char smsg[10];
17 int  rank, size;
18 int  src, dest;
19 int  count;
20 MPI_Status status;
21
22 MPI_Init( &argc, &argv );
23 MPI_Comm_size( MPI_COMM_WORLD, &size );
24 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
25 if (size != 2) {
26     MPI_Abort( MPI_COMM_WORLD, 1 );
27     return 1;
28     }
29 src  = 1;
30 dest = 0;
31 if (rank == src) {
32     strcpy( msg, "MPICH!" );
33     MPI_Send( msg, 7, MPI_CHAR, dest, 10, MPI_COMM_WORLD );
34     }
35 else {
36     MPI_Recv( smsg, 10, MPI_CHAR, src, 10, MPI_COMM_WORLD, &status );
37     if (status.MPI_TAG != 10) {
38         fprintf( stderr, "Error in status tag!\n" );
39         }
40     if (status.MPI_SOURCE != src) {
41         fprintf( stderr, "Error in status source!\n" );
42         }
43     MPI_Get_count( &status, MPI_CHAR, &count );
44     if (count != 7) {
45         fprintf( stderr, "Error in count, got %d expected 7\n", count );
46         }
47     if (strcmp( smsg, "MPICH!" )) {
48         fprintf( stderr, "Got wrong msg (%s), expected \"MPICH!\"\n", smsg );
49         }
50     }
51
52 MPI_Finalize();
53 return 0;
54 }