Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
play with mpich3 cmake files
[simgrid.git] / teshsuite / smpi / mpich3-test / datatype / typecommit.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2006 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include <stdio.h>
7 #include <mpi.h>
8 #include "mpitest.h"
9
10 void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf, 
11          MPI_Datatype recvtype);
12 void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf, 
13          MPI_Datatype recvtype)
14 {
15     int blocks[2];
16     MPI_Aint struct_displs[2];
17     MPI_Datatype types[2], tmp_type;
18
19     blocks[0] = 256;
20     MPI_Get_address( sendbuf, &struct_displs[0] );
21     types[0] = sendtype;
22     blocks[1] = 256;
23     MPI_Get_address( recvbuf, &struct_displs[1] );
24     types[1] = MPI_BYTE;
25
26     MPI_Type_create_struct(2, blocks, struct_displs, types, &tmp_type);
27     MPI_Type_commit(&tmp_type);
28     MPI_Type_free(&tmp_type);
29 }
30
31 int main(int argc, char **argv)
32 {
33     int errs = 0;
34
35     MTest_Init(&argc, &argv);
36
37     foo((void*) 0x1, MPI_FLOAT_INT, (void*) 0x2, MPI_BYTE);
38     foo((void*) 0x1, MPI_DOUBLE_INT, (void*) 0x2, MPI_BYTE);
39     foo((void*) 0x1, MPI_LONG_INT, (void*) 0x2, MPI_BYTE);
40     foo((void*) 0x1, MPI_SHORT_INT, (void*) 0x2, MPI_BYTE);
41     foo((void*) 0x1, MPI_2INT, (void*) 0x2, MPI_BYTE);
42 #ifdef HAVE_LONG_DOUBLE
43     /* Optional type may be NULL */
44     if (MPI_LONG_DOUBLE_INT != MPI_DATATYPE_NULL) {
45         foo((void*) 0x1, MPI_LONG_DOUBLE_INT, (void*) 0x2, MPI_BYTE);
46     }
47 #endif
48
49     MTest_Finalize(errs);
50     MPI_Finalize();
51
52     return 0;
53 }