Programming Taskbook


E-mail:

Password:

User registration   Restore password

Russian

SFedU SMBU

1100 training tasks on programming

©  M. E. Abramyan (Southern Federal University, Shenzhen MSU-BIT University), 1998–2024

 

PT for MPI-2 | Task groups | MPI3Coll

PrevNext


Collective communications

Collective data transfer

MPI3Coll1°. An integer is given in the master process. Send the given integer to all slave processes using the MPI_Bcast function. Output the received integer in all slave processes.

MPI3Coll2°. A sequence of 5 real numbers is given in the master process. Send the given sequence to all slave processes using the MPI_Bcast function. Output received data in all slave processes.

MPI3Coll3°. A real number is given in each process. Send the given numbers to master process using the MPI_Gather function. Output received numbers in the master process in ascending order of ranks of sending processes (starting with the number that is given in the master process).

MPI3Coll4°. A sequence of 5 integers is given in each process. Send the given sequences to master process using the MPI_Gather function. Output received data in the master process in ascending order of ranks of sending processes (starting with the sequence that is given in the master process).

MPI3Coll5°. A sequence of R + 2 integers is given in each process; the integer R is equal to rank of the process (there are given 2 integers in the process 0, 3 integers in the process 1, and so on). Send the given sequences to master process using the MPI_Gatherv function. Output received data in the master process in ascending order of ranks of sending processes (starting with the sequence that is given in the master process).

MPI3Coll6°. A sequence of K real numbers is given in the master process; K is the number of processes. Send one element of given sequence to each process (including the master process) using the MPI_Scatter function. Output the received number in each process.

MPI3Coll7°. A sequence of 3K real numbers is given in the master process, K is the number of processes. Send three elements of given sequence to each process (including the master process) using the MPI_Scatter function. Output received numbers in each process.

MPI3Coll8°. A sequence of K real numbers is given in the master process; K is the number of processes. Using the MPI_Scatterv function, send elements of given sequence to all processes as follows: the first element should be sent to the process K − 1, the second element should be sent to the process K − 2, …, the last element should be sent to the process 0). Output the received number in each process.

MPI3Coll9°. A sequence of K(K + 3)/2 integers is given in the master process; K is the number of processes. Using the MPI_Scatterv function, send R + 2 elements of given sequence to the process of rank R, where R = 0, …, K − 1: the first two elements should be sent to the process 0, the next three elements should be sent to the process 1, and so on. Output received numbers in each process.

MPI3Coll10°. A sequence of K + 2 real numbers is given in the master process; K is the number of processes. Using the MPI_Scatterv function, send three elements of given sequence to each process as follows: elements with order numbers in the range R + 1 to R + 3 should be sent to the process of rank R, where R = 0, …, K − 1 (the initial three elements should be sent to the process 0; the second, the third, and the fourth element should be sent to the process 1, and so on). Output received numbers in each process.

MPI3Coll11°. A real number is given in each process. Send given numbers to all process using the MPI_Allgather function. Output received data in each process in ascending order of ranks of sending processes (including the number received from itself).

MPI3Coll12°. Four integers are given in each process. Send given integers to all processes using the MPI_Allgather function. Output received data in each process in ascending order of ranks of sending processes (including the numbers received from itself).

MPI3Coll13°. A sequence of R + 2 integers is given in each process; R is the rank of process (that is, two integers are given in the process 0, three integers are given in the process 1, and so on). Send given integers to all processes using the MPI_Allgatherv function. Output received data in each process in ascending order of ranks of sending processes (including the numbers received from itself).

MPI3Coll14°. A sequence of K real numbers is given in each process; K is the number of processes. Using the MPI_Alltoall function, send one element of each given sequence to each process as follows: first element of each sequence should be sent to the process 0, second element of each sequence should be sent to the process 1, and so on. Output received numbers in each process in ascending order of ranks of sending processes (including the number received from itself).

MPI3Coll15°. A sequence of 3K integers is given in each process; K is the number of processes. Using the MPI_Alltoall function, send three elements of each given sequence to each process as follows: the initial three elements of each sequence should be sent to the process 0, the next three elements of each sequence should be sent to the process 1, and so on. Output received numbers in each process in ascending order of ranks of sending processes (including the numbers received from itself).

MPI3Coll16°. A sequence of K(K + 1)/2 integers is given in each process; K is the number of processes. Using the MPI_Alltoallv function, send some elements of each given sequence to each process as follows: the first element of each sequence should be sent to the process 0, the next two elements of each sequence should be sent to the process 1, the next three elements of each sequence should be sent to the process 2, and so on. Output received numbers in each process in ascending order of ranks of sending processes (including the numbers received from itself).

MPI3Coll17°. A sequence of K + 1 real numbers is given in each process; K is the number of processes. Using the MPI_Alltoallv function, send two elements of each given sequence to each process as follows: the initial two elements of each sequence should be sent to the process 0, the second and the third element of each sequence should be sent to the process 1, …, the last two elements of each sequence should be sent to the last process. Output received numbers in each process in ascending order of ranks of sending processes (including the numbers received from itself).

MPI3Coll18°. A sequence of K + 1 real numbers is given in each process; K is the number of processes. Using the MPI_Alltoallv function, send two elements of each given sequence to each process as follows: the last two elements of each sequence (with the order numbers K + 1 and K) should be sent to the process 0, the elements of each sequence with the order numbers K − 1 and K should be sent to the process 1, …, the initial two elements of each sequence should be sent to the last process. Output received numbers in each process in ascending order of ranks of sending processes (including the numbers received from itself).

Global reduction operations

MPI3Coll19°. A sequence of K + 5 integers is given in each process; K is the number of processes. Find sums of elements of all given sequences with the same order number using the MPI_Reduce function with the MPI_SUM operation. Output received sums in the master process.

MPI3Coll20°. A sequence of K + 5 real numbers is given in each process; K is the number of processes. Find the minimal value among the elements of all given sequences with the same order number using the MPI_Reduce function with the MPI_MIN operation. Output received minimal values in the master process.

MPI3Coll21°. A sequence of K + 5 integers is given in each process; K is the number of processes. Using the MPI_Reduce function with the MPI_MAXLOC operation, find the maximal value among the elements of all given sequences with the same order number and also the rank of process that contains this maximal value. Output received maximal values and ranks in the master process (first, output all maximal values, then output all corresponding ranks).

MPI3Coll22°. A sequence of K + 5 real numbers is given in each process; K is the number of processes. Find products of elements of all given sequences with the same order number using the MPI_Allreduce function with the MPI_PROD operation. Output received products in each process.

MPI3Coll23°. A sequence of K + 5 real numbers is given in each process; K is the number of processes. Using the MPI_Allreduce function with the MPI_MINLOC operation, find the minimal value among the elements of all given sequences with the same order number and also the rank of process that contains this minimal value. Output received minimal values in the master process and output corresponding ranks in each slave process.

MPI3Coll24°. A sequence of K integers is given in each process; K is the number of processes. Using the MPI_Reduce_scatter function, find sums of elements of all given sequences with the same order number and send one sum to each process as follows: the first sum should be sent to the process 0, the second sum should be sent to the process 1, and so on. Output the received sum in each process.

MPI3Coll25°. A sequence of 2K real numbers is given in each process; K is the number of processes. Using the MPI_Reduce_scatter function, find maximal values among elements of all given sequences with the same order number and send two maximal values to each process as follows: the initial two maximums should be sent to the process 0, the next two maximums should be sent to the process 1, and so on. Output received data in each process.

MPI3Coll26°. A sequence of K(K + 3)/2 integers is given in each process; K is the number of processes. Using the MPI_Reduce_scatter function, find minimal values among elements of all given sequences with the same order number and send some minimal values to each process as follows: the initial two minimums should be sent to the process 0, the next three minimums should be sent to the process 1, …, the last K + 1 minimums should be sent to the process K − 1. Output received data in each process.

MPI3Coll27°. A sequence of K + 5 real numbers is given in each process; K is the number of processes. Using the MPI_Scan function, find products of elements of given sequences with the same order number as follows: the products of elements of sequences given in the processes of rank 0, …, R should be found in the process R (R = 0, 1, …, K − 1). Output received data in each process; in particular, products of elements of all given sequences should be output in the process K − 1.

MPI3Coll28°. A sequence of K + 5 integers is given in each process; K is the number of processes. Using the MPI_Scan function, find maximal values among elements of given sequences with the same order number as follows: the maximal values of elements of sequences given in the processes of rank 0, …, R should be found in the process R (R = 0, 1, …, K − 1). Output received data in each process.


PrevNext

 

  Ðåéòèíã@Mail.ru

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

Last revised:
01.01.2024