~ubuntu-branches/ubuntu/raring/simgrid/raring

« back to all changes in this revision

Viewing changes to teshsuite/smpi/mpich-test/coll/coll8.c

  • Committer: Package Import Robot
  • Author(s): Martin Quinson
  • Date: 2013-01-31 00:24:51 UTC
  • mfrom: (10.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20130131002451-krejhf7w7h24lpsc
Tags: 3.9~rc1-1
* New upstream release: the "Grasgory" release. Major changes:
  - Gras was completely removed from this version.
  - Documentation reorganization to ease browsing it.
  - New default value for the TCP_gamma parameter: 4MiB

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "mpi.h"
 
2
#include <stdio.h>
 
3
#include "test.h"
 
4
 
 
5
int main( int argc, char **argv )
 
6
{
 
7
    int              rank, size, i;
 
8
    int              data;
 
9
    int              errors=0;
 
10
    int              result = -100;
 
11
    int              correct_result;
 
12
 
 
13
    MPI_Init( &argc, &argv );
 
14
    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
 
15
    MPI_Comm_size( MPI_COMM_WORLD, &size );
 
16
 
 
17
    data = rank;
 
18
 
 
19
    MPI_Reduce ( &data, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD );
 
20
    MPI_Bcast  ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD );
 
21
    correct_result = 0;
 
22
    for(i=0;i<size;i++) 
 
23
      correct_result += i;
 
24
    if (result != correct_result) errors++;
 
25
 
 
26
    MPI_Reduce ( &data, &result, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD );
 
27
    MPI_Bcast  ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD );
 
28
    if (result != 0) errors++;
 
29
 
 
30
    MPI_Reduce ( &data, &result, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD );
 
31
    MPI_Bcast  ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD );
 
32
    if (result != (size-1)) errors++;
 
33
 
 
34
    Test_Waitforall( );
 
35
    MPI_Finalize();
 
36
    if (errors)
 
37
      printf( "[%d] done with ERRORS(%d)!\n", rank, errors );
 
38
    return errors;
 
39
}