1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2012 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
14 /* test broadcast behavior with non-zero counts but zero-sized types */
16 int main(int argc, char *argv[])
19 MPI_Datatype type = MPI_DATATYPE_NULL;
23 MPI_Init(&argc, &argv);
24 MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
25 MPI_Comm_size(MPI_COMM_WORLD, &wsize);
27 /* a random non-zero sized buffer */
29 buf = malloc(NELEM*sizeof(int));
32 for (i = 0; i < NELEM; i++) {
33 buf[i] = wrank * NELEM + i;
36 /* create a zero-size type */
37 MPI_Type_contiguous(0, MPI_INT, &type);
38 MPI_Type_commit(&type);
39 MPI_Type_size(type, &type_size);
40 assert(type_size == 0);
42 /* do the broadcast, which will break on some MPI implementations */
43 MPI_Bcast(buf, NELEM, type, 0, MPI_COMM_WORLD);
45 /* check that the buffer remains unmolested */
46 for (i = 0; i < NELEM; i++) {
47 assert(buf[i] == wrank * NELEM + i);
54 printf(" No errors\n");