Task Parallelism and Manager-Worker Parallelism Flashcards
What is the purpose of MPI_ANY_SOURCE
and MPI_ANY_TAG
?
-
MPI_ANY_SOURCE
allows receiving from an unspecified source -
MPI_ANY_TAG
allows receiving from an unspecified tag
Why define a new communicator instead of using MPI_COMM_WORLD
?
To limit communication to a subset of processes.
What are the steps to create a new communicator?
- Get world group handle (
MPI_Comm_group
) - Create a new group (
MPI_Group_incl
orMPI_Group_excl
) - Create a communicator (
MPI_Comm_create
) - Get rank in new communicator (
MPI_Comm_rank
) - Perform communication
- Free the group and communicator (
MPI_Group_free
,MPI_Comm_free
)
What does MPI_Group_incl
do?
Creates a new group including specific processes.
What does MPI_Group_excl
do?
Creates a new group excluding specific processes.
What does MPI_Group_union
do?
Combines two groups, keeping all unique members.
What does MPI_Group_intersection
do?
Creates a group containing only common members.
What does MPI_Group_difference
do?
Creates a group containing processes in the first group but not in the second.
How does the Manager-Worker model work in MPI?
- The manager assigns work to worker processes 2. Workers request more work when finished
What function is used to request work in the Mandelbrot Manager-Worker model?
MPI_Recv(&nextProc, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
How do workers signal completion?
Workers send a request, receive a task, and exit if the received task is a special end flag.
What are two OpenMP work-sharing constructs besides parallel for
? When is each used?
-
sections
- When there are multiple, independent, tasks that can execute concurrently -
single
- Ensures that only thread executes a block of code
When are OpenMP tasks useful?
For recursive algorithms and traversing linked lists.
How does OpenMP handle tasks?
One thread generates tasks, and other threads execute them.
What OpenMP directive ensures only one thread generates tasks?
#pragma omp single
When using a single
construct, which thread executes the code?
It can be any thread