- Source: Broadcast (parallel pattern)
Broadcast is a collective communication primitive in parallel programming to distribute programming instructions or data to nodes in a cluster. It is the reverse operation of reduction. The broadcast operation is widely used in parallel algorithms, such as matrix-vector multiplication, Gaussian elimination and shortest paths.
The Message Passing Interface implements broadcast in MPI_Bcast.
Definition
A message
M
[
1..
m
]
{\displaystyle M[1..m]}
of length
m
{\displaystyle m}
should be distributed from one node to all other
p
−
1
{\displaystyle p-1}
nodes.
T
byte
{\displaystyle T_{\text{byte}}}
is the time it takes to send one byte.
T
start
{\displaystyle T_{\text{start}}}
is the time it takes for a message to travel to another node, independent of its length.
Therefore, the time to send a package from one node to another is
t
=
s
i
z
e
×
T
byte
+
T
start
{\displaystyle t=\mathrm {size} \times T_{\text{byte}}+T_{\text{start}}}
.
p
{\displaystyle p}
is the number of nodes and the number of processors.
Binomial Tree Broadcast
With Binomial Tree Broadcast the whole message is sent at once. Each node that has already received the message sends it on further. This grows exponentially as each time step the amount of sending nodes is doubled. The algorithm is ideal for short messages but falls short with longer ones as during the time when the first transfer happens only one node is busy.
Sending a message to all nodes takes
log
2
(
p
)
t
{\displaystyle \log _{2}(p)t}
time which results in a runtime of
log
2
(
p
)
(
m
T
byte
+
T
start
)
{\displaystyle \log _{2}(p)(mT_{\text{byte}}+T_{\text{start}})}
Linear Pipeline Broadcast
The message is split up into
k
{\displaystyle k}
packages and sent piecewise from node
n
{\displaystyle n}
to node
n
+
1
{\displaystyle n+1}
. The time needed to distribute the first message piece is
p
t
=
m
k
T
byte
+
T
start
{\textstyle pt={\frac {m}{k}}T_{\text{byte}}+T_{\text{start}}}
whereby
t
{\displaystyle t}
is the time needed to send a package from one processor to another.
Sending a whole message takes
(
p
+
k
)
(
m
T
byte
k
+
T
start
)
=
(
p
+
k
)
t
=
p
t
+
k
t
{\displaystyle (p+k)\left({\frac {mT_{\text{byte}}}{k}}+T_{\text{start}}\right)=(p+k)t=pt+kt}
.
Optimal is to choose
k
=
m
(
p
−
2
)
T
byte
T
start
{\displaystyle k={\sqrt {\frac {m(p-2)T_{\text{byte}}}{T_{\text{start}}}}}}
resulting in a runtime of approximately
m
T
byte
+
p
T
start
+
m
p
T
start
T
byte
{\displaystyle mT_{\text{byte}}+pT_{\text{start}}+{\sqrt {mpT_{\text{start}}T_{\text{byte}}}}}
The run time is dependent on not only message length but also the number of processors that play roles. This approach shines when the length of the message is much larger than the amount of processors.
Pipelined Binary Tree Broadcast
This algorithm combines Binomial Tree Broadcast and Linear Pipeline Broadcast, which makes the algorithm work well for both short and long messages. The aim is to have as many nodes work as possible while maintaining the ability to send short messages quickly. A good approach is to use Fibonacci trees for splitting up the tree, which are a good choice as a message cannot be sent to both children at the same time. This results in a binary tree structure.
We will assume in the following that communication is full-duplex. The Fibonacci tree structure has a depth of about
d
≈
log
Φ
(
p
)
{\displaystyle d\approx \log _{\Phi }(p)}
whereby
Φ
=
1
+
5
2
{\displaystyle \Phi ={\frac {1+{\sqrt {5}}}{2}}}
the golden ratio.
The resulting runtime is
(
m
k
T
byte
+
T
start
)
(
d
+
2
k
−
2
)
{\textstyle ({\frac {m}{k}}T_{\text{byte}}+T_{\text{start}})(d+2k-2)}
. Optimal is
k
=
n
(
d
−
2
)
T
byte
3
T
start
{\displaystyle k={\sqrt {\frac {n(d-2)T_{\text{byte}}}{3T_{\text{start}}}}}}
.
This results in a runtime of
2
m
T
byte
+
T
start
log
Φ
(
p
)
+
2
m
log
Φ
(
p
)
T
start
T
byte
{\displaystyle 2mT_{\text{byte}}+T_{\text{start}}\log _{\Phi }(p)+{\sqrt {2m\log _{\Phi }(p)T_{\text{start}}T_{\text{byte}}}}}
.
Two Tree Broadcast (23-Broadcast)
= Definition
=This algorithm aims to improve on some disadvantages of tree structure models with pipelines. Normally in tree structure models with pipelines (see above methods), leaves receive just their data and cannot contribute to send and spread data.
The algorithm concurrently uses two binary trees to communicate over. Those trees will be called tree A and B. Structurally in binary trees there are relatively more leave nodes than inner nodes. Basic Idea of this algorithm is to make a leaf node of tree A be an inner node of tree B. It has also the same technical function in opposite side from B to A tree. This means, two packets are sent and received by inner nodes and leaves in different steps.
= Tree construction
=The number of steps needed to construct two parallel-working binary trees is dependent on the amount of processors. Like with other structures one processor can is the root node who sends messages to two trees. It is not necessary to set a root node, because it is not hard to recognize that the direction of sending messages in binary tree is normally top to bottom. There is no limitation on the number of processors to build two binary trees. Let the height of the combined tree be h = ⌈log(p + 2)⌉. Tree A and B can have a height of
h
−
1
{\displaystyle h-1}
. Especially, if the number of processors correspond to
p
=
2
h
−
1
{\displaystyle p=2^{h}-1}
, we can make both sides trees and a root node.
To construct this model efficiently and easily with a fully built tree, we can use two methods called "Shifting" and "Mirroring" to get second tree. Let assume tree A is already modeled and tree B is supposed to be constructed based on tree A. We assume that we have
p
{\displaystyle p}
processors ordered from 0 to
p
−
1
{\displaystyle p-1}
.
Shifting
The "Shifting" method, first copies tree A and moves every node one position to the left to get tree B. The node, which will be located on -1, becomes a child of processor
p
−
2
{\displaystyle p-2}
.
Mirroring
"Mirroring" is ideal for an even number of processors. With this method tree B can be more easily constructed by tree A, because there are no structural transformations in order to create the new tree. In addition, a symmetric process makes this approach simple. This method can also handle an odd number of processors, in this case, we can set processor
p
−
1
{\displaystyle p-1}
as root node for both trees. For the remaining processors "Mirroring" can be used.
= Coloring
=We need to find a schedule in order to make sure that no processor has to send or receive two messages from two trees in a step. The edge, is a communication connection to connect two nodes, and can be labelled as either 0 or 1 to make sure that every processor can alternate between 0 and 1-labelled edges. The edges of A and B can be colored with two colors (0 and 1) such that
no processor is connected to its parent nodes in A and B using edges of the same color-
no processor is connected to its children nodes in A or B using edges of the same color.
In every even step the edges with 0 are activated and edges with 1 are activated in every odd step.
= Time complexity
=In this case the number of packet k is divided in half for each tree. Both trees are working together the total number of packets
k
=
k
/
2
+
k
/
2
{\displaystyle k=k/2+k/2}
(upper tree + bottom tree)
In each binary tree sending a message to another nodes takes
2
i
{\displaystyle 2i}
steps until a processor has at least a packet in step
i
{\displaystyle i}
. Therefore, we can calculate all steps as
d
:=
log
2
(
p
+
1
)
⇒
log
2
(
p
+
1
)
≈
log
2
(
p
)
{\displaystyle d:=\log _{2}(p+1)\Rightarrow \log _{2}(p+1)\approx \log _{2}(p)}
.
The resulting run time is
T
(
m
,
p
,
k
)
≈
(
m
k
T
byte
+
T
start
)
(
2
d
+
k
−
1
)
{\textstyle T(m,p,k)\approx ({\frac {m}{k}}T_{\text{byte}}+T_{\text{start}})(2d+k-1)}
. (Optimal
k
=
m
(
2
d
−
1
)
T
byte
/
T
start
{\textstyle k={\sqrt {{m(2d-1)T_{\text{byte}}}/{T_{\text{start}}}}}}
)
This results in a run time of
T
(
m
,
p
)
≈
m
T
byte
+
T
start
⋅
2
log
2
(
p
)
+
m
⋅
2
log
2
(
p
)
T
start
T
byte
{\displaystyle T(m,p)\approx mT_{\text{byte}}+T_{\text{start}}\cdot 2\log _{2}(p)+{\sqrt {m\cdot 2\log _{2}(p)T_{\text{start}}T_{\text{byte}}}}}
.
ESBT-Broadcasting (Edge-disjoint Spanning Binomial Trees)
In this section, another broadcasting algorithm with an underlying telephone communication model will be introduced. A Hypercube creates network system with
p
=
2
d
(
d
=
0
,
1
,
2
,
3
,
.
.
.
)
{\displaystyle p=2^{d}(d=0,1,2,3,...)}
. Every node is represented by binary
0
,
1
{\displaystyle {0,1}}
depending on the number of dimensions. Fundamentally ESBT(Edge-disjoint Spanning Binomial Trees) is based on hypercube graphs, pipelining(
m
{\displaystyle m}
messages are divided by
k
{\displaystyle k}
packets) and binomial trees. The Processor
0
d
{\displaystyle 0^{d}}
cyclically spreads packets to roots of ESBTs. The roots of ESBTs broadcast data with binomial tree. To leave all of
k
{\displaystyle k}
from
p
0
{\displaystyle p_{0}}
,
k
{\displaystyle k}
steps are required, because all packets are distributed by
p
0
{\displaystyle p_{0}}
. It takes another d steps until the last leaf node receives the packet. In total
d
+
k
{\displaystyle d+k}
steps are necessary to broadcast
m
{\displaystyle m}
message through ESBT.
The resulting run time is
T
(
m
,
p
,
k
)
=
(
m
k
T
byte
+
T
start
)
(
k
+
d
)
{\textstyle T(m,p,k)=({\frac {m}{k}}T_{\text{byte}}+T_{\text{start}})(k+d)}
.
(
k
=
m
d
T
byte
/
T
start
)
{\textstyle (k={\sqrt {{mdT_{\text{byte}}}/{T_{\text{start}}}}})}
.
This results in a run time of
T
(
m
,
p
)
:=
m
T
byte
+
d
T
start
+
m
d
T
start
T
byte
{\displaystyle T(m,p):=mT_{\text{byte}}+dT_{\text{start}}+{\sqrt {mdT_{\text{start}}T_{\text{byte}}}}}
.
See also
Reduction operator
References
Kata Kunci Pencarian:
- Broadcast (parallel pattern)
- Broadcast (disambiguation)
- Collective operation
- Reduction operator
- Readers–writer lock
- Publish–subscribe pattern
- Loop antenna
- TP
- Algorithmic skeleton
- Automatic parallelization