Write a code that performs a circular sum of the tasks' ranks. Let A be a float initialized to the rank of the task, and B a float used as a buffer for the receive call. Then, let SUM be a variable for storing the partial sum. The code should execute a series of send/receive calls, and, at each step:
SUM is updated with the just received buffer B;
The following figure represents what the code should do
At the end of the execution, all the processes will have stored in their variable SUM the sum of all the ranks.
I am proc 0 and sum = 6.00 I am proc 1 and sum = 6.00 I am proc 2 and sum = 6.00 I am proc 3 and sum = 6.00
HINTS: |
|
C |
|
MPI_SENDRECV |
|
MPI_INIT |
|
MPI_COMM_SIZE | |
MPI_COMM_RANK |
|
MPI_FINALIZE |
|
|
|
MPI_SENDRECV |
|
MPI_INIT |
|
MPI_COMM_SIZE |
MPI_COMM_SIZE(COMM, SIZE, IERROR) |
MPI_COMM_RANK |
MPI_COMM_RANK(COMM, RANK, IERROR) |
MPI_FINALIZE |