1 /* Copyright (c) 2009-2021. 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 int maxlen = argc >= 2 ? atoi(argv[1]) : 1;
24 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
25 MPI_Comm_size(MPI_COMM_WORLD, &size);
26 MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
29 mult = maxlen > size ? size : maxlen;
30 int* sb = xbt_new0(int, size * maxlen);
31 int* rb = xbt_new0(int, size * maxlen);
33 for (i = 0; i < size *maxlen; ++i) {
34 sb[i] = rank*size + i;
38 status = MPI_Allreduce(NULL, rb, size, MPI_UNSIGNED_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
39 if(status!=MPI_ERR_BUFFER)
40 printf("MPI_Allreduce did not return MPI_ERR_BUFFER for empty sendbuf\n");
41 status = MPI_Allreduce(sb, NULL, size, MPI_UNSIGNED_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
42 if(status!=MPI_ERR_BUFFER)
43 printf("MPI_Allreduce did not return MPI_ERR_BUFFER for empty recvbuf\n");
44 status = MPI_Allreduce(sb, rb, -1, MPI_UNSIGNED_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
45 if(status!=MPI_ERR_COUNT)
46 printf("MPI_Allreduce did not return MPI_ERR_COUNT for -1 count\n");
47 status = MPI_Allreduce(sb, rb, size, MPI_DATATYPE_NULL, MPI_SUM, MPI_COMM_WORLD);
48 if(status!=MPI_ERR_TYPE)
49 printf("MPI_Allreduce did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL type\n");
50 status = MPI_Allreduce(sb, rb, size, MPI_UNSIGNED_LONG_LONG, MPI_OP_NULL, MPI_COMM_WORLD);
51 if(status!=MPI_ERR_OP)
52 printf("MPI_Allreduce did not return MPI_ERR_OP for MPI_OP_NULL op\n");
53 status = MPI_Allreduce(sb, rb, size, MPI_UNSIGNED_LONG_LONG, MPI_SUM, MPI_COMM_NULL);
54 if(status!=MPI_ERR_COMM)
55 printf("MPI_Allreduce did not return MPI_ERR_COMM for MPI_COMM_NULL comm\n");
57 printf("[%d] sndbuf=[", rank);
58 for (i = 0; i < size *mult; i++)
61 status = MPI_Allreduce(sb, rb, size *maxlen, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
63 printf("[%d] rcvbuf=[", rank);
64 for (i = 0; i < size *mult; i++)//do not print everything
68 if (rank == 0 && status != MPI_SUCCESS) {
69 printf("all_to_all returned %d\n", status);
75 return (EXIT_SUCCESS);