File: typelb.c

package info (click to toggle)
mpich 4.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 423,384 kB
  • sloc: ansic: 1,088,434; cpp: 71,364; javascript: 40,763; f90: 22,829; sh: 17,463; perl: 14,773; xml: 14,418; python: 10,265; makefile: 9,246; fortran: 8,008; java: 4,355; asm: 324; ruby: 176; lisp: 19; php: 8; sed: 4
file content (53 lines) | stat: -rw-r--r-- 1,435 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */

#include "mpi.h"
#include <stdio.h>
#include "mpitest.h"

int main(int argc, char **argv)
{
    int blockcnt[2], rank;
    MPI_Aint offsets[2], lb, ub, extent;
    MPI_Datatype tmp_type, newtype;
    int errs = 0;

    MTest_Init(&argc, &argv);

    /* Set some values in locations that should not be accessed */
    blockcnt[1] = -1;
    offsets[1] = -1;

    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    if (rank == 0) {
        blockcnt[0] = 1;
        offsets[0] = 3;
        MPI_Type_create_hindexed(1, blockcnt, offsets, MPI_BYTE, &tmp_type);
        blockcnt[0] = 1;
        offsets[0] = 1;
        MPI_Type_create_hindexed(1, blockcnt, offsets, tmp_type, &newtype);
        MPI_Type_commit(&newtype);

        MPI_Type_get_extent(newtype, &lb, &extent);
        ub = lb + extent;

        /* Check that the results are correct */
#ifdef DEBUG
        printf("lb=%ld, ub=%ld, extent=%ld\n", lb, ub, extent);
        printf("Should be lb=4, ub=5, extent=1\n");
#endif
        if (lb != 4 || ub != 5 || extent != 1) {
            printf("lb = %d (should be 4), ub = %d (should be 5) extent = %d should be 1\n",
                   (int) lb, (int) ub, (int) extent);
            errs++;
        }

        MPI_Type_free(&tmp_type);
        MPI_Type_free(&newtype);
    }

    MTest_Finalize(errs);
    return MTestReturnValue(errs);
}