precompute_v2
The previous precompute could not handle if there is dependencies between substitutions. Of course one could traverse in backwards dependency pattern of the substitutions and achieve the program logic. But finding substittutions dependencies become moderately difficult in complicated kernels, especially when the dependencies between the instructions are linked by instructions in between them. Like:
subst1[j] := sum(i, a[i, j])
<>tmp[j] = 2*subst1[j]
subst2[j] := sum(i_1, tmp[j]*b[i_1, j])
For the above kernel the correct precomputing order is subst1 -> subst2
. But imagine this if there are a dozen of substitutions and even writing something for a user to figure out the dependency order is a difficult task, as the user would need to scan through the instructions as well as substitutions.
Q. If this works, why precompute_v2
, why not make changes to precompute
itself.
This version does not "conserve" arguments of the substitutions. For example if I would do lp.precompute_v2(knl, 'subst2', 'j')
. In the above kernel. Then the subst1
gets changed as subst1[j_0] := sum(i, a[i, j_0])
, and this might hurt the existing style of precompute in various implementations and tests. Hence currently giving it a different name.