Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update datatype mpich tests
[simgrid.git] / teshsuite / smpi / mpich3-test / datatype / struct-ezhov.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2008 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include "mpi.h"
9 #include <string.h>
10
11 #define COUNT           14
12 #define SIZE            340
13 #define EL_COUNT        1131
14
15 char s_buf[EL_COUNT * SIZE];
16 char r_buf[EL_COUNT * SIZE];
17
18 int main(int argc, char **argv)
19 {
20     int rank, size, ret;
21     MPI_Status Status;
22     MPI_Request request;
23     MPI_Datatype struct_type, type1[COUNT];
24     MPI_Aint disp1[COUNT] = { 0, 0, 332, 340 };
25     int block1[COUNT] = { 1, 56, 2, 1 };
26
27     MPI_Init(&argc, &argv);
28     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
29     MPI_Comm_size(MPI_COMM_WORLD, &size);
30
31     type1[0] = MPI_LB;
32     type1[1] = MPI_FLOAT;
33     type1[2] = MPI_FLOAT;
34     type1[3] = MPI_UB;
35
36     MPI_Type_struct(4, block1, disp1, type1, &struct_type);
37
38     ret = MPI_Type_commit(&struct_type);
39     if (ret != MPI_SUCCESS) {
40         fprintf(stderr, "Could not make struct type."), fflush(stderr);
41         MPI_Abort(MPI_COMM_WORLD, 1);
42     }
43
44     memset(s_buf, 0, EL_COUNT * SIZE);
45     memset(r_buf, 0, EL_COUNT * SIZE);
46
47     MPI_Isend(s_buf, EL_COUNT, struct_type, 0, 4, MPI_COMM_WORLD, &request);
48     MPI_Recv(r_buf, EL_COUNT, struct_type, 0, 4, MPI_COMM_WORLD, &Status);
49     MPI_Wait(&request, &Status);
50
51     MPI_Type_free(&struct_type);
52
53     MPI_Finalize();
54
55     printf(" No Errors\n");
56
57     return 0;
58 }