1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2001 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
10 #define MAX_PROCESSES 10
12 int main( int argc, char **argv )
15 int table[MAX_PROCESSES][MAX_PROCESSES];
16 int row[MAX_PROCESSES];
19 int displs[MAX_PROCESSES];
20 int send_counts[MAX_PROCESSES];
22 MTest_Init( &argc, &argv );
23 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
24 MPI_Comm_size( MPI_COMM_WORLD, &size );
26 /* A maximum of MAX_PROCESSES processes can participate */
27 if ( size > MAX_PROCESSES ) participants = MAX_PROCESSES;
28 else participants = size;
29 if ( (rank < participants) ) {
30 int recv_count = MAX_PROCESSES;
32 /* If I'm the root (process 0), then fill out the big table */
33 /* and setup send_counts and displs arrays */
35 for ( i=0; i<participants; i++) {
36 send_counts[i] = recv_count;
37 displs[i] = i * MAX_PROCESSES;
38 for ( j=0; j<MAX_PROCESSES; j++ )
42 /* Scatter the big table to everybody's little table */
43 MPI_Scatterv(&table[0][0], send_counts, displs, MPI_INT,
44 &row[0] , recv_count, MPI_INT, 0, MPI_COMM_WORLD);
46 /* Now see if our row looks right */
47 for (i=0; i<MAX_PROCESSES; i++)
48 if ( row[i] != i+rank ) errors++;
51 MTest_Finalize( errors );
53 return MTestReturnValue( errors );