7 /* test broadcast behavior with non-zero counts but zero-sized types */
9 int main(int argc, char *argv[])
12 MPI_Datatype type = MPI_DATATYPE_NULL;
16 MPI_Init(&argc, &argv);
17 MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
18 MPI_Comm_size(MPI_COMM_WORLD, &wsize);
20 /* a random non-zero sized buffer */
22 buf = malloc(NELEM*sizeof(int));
25 for (i = 0; i < NELEM; i++) {
26 buf[i] = wrank * NELEM + i;
29 /* create a zero-size type */
30 MPI_Type_contiguous(0, MPI_INT, &type);
31 MPI_Type_commit(&type);
32 MPI_Type_size(type, &type_size);
33 assert(type_size == 0);
35 /* do the broadcast, which will break on some MPI implementations */
36 MPI_Bcast(buf, NELEM, type, 0, MPI_COMM_WORLD);
38 /* check that the buffer remains unmolested */
39 for (i = 0; i < NELEM; i++) {
40 assert(buf[i] == wrank * NELEM + i);
47 printf(" No errors\n");