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. */
13 int main(int argc, char *argv[])
21 MPI_Init(&argc, &argv);
22 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
23 MPI_Comm_size(MPI_COMM_WORLD, &size);
26 int* sb = (int *) xbt_malloc(count * sizeof(int));
27 int* rb = (int *) xbt_malloc(count * size * sizeof(int));
29 for (int i = 0; i < count; ++i)
30 sb[i] = rank * count + i;
31 for (int i = 0; i < count * size; ++i)
34 printf("[%d] sndbuf=[", rank);
35 for (int i = 0; i < count; i++)
39 status = MPI_Gather(NULL, count, MPI_INT, rb, count, MPI_INT, root, MPI_COMM_WORLD);
40 if(status!=MPI_ERR_BUFFER)
41 printf("MPI_Gather did not return MPI_ERR_BUFFER for empty sendbuf\n");
42 status = MPI_Gather(sb, -1, MPI_INT, rb, count, MPI_INT, root, MPI_COMM_WORLD);
43 if(status!=MPI_ERR_COUNT)
44 printf("MPI_Gather did not return MPI_ERR_COUNT for -1 sendcount\n");
45 status = MPI_Gather(sb, count, MPI_DATATYPE_NULL, rb, count, MPI_INT, root, MPI_COMM_WORLD);
46 if(status!=MPI_ERR_TYPE)
47 printf("MPI_Gather did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL sendtype\n");
48 status = MPI_Gather(sb, count, MPI_INT, rb, count, MPI_INT, -1, MPI_COMM_WORLD);
49 if(status!=MPI_ERR_ROOT)
50 printf("MPI_Gather did not return MPI_ERR_ROOT for root -1\n");
51 status = MPI_Gather(sb, count, MPI_INT, rb, count, MPI_INT, size+1, MPI_COMM_WORLD);
52 if(status!=MPI_ERR_ROOT)
53 printf("MPI_Gather did not return MPI_ERR_ROOT for root > size\n");
54 status = MPI_Gather(sb, count, MPI_INT, rb, count, MPI_INT, root, MPI_COMM_NULL);
55 if(status!=MPI_ERR_COMM)
56 printf("MPI_Gather did not return MPI_ERR_COMM for MPI_COMM_NULL comm\n");
58 status = MPI_Gather(sb, count, MPI_INT, rb, count, MPI_INT, root, MPI_COMM_WORLD);
61 printf("[%d] rcvbuf=[", rank);
62 for (int i = 0; i < count * size; i++)
66 if (status != MPI_SUCCESS) {
67 printf("gather returned %d\n", status);
73 MPI_Barrier(MPI_COMM_WORLD);
75 return (EXIT_SUCCESS);