Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove few tests which may never finish, and change one that used too much stack...
[simgrid.git] / teshsuite / smpi / mpich-test / pt2pt / structlb.c
1 #include "mpi.h"
2 #include <stdio.h>
3
4 int main( int argc, char **argv)
5 {
6     int blockcnt[2], size;
7     MPI_Datatype tmptype, newtype, oldtypes[2];
8     MPI_Aint offsets[2], extent, lb, ub;
9
10     MPI_Init(&argc, &argv);
11
12     blockcnt[0] = 1;
13     offsets[0] = 1;
14     oldtypes[0] = MPI_BYTE;
15     blockcnt[1] = 1;    /* set upper bound to avoid padding */
16     offsets[1] = 2;
17     oldtypes[1] = MPI_UB;
18     MPI_Type_struct(2, blockcnt, offsets, oldtypes, &tmptype);
19     MPI_Type_commit(&tmptype);
20
21     MPI_Type_size(tmptype, &size);
22     MPI_Type_lb(tmptype, &lb);
23     MPI_Type_ub(tmptype, &ub);
24     MPI_Type_extent(tmptype, &extent);
25 #ifdef DEBUG
26     printf("tmptype: size: %d lb: %ld ub: %ld ex: %ld\n", size, lb, ub, 
27            extent);
28 #endif
29         
30     blockcnt[0] = 1;
31     offsets[0] = 1;
32     oldtypes[0] = tmptype;
33     MPI_Type_struct(1, blockcnt, offsets, oldtypes, &newtype);
34     MPI_Type_commit(&newtype);
35
36     MPI_Type_size(newtype, &size);
37     MPI_Type_lb(newtype, &lb);
38     MPI_Type_ub(newtype, &ub);
39     MPI_Type_extent(newtype, &extent);
40 #ifdef DEBUG
41     printf("newtype: size: %ld lb: %ld ub: %ld ex: %d\n", size, lb, ub, 
42            extent);
43 #endif  
44     if (size != 1 || lb != 2 || ub != 3 || extent != 1) {
45             printf ("lb = %ld (should be 2), ub = %ld (should be 3) extent = %ld should be 1, size = %d (should be 1)\n", lb, ub, extent, size) ;
46     }
47     else {
48         printf( " No Errors\n" );
49     }
50     MPI_Type_free(&tmptype);
51     MPI_Type_free(&newtype);
52     MPI_Finalize();
53
54     return 0;
55 }