Feature request: loopy.alias_temporaries should be able to alias group of variables to a single base storage.
For a kernel defined as --
0<=i<10 and 0<=j<20:
<> tmp_0[i] = 2*x[i]
<> tmp_1[i] = 4*x[i]
y[i] = y[i] + tmp_0[i] + tmp_1[i]
<> tmp_2[j] = 6*x[j] + y[j//2]
z[j] = z[j] + tmp_2[j]
(seq_deps=True)
As of now there is no transformation to enforce a single base storage for all the temporary variables tmp_0, tmp_1, tmp_2
as there is a usage conflict between tmp_0
and tmp_1
. However, loopy.alias_temporaries
could be extended to take in arguments as kernel = lp.alias_temporaries(kernel, [('tmp_0', 'tmp_1'), ('tmp_2',)])
i.e. takes in a list of variable groups with the condition that there is no inter-group conflict. The code generated should be--
double base_storage[20];
double* const tmp_0 = base_storage;
double* const tmp_1 = base_storage+10;
double* const tmp_2 = base_storage;