Lecture 17 PDC BCS 6EF SMI Spring 2025
Lecture 17 PDC BCS 6EF SMI Spring 2025
CS3006 (BCS-6E/6F)
Lecture 17
Instructor: Dr. Syed Mohammad Irteza
Assistant Professor, FAST School of Computing
NUCES Lahore
24 March, 2025
Previous Lecture
• Basic Communication Operations
• Scatter
• Gather
• Circular q-shift
• All Operations
• Across hypercube
• Across 2-D ring
• Across 4*4 mesh
• Across balanced binary tree
2
A more in-depth look
• Algorithms of these operations
3
1.
2.
procedure ONE_TO_ALL_BC(d, my_id, X)
begin One-to-All Broadcast
3. mask := 2d - 1; /* Set all d bits of mask to 1 */
4. for i := d - 1 downto 0 do /* Outer loop */
5. mask := mask XOR 2i; /* Set bit i of mask to 0 */
6. if (my_id AND mask) = 0 then /* If lower i bits of my_id are 0 */
7. if (my_id AND 2i) = 0 then
8. msg_destination := my_id XOR 2i;
9. send X to msg_destination;
10. else
(6) my_id AND mask==0 → if I will be in
11. msg_source := my_id XOR 2i; communication in this step (if my i bits are zero)
12. receive X from msg_source;
13. endelse; (7) my_id AND 2i == 0 → if I’m the sender of
message (if my i+1th bit is 0)
14. endif;
15. endfor; (8) XOR-ing my_id with 2i gives my partner in the ith
16. end ONE_TO_ALL_BC phase of the algorithm
Algorithm 4.1 One-to-all broadcast of a message X from node 0 of a d-dimensional p-node hypercube
(d = log p). AND and XOR are bitwise logical-and and exclusive-or operations, respectively.
4
1.
2.
procedure GENERAL_ONE_TO_ALL_BC(d, my_id, source, X)
begin
One-to-All Broadcast:
3.
4.
my_virtual id := my_id XOR source;
mask := 2d - 1;
Generic Form
5. for i := d - 1 downto 0 do /* Outer loop */
6. mask := mask XOR 2i; /* Set bit i of mask to 0 */ source XOR source makes source→ zero and
7. if (my_virtual_id AND mask) = 0 then similarly maps other according to the source
8. if (my_virtual_id AND 2i) = 0 then
9. virtual_dest := my_virtual_id XOR 2i;
10. send X to (virtual_dest XOR source);
/* Convert virtual_dest to the label of the physical destination */
11. else
12. virtual_source := my_virtual_id XOR 2i;
13. receive X from (virtual_source XOR source);
/* Convert virtual_source to the label of the physical source */
14. endelse;
15. endfor;
16. end GENERAL_ONE_TO_ALL_BC
Algorithm 4.3 Single-node accumulation on a d-dimensional hypercube. Each node contributes a message X
containing m words, and node 0 is the destination of the sum. The AND and XOR operations are bitwise
6
logical operations.
Basic Communication Operations
(One-to-All Broadcast and All-to-One Reduction)
• Cost Estimation
• Broadcast needs log(p) point-to-point simple message transfer steps.
• Message size of each transfer is m
• Time for each of the transfers is: 𝒕𝒔 + 𝒎𝒕𝒘
7
All-to-All Broadcast and All-to-All Reduction
8
All-to-All Broadcast
• A generalization of one-to-all broadcast.
• Every process broadcasts an m-word message.
• The broadcast-message for each of the processes can be different from others
All-to-All Reduction
• Dual of all-to-all broadcast
• Each node is the destination of an all-to-one reduction out of total P
reductions.
All-to-All Broadcast and All-to-All Reduction
9
This will result 𝑝(log 𝑝 (𝑡𝑠 + 𝑚𝑡𝑤 )) Solution: It is possible to use the communication links in the interconnection
network more efficiently by performing all p one-to-all broadcasts
communication time.
simultaneously so that all messages traversing the same path at the same
time are concatenated into a single message whose size is the sum of the sizes
Solution? of individual messages.
All-to-All Broadcast and
All-to-All Reduction
Log p steps