Just started learning MPI and all, need a little help with it though.

    int main( int argc, char *argv[] ) {

        int rank, n;

        MPI_Init( &argc, &argv );
        MPI_Comm_size( MPI_COMM_WORLD, &n );
        MPI_Comm_rank( MPI_COMM_WORLD, &rank );

        int a = rank;
        int b = 0;
         int C[n], D[n];

        for ( int i = 0; i < n; i++ ) {
            C[i] = rank + i;
            D[i] = 0;
         }

        < MPI CODE >

        MPI_Finalize( );
        return 0;
    }

Suppose n = 4. There are two integer variables a and b and two integer arrays C[n] and D[n].
What is the value of b in MPI_Allreduce(&a, &b, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); at process rank 0, 1, 2, 3?
What is the value of D in MPI_Gather(&a, 1, MPI_INT, D, 1, MPI_INT, 2, MPI_COMM_WORLD); at process rank 0, 1, 2, 3?
What is the value of C in MPI_Scatter(C, 1, MPI_INT, &b, 1, MPI_INT, 2, MPI_COMM_WORLD); at process rank 0, 1, 2, 3?
What is the value of b in MPI_Scan(&a, &b, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD); at process rank 0, 1, 2, 3?

Any help with this would be great!

This article has been dead for over six months. Start a new discussion instead.