1 /* Copyright (c) 2009-2019. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
10 int main(int argc, char **argv)
18 MPI_Init(&argc, &argv);
19 MPI_Comm_size(MPI_COMM_WORLD, &size);
20 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
22 int *values = (int *) xbt_malloc(count * sizeof(int));
24 for (i = 0; i < count; i++)
25 values[i] = (0 == rank) ? 17 : 3;
27 status = MPI_Bcast(NULL, count, MPI_INT, 0, MPI_COMM_WORLD);
28 if(status!=MPI_ERR_BUFFER)
29 printf("MPI_Bcast did not return MPI_ERR_BUFFER for empty sendbuf\n");
30 status = MPI_Bcast(values, -1, MPI_INT, 0, MPI_COMM_WORLD);
31 if(status!=MPI_ERR_COUNT)
32 printf("MPI_Bcast did not return MPI_ERR_COUNT for -1 sendcount\n");
33 status = MPI_Bcast(values, count, MPI_DATATYPE_NULL, 0, MPI_COMM_WORLD);
34 if(status!=MPI_ERR_TYPE)
35 printf("MPI_Bcast did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL sendtype\n");
36 status = MPI_Bcast(values, count, MPI_INT, -1, MPI_COMM_WORLD);
37 if(status!=MPI_ERR_ROOT)
38 printf("MPI_Bcast did not return MPI_ERR_ROOT for -1 root\n");
39 status = MPI_Bcast(values, count, MPI_INT, size, MPI_COMM_WORLD);
40 if(status!=MPI_ERR_ROOT)
41 printf("MPI_Bcast did not return MPI_ERR_ROOT for root > size\n");
42 status = MPI_Bcast(values, count, MPI_INT, 0, MPI_COMM_NULL);
43 if(status!=MPI_ERR_COMM)
44 printf("MPI_Bcast did not return MPI_ERR_COMM for MPI_COMM_NULL comm\n");
46 MPI_Bcast(values, count, MPI_INT, 0, MPI_COMM_WORLD);
49 for (i = 0; i < count; i++)
50 if (values[i]==17) good++;
51 printf("[%d] number of values equals to 17: %d\n", rank, good);
53 MPI_Barrier(MPI_COMM_WORLD);
57 values = (int *) xbt_malloc(count * sizeof(int));
59 for (i = 0; i < count; i++)
60 values[i] = (size -1 == rank) ? 17 : 3;
62 status = MPI_Bcast(values, count, MPI_INT, size-1, MPI_COMM_WORLD);
65 for (i = 0; i < count; i++)
66 if (values[i]==17) good++;
67 printf("[%d] number of values equals to 17: %d\n", rank, good);
69 if (rank == 0 && status != MPI_SUCCESS) {
70 printf("bcast returned %d\n", status);