1 /* Copyright (c) 2012, 2014. 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. */
11 * MESSAGE PASSING INTERFACE TEST CASE SUITE
13 * Copyright IBM Corp. 1995
15 * IBM Corp. hereby grants a non-exclusive license to use, copy, modify, and
16 *distribute this software for any purpose and without fee provided that the
17 *above copyright notice and the following paragraphs appear in all copies.
19 * IBM Corp. makes no representation that the test cases comprising this
20 * suite are correct or are an accurate representation of any standard.
22 * In no event shall IBM be liable to any party for direct, indirect, special
23 * incidental, or consequential damage arising out of the use of this software
24 * even if IBM Corp. has been advised of the possibility of such damage.
26 * IBM CORP. SPECIFICALLY DISCLAIMS ANY WARRANTIES INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS AND IBM
29 * CORP. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
30 * ENHANCEMENTS, OR MODIFICATIONS.
31 * ***************************************************************************
33 static int ibm_test(int rank, int size)
38 int root = 0, i, j, k;
42 for (j = 1; j <= MAXLEN; j *= 10) {
43 for (i = 0; i < j; i++)
46 MPI_Allreduce(out, in, j, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
47 MPI_Barrier(MPI_COMM_WORLD);
50 for (k = 0; k < j; k++) {
51 if (in[k] != k * size) {
52 printf("bad answer (%d) at index %d of %d (should be %d)", in[k],
66 int main(int argc, char **argv)
71 MPI_Init(&argc, &argv);
72 MPI_Comm_size(MPI_COMM_WORLD, &size);
73 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
77 printf("** IBM Test Result: ... \n");
78 if (!ibm_test(rank, size))
79 printf("\t[%d] failed.\n", rank);
81 printf("\t[%d] ok.\n", rank);