Programming Taskbook


E-mail:

Password:

User registration   Restore password

Russian

SFedU

1100 training tasks on programming

©  M. E. Abramyan (Southern Federal University), 1998–2018

 

PT for MPI-2 | Task groups | MPI1Proc

PrevNext


Processes and their ranks

MPI1Proc1. Input a real number X in each process of the MPI_COMM_WORLD communicator and output its opposite value −X. Also output the total number of processes in the master process (that is, a rank-zero process). For data input and output use the input-output stream pt. Also output the value −X in the debug section using the Show function, which is also defined in the taskbook.

MPI1Proc2. Input an integer A in each process of the MPI_COMM_WORLD communicator and output doubled value of A. Also output the total number of processes in the master process (that is, a rank-zero process). For data input and output use the input-output stream pt. In the master process, duplicate the data output in the debug section by displaying on separate lines the doubled value of A and the total number of processes (use two calls of the ShowLine function, which is defined in the taskbook along with the Show function).

MPI1Proc3. Input a real number X and output its opposite value in the master process. Also output the rank of slave processes (which are processes whose rank is greater than 0); the rank of each process should be output in the process of this rank. In addition, duplicate the data output in the debug section by displaying the value of −X with the "-X=" comment and the rank values with the "rank=" comments (use the Show function calls with two parameters).

MPI1Proc4. Input one integer in processes with even rank (inclusive of the master process) and output the doubled value of input number. Do not perform any action in processes with odd rank.

MPI1Proc5. Input one integer in processes with even rank (including the master process), input one real number in processes with odd rank. Output doubled value of input number in each process.

MPI1Proc6. Input one integer in slave processes with even rank, input one real number in processes with odd rank. Output doubled value of input number in each slave process. Do not perform any action in the master process.

MPI1Proc7. An integer N (> 0) and a sequence of N real numbers are given in each process with even rank (including the master process). Output the sum of given numbers in each process. Do not perform any action in processes with odd rank.

MPI1Proc8. An integer N (> 0) and a sequence of N real numbers are given in each process. Output the sum of given numbers in each process with even rank (including the master process), output the average of given numbers in each process with odd rank.

MPI1Proc9. An integer N (> 0) and a sequence of N real numbers are given in each process. Output the sum of given numbers in each slave process with even rank, output the average of given numbers in each process with odd rank, output the product of given numbers in the master process.

MPI1Proc10. An integer N (> 0) and a sequence of N numbers are given in each process. The sequence contains real numbers in the slave processes with odd rank (1, 3, …) and integers in the slave processes with even rank (2, 4 …). The type of elements in the master process depends on the number of processes K: if K is an odd number then the sequence contains integers otherwise the sequence contains real numbers. Output the minimal element of the given sequence in each even-rank process (including the master process), output the maximal element of the given sequence in each odd-rank process.


PrevNext

 

  @Mail.ru

Designed by
M. E. Abramyan and V. N. Braguilevsky

Last revised:
06.05.2018