Because
,
and
expressions only use values already
available on all processors, they are transformed to the argument functions for map
skeletons.
expressions are evaluated along the returns of recursive calls and
the intermediate results for calculating Red results can be used
for the following computations. So,
expressions are transformed to the argument functions
for
operation.
expressions evaluates the accumulation parameters
for all recursive calls. Because they are evaluated propagating the accumulation parameters
along recursive calls and their intermediate results can be also used in next computations,
they are transformed to the argument functions for
operation.
expressions compute the overall result using the results of recursive calls
and the intermediate results from previous computations. So, they are transformed to
the argument functions for reduce.
Argument functions for parallel skeletons are generated in three steps. At first,
recursive calls are replaced with variable tuples so that their results can be
propagated through the formal parameters of the argument functions for
and
skeletons.
And then, expressions of each color are extracted from the input program in a form of assignments to
new variables and the extracted places are replaced with the new variables.
Using these extracted expressions for each color, the argument functions for each skeleton are generated.
When generating argument functions, new variables from the previous colors are added
to the formal parameters so that previous intermediate results can be used.
Resulting parallel program from the inorder function is given in Figure 7.
Because there is neither
nor
computation, the first and second
operations are omitted.
Argument functions for each color are composed of two functions for Leaf and Node constructors.
inorder_R1 and inorder_R2 evaluate the size of each subtree. Sizes of subtrees are propagated
through Rtemp221 and Rtemp222 variables, and
intermediate results are tupled with the current tree size.
inorder_Y1 and inorder_Y2 evaluate the accumulation parameters for all recursions using computed
values from
expressions and the accumulation parameter from the upper node.
inorder_G1 and inorder_G2 functions are used as the argument functions of map skeletons and
inorder_Bk1 and inorder_Bk2 functions evaluate overall results.
The execution time of our parallel program is
with enough processors
where
is the height of the input tree.