1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #include "mpi.h"
7 #include <stdio.h>
8 #include "mpitest.h"
9
main(int argc,char ** argv)10 int main(int argc, char **argv)
11 {
12 int blockcnt[2], rank;
13 MPI_Aint offsets[2], lb, ub, extent;
14 MPI_Datatype tmp_type, newtype;
15 int errs = 0;
16
17 MTest_Init(&argc, &argv);
18
19 /* Set some values in locations that should not be accessed */
20 blockcnt[1] = -1;
21 offsets[1] = -1;
22
23 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
24 if (rank == 0) {
25 blockcnt[0] = 1;
26 offsets[0] = 3;
27 MPI_Type_create_hindexed(1, blockcnt, offsets, MPI_BYTE, &tmp_type);
28 blockcnt[0] = 1;
29 offsets[0] = 1;
30 MPI_Type_create_hindexed(1, blockcnt, offsets, tmp_type, &newtype);
31 MPI_Type_commit(&newtype);
32
33 MPI_Type_get_extent(newtype, &lb, &extent);
34 ub = lb + extent;
35
36 /* Check that the results are correct */
37 #ifdef DEBUG
38 printf("lb=%ld, ub=%ld, extent=%ld\n", lb, ub, extent);
39 printf("Should be lb=4, ub=5, extent=1\n");
40 #endif
41 if (lb != 4 || ub != 5 || extent != 1) {
42 printf("lb = %d (should be 4), ub = %d (should be 5) extent = %d should be 1\n",
43 (int) lb, (int) ub, (int) extent);
44 errs++;
45 }
46
47 MPI_Type_free(&tmp_type);
48 MPI_Type_free(&newtype);
49 }
50
51 MTest_Finalize(errs);
52 return MTestReturnValue(errs);
53 }
54