Writing Parallel Code
6-12
Use the following steps to draw a dependency graph:
1) Define the nodes based on the variables accessed by the instructions.
2) Define the data paths that show the flow of data between nodes.
3) Add the instructions and the latencies.
4) Add the functional units.
6.3.4.1
Fixed-Point Dot Product
Figure 6–1 shows the dependency graph for the fixed-point dot product
assembly instructions shown in Example 6–7 and their corresponding register
allocations.
Figure 6–1. Dependency Graph of Fixed-Point Dot Product
ai
bi
1
2
5
5
SUB
ADD
MPY
LDH
LDH
pi
sum
1
B
cntr
LOOP
1
(A2)
(A5)
(A6)
(A7)
(A1)
.M1
.L1
.D1
.D1
.S1
.S1
Number of cycles
required to complete
an instruction
Variable
being
written
Instruction
mnemonic
Functional
unit
Register
allocation
-
The two LDH instructions, which write the values of ai and bi, are parents
of the MPY instruction. It takes five cycles for the parent (LDH) instruction
to complete. Therefore, if LDH is scheduled on cycle i, then its child (MPY)
cannot be scheduled until cycle i + 5.
-
The MPY instruction, which writes the product pi, is the parent of the ADD
instruction. The MPY instruction takes two cycles to complete.
-
The ADD instruction adds pi (the result of the MPY) to sum. The output of
the ADD instruction feeds back to become an input on the next iteration
and, thus, creates a
loop carry path. (See section 6.7 on page 6-77 for
more information on loop carry paths.)