Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update datatype mpich tests
[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, MPI_Datatype recvtype);
11 void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf, MPI_Datatype recvtype)
12 {
13     int blocks[2];
14     MPI_Aint struct_displs[2];
15     MPI_Datatype types[2], tmp_type;
16
17     blocks[0] = 256;
18     MPI_Get_address(sendbuf, &struct_displs[0]);
19     types[0] = sendtype;
20     blocks[1] = 256;
21     MPI_Get_address(recvbuf, &struct_displs[1]);
22     types[1] = MPI_BYTE;
23
24     MPI_Type_create_struct(2, blocks, struct_displs, types, &tmp_type);
25     MPI_Type_commit(&tmp_type);
26     MPI_Type_free(&tmp_type);
27 }
28
29 int main(int argc, char **argv)
30 {
31     int errs = 0;
32
33     MTest_Init(&argc, &argv);
34
35     foo((void *) 0x1, MPI_FLOAT_INT, (void *) 0x2, MPI_BYTE);
36     foo((void *) 0x1, MPI_DOUBLE_INT, (void *) 0x2, MPI_BYTE);
37     foo((void *) 0x1, MPI_LONG_INT, (void *) 0x2, MPI_BYTE);
38     foo((void *) 0x1, MPI_SHORT_INT, (void *) 0x2, MPI_BYTE);
39     foo((void *) 0x1, MPI_2INT, (void *) 0x2, MPI_BYTE);
40 #ifdef HAVE_LONG_DOUBLE
41     /* Optional type may be NULL */
42     if (MPI_LONG_DOUBLE_INT != MPI_DATATYPE_NULL) {
43         foo((void *) 0x1, MPI_LONG_DOUBLE_INT, (void *) 0x2, MPI_BYTE);
44     }
45 #endif
46
47     MTest_Finalize(errs);
48     MPI_Finalize();
49
50     return 0;
51 }