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!

2 things.

  1. Looks to be a duplicate of https://www.daniweb.com/programming/threads/503211/process-rank-in-mpic-code
  2. It seems you have 16 questions you want answers to. If you want these values it looks like you could run the code and get the numbers.

https://en.wikipedia.org/wiki/Message_Passing_Interface seems to lead me to more documents, archives, and how to make comments on MPI. Given the possible esoteric area you want to discuss I'd seek out a forum on MPI.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.