1 /* Copyright (c) 2009-2021. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
12 #include "simgrid/actor.h"
14 int main(int argc, char *argv[])
20 srand(sg_actor_self_get_pid());
21 int randomTime = rand() %5;
24 MPI_Init(&argc, &argv);
25 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
26 MPI_Comm_size(MPI_COMM_WORLD, &size);
27 MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
30 int* sb = (int *) xbt_malloc(count * sizeof(int));
31 int* rb = (int *) xbt_malloc(count * size * sizeof(int));
33 for (int i = 0; i < count; ++i)
34 sb[i] = rank * count + i;
35 for (int i = 0; i < count * size; ++i)
38 status = MPI_Allgather(NULL, count, MPI_INT, rb, count, MPI_INT, MPI_COMM_WORLD);
39 if(status!=MPI_ERR_BUFFER)
40 printf("MPI_Allgather did not return MPI_ERR_BUFFER for empty sendbuf\n");
41 status = MPI_Allgather(sb, -1, MPI_INT, rb, count, MPI_INT, MPI_COMM_WORLD);
42 if(status!=MPI_ERR_COUNT)
43 printf("MPI_Allgather did not return MPI_ERR_COUNT for -1 sendcount\n");
44 status = MPI_Allgather(sb, count, MPI_DATATYPE_NULL, rb, count, MPI_INT, MPI_COMM_WORLD);
45 if(status!=MPI_ERR_TYPE)
46 printf("MPI_Allgather did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL sendtype\n");
47 status = MPI_Allgather(sb, count, MPI_INT, NULL, count, MPI_INT, MPI_COMM_WORLD);
48 if(status!=MPI_ERR_BUFFER)
49 printf("MPI_Allgather did not return MPI_ERR_BUFFER for empty recvbuf\n");
50 status = MPI_Allgather(sb, count, MPI_INT, rb, -1, MPI_INT, MPI_COMM_WORLD);
51 if(status!=MPI_ERR_COUNT)
52 printf("MPI_Allgather did not return MPI_ERR_COUNT for -1 recvcount\n");
53 status = MPI_Allgather(sb, count, MPI_INT, rb, count, MPI_DATATYPE_NULL, MPI_COMM_WORLD);
54 if(status!=MPI_ERR_TYPE)
55 printf("MPI_Allgather did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL recvtype\n");
56 status = MPI_Allgather(sb, count, MPI_INT, rb, count, MPI_INT, MPI_COMM_NULL);
57 if(status!=MPI_ERR_COMM)
58 printf("MPI_Allgather did not return MPI_ERR_COMM for MPI_COMM_NULL comm\n");
60 printf("[%d] sndbuf=[", rank);
61 for (int i = 0; i < count; i++)
65 status = MPI_Allgather(sb, count, MPI_INT, rb, count, MPI_INT, MPI_COMM_WORLD);
67 printf("[%d] rcvbuf=[", rank);
68 for (int i = 0; i < count * size; i++)
72 if (rank == 0 && status != MPI_SUCCESS) {
73 printf("allgather returned %d\n", status);