Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update datatype mpich tests
[simgrid.git] / teshsuite / smpi / mpich3-test / datatype / contigstruct.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2003 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #include "mpi.h"
8 #include <stdio.h>
9
10 /*
11  * This test checks to see if we can create a simple datatype
12  * made from many contiguous copies of a single struct.  The
13  * struct is built with monotone decreasing displacements to
14  * avoid any struct->contig optimizations.
15  */
16
17 int main(int argc, char **argv)
18 {
19     int blocklens[8], psize, i, rank;
20     MPI_Aint displs[8];
21     MPI_Datatype oldtypes[8];
22     MPI_Datatype ntype1, ntype2;
23
24     MPI_Init(&argc, &argv);
25     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
26
27     for (i = 0; i < 8; i++) {
28         blocklens[i] = 1;
29         displs[i] = (7 - i) * sizeof(long);
30         oldtypes[i] = MPI_LONG;
31     }
32     MPI_Type_struct(8, blocklens, displs, oldtypes, &ntype1);
33     MPI_Type_contiguous(65536, ntype1, &ntype2);
34     MPI_Type_commit(&ntype2);
35
36     MPI_Pack_size(2, ntype2, MPI_COMM_WORLD, &psize);
37
38     MPI_Type_free(&ntype2);
39     MPI_Type_free(&ntype1);
40
41     /* The only failure mode has been SEGV or aborts within the datatype
42      * routines */
43     if (rank == 0) {
44         printf(" No Errors\n");
45     }
46
47     MPI_Finalize();
48     return 0;
49 }