Download Parallel Algorithm Design: Task/Channel Model and Parallel Program Design - Prof. Adrian S and more Study notes Computer Science in PDF only on Docsity!
Parallel algorithm design
Task/channel model:
- Computation is split in a set of tasks.
- Each task is a âprocessâ in its own tight: have its program, local memory&private data, and owns a CPU.
- Tasks communicate with each other via âcomm. Channelsâ (source Ă dest). Message sent along a channel (same source Ă same dest)) arrive in the order they have been sent. MPI answers this.
- A receive operation blocks the destination until the message arrives.
Design of parallel programs
Step 1: partitioning Divide the computation into tasks: which can be executed concurrently. How?
a. domain decomposition
- Divide the data into pieces.
- Computations associated with each data piece form the tasks. Example: matrix-vector multiplication:
Task I = now I * vector = element I
b. Functional decomposition
Divide the computational operations into tasks that can be executed concurrently. E.g., Climate modeling.
E.g., filtering in signal processing:
=
Hydrology model
Ocean model
Atmospheric model
Land/surface
FFT: g (^) k = , 1
1 0
ââ^2 / = â
=
N f e â Î â
j ni
in nikjN
Pipeline parallelism possible: Digital signalĂforward FFTĂfilter out DC componentĂinverse FFTĂ????signal
E.g., â
i
f (^) i ( x ) ďźsame data(x), diff. functions
Note: design criteria:
- The number of elementary tasks is an upper bound for the amount of parallelism problems offers. There should be considerately more elementary tasks than CPU (n>>p).
- Tasks should be âorthogonalâ, i.e. have minimum redundant storage and redundant computations.
- Elementary tasks should perform proximately equal amounts of computation.
- The number of tasks should scale up with the size of the problem (this will allow scalability solve efficiently larger problems on larger machines). E.g., n.
Step 2: determine the communication between tasks
Global communication:
- Most of the tasks contribute data needed for the next step of the algorithm. E.g., summation, need all partial results.
Local communication:
- A task needs data from another (or few others) tasks.
- Open channels from the data producer to the data consumer.
Note:
- Communication is needed for the correct flow of data.
- Overload (since not needed by the sequential code).
Criteria:
- Each task performs proximately same amount of communication.
- Each task communicates with its neighbors/rather than global.
- Communication may be performed concurrently.
Step 3: agglomeration
Granularity of our parallel decomposition.
Agglomeration: neighboring tasks
- some messages need not be sent since all data is now in the local memory
- otherwise, many small messages are replaced by few large messages, which is more efficient (since there are fewer startup costs involved)
Example: matrix-vector multiplication.
- Coarser tasks are likely to reuse more of the sequential code, reducing the parallel code time development.
- Likely to reduce redundant computation and redundant data.
Note: Agglomeration should maintain the ability of the algorithm to scale:
- Agglomerated tasks have simpler CPU and comm. needs.
of coarse tasks still increases with problem dimension
- #of tasks >= # of processors.
Step 4: Mapping tasks to physical processors
This is done by the operating system in a centralized multiprocessor.
Goals:
- Utilize completely the computational resources: each CPU has to be busy most of the time. Idle CPUs Ă waste of resources. Local balancing: assigning âequalâ amounts of work to each CPU to avoid CPU finishes too early and remaining idle. The total parallel computation time = time of test CPU that finishes.
- Reduce communication overhead by mapping tasks that communicate a lot on the same (or neighboring) processors.
Processor utilization
- average % of time the CPSâs are busy executing useful computations
- Maximized when the work is evenly distributed.
Interprocessor communication
- Reduced when communication tasks are on the same CPU.
1 processor: zero intercommunication, but worst processer utilization
Note: Mapping should attain a compromise between these conflicting goals. Task mapping can be
- dynamic, reevaluated at each time
Finding the maximum
Max( a0, âŚ, an-1): O(n) sequential complexity.
Note: max is associative operation: Max(a1, a2,a3) = max (a1, max(a2,a3)) = max(max(a1,a2), a3)
Problem: find max entry in a vector. âReductionâ operation: op(vector) Ă scalar
If vector is distributed among processors, we want the final result at P0.
Analysis: a = time to add (max) c = time to send 1 value. T_total = (n/p-1)a + pc + (p-10a ~~ n/pa + p*(a+c)
Alternative strategy;
add
add ⌠add
P0 P1 ⌠Pp-
send
P0 P1 P2 P3 P4 P5 P6 P
add add add add
add add
add