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[])
20 MPI_Init(&argc, &argv);
21 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
22 MPI_Comm_size(MPI_COMM_WORLD, &size);
24 int* recv_counts = (int *) xbt_malloc(size * sizeof(int));
25 int* recv_disps = (int *) xbt_malloc(size * sizeof(int));
28 for (i = 0; i < size; i++) {
29 recv_counts[i] = i + 1;
30 recv_disps[i] = recv_sb_size;
31 recv_sb_size += i + 1;
34 int* sb = (int *) xbt_malloc(recv_counts[rank] * sizeof(int));
35 int* rb = (int *) xbt_malloc(recv_sb_size * sizeof(int));
37 status = MPI_Allgatherv(NULL, recv_counts[rank], MPI_INT, rb, recv_counts, recv_disps, MPI_INT, MPI_COMM_WORLD);
38 if(status!=MPI_ERR_BUFFER)
39 printf("MPI_Allgatherv did not return MPI_ERR_BUFFER for empty sendbuf\n");
40 status = MPI_Allgatherv(sb, -1, MPI_INT, rb, recv_counts, recv_disps, MPI_INT, MPI_COMM_WORLD);
41 if(status!=MPI_ERR_COUNT)
42 printf("MPI_Allgatherv did not return MPI_ERR_COUNT for -1 sendcount\n");
43 status = MPI_Allgatherv(sb, recv_counts[rank], MPI_DATATYPE_NULL, rb, recv_counts, recv_disps, MPI_INT, MPI_COMM_WORLD);
44 if(status!=MPI_ERR_TYPE)
45 printf("MPI_Allgatherv did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL sendtype\n");
46 status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, NULL, recv_counts, recv_disps, MPI_INT, MPI_COMM_WORLD);
47 if(status!=MPI_ERR_BUFFER)
48 printf("MPI_Allgatherv did not return MPI_ERR_BUFFER for empty recvbuf\n");
49 status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, NULL, recv_disps, MPI_INT, MPI_COMM_WORLD);
50 if(status!=MPI_ERR_ARG)
51 printf("MPI_Allgatherv did not return MPI_ERR_ARG for NULL recvcounts\n");
52 status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, recv_counts, NULL, MPI_INT, MPI_COMM_WORLD);
53 if(status!=MPI_ERR_ARG)
54 printf("MPI_Allgatherv did not return MPI_ERR_ARG for NULL recvdisps\n");
55 status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, recv_counts, recv_disps, MPI_DATATYPE_NULL, MPI_COMM_WORLD);
56 if(status!=MPI_ERR_TYPE)
57 printf("MPI_Allgatherv did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL recvtype\n");
58 status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, recv_counts, recv_disps, MPI_INT, MPI_COMM_NULL);
59 if(status!=MPI_ERR_COMM)
60 printf("MPI_Allgatherv did not return MPI_ERR_COMM for MPI_COMM_NULL comm\n");
62 printf("[%d] sndbuf=[", rank);
63 for (i = 0; i < recv_counts[rank]; i++){
64 sb[i] = recv_disps[rank] + i;
69 for (i = 0; i < recv_sb_size; i++)
72 status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, recv_counts, recv_disps, MPI_INT, MPI_COMM_WORLD);
74 printf("[%d] rcvbuf=[", rank);
75 for (i = 0; i < recv_sb_size; i++)
79 if (rank == 0 && status != MPI_SUCCESS) {
80 printf("allgatherv returned %d\n", status);
85 xbt_free(recv_counts);
88 return (EXIT_SUCCESS);