Writing Parallel Code
6-11
Optimizing Assembly Code via Linear Assembly
accumulates the total of the results from the multiply (MPYSP) instruction. The
subtract (SUB) instruction decrements the loop counter.
An additional instruction is included to execute the branch back to the top of
the loop. The branch (B) instruction is conditional on the loop counter, A1, and
executes only until A1 is 0.
6.3.3
Linear Assembly Resource Allocation
The following rules affect the assignment of functional units for Example 6–7
and Example 6–8 (shown in the third column of each example):
-
Load (LDH and LDW) instructions must use a .D unit.
-
Multiply (MPY and MPYSP) instructions must use a .M unit.
-
Add (ADD and ADDSP) instructions use a .L unit.
-
Subtract (SUB) instructions use a .S unit.
-
Branch (B) instructions must use a .S unit.
Note:
The ADD and SUB can be on the .S, .L, or .D units; however, for Example 6–7
and Example 6–8, they are assigned as listed above.
The ADDSP instruction in Example 6–8 must use a .L unit.
6.3.4
Drawing a Dependency Graph
Dependency graphs can help analyze loops by showing the flow of instruc-
tions and data in an algorithm. These graphs also show how instructions
depend on one another. The following terms are used in defining a depen-
dency graph.
-
A
node is a point on a dependency graph with one or more data paths
flowing in and/or out.
-
The
path shows the flow of data between nodes. The numbers beside
each path represent the number of cycles required to complete the instruc-
tion.
-
An instruction that writes to a variable is referred to as a parent instruction
and defines a
parent node.
-
An instruction that reads a variable written by a parent instruction is re-
ferred to as its child and defines a
child node.