On Mon, Feb 13, 2023 at 11:02:26PM -0800, Kelvin Yang wrote:
> How to compute the bound when it comes to wrapped relation in
> isl_union_pw_qpolynomial?
> For example, I have { [A[i0, i1] -> B[i2, i3, i4, i5]] -> (12 - 4 *
> floor((i1 + i5)/2)) : i0 = 1 and i2 = 0 and i3 = 0 and 0 <= i1 <= 1 and 0
> <= i4 <= 2 and 4 <= i5 <= 5; [A[i0, i1] -> B[i2, i3, i4, i5]] -> (4 * i5 -
> 4 * floor((i1 + i5)/2)) : i0 = 1 and i2 = 0 and i3 = 0 and 0 <= i1 <= 1 and
> 0 <= i4 <= 2 and 0 < i5 <= 3; [A[i0, i1] -> B[i2, i3, i4, i5]] -> ((2 - 2 *
> i1) + 2 * floor((i1)/2)) : i0 = 0 and i2 = 0 and i3 = 0 and i5 = 1 and 0 <=
> i1 <= 1 and 0 <= i4 <= 2; [A[i0, i1] -> B[i2, i3, i4, i5]] -> 2 : i0 = 0
> and i2 = 0 and i3 = 0 and i5 = 2 and 0 <= i1 <= 1 and 0 <= i4 <= 2; [A[i0,
> i1] -> B[i2, i3, i4, i5]] -> (((6 - 2 * i1) - 2 * i5) + 2 * floor((i1 +
> i5)/2)) : i0 = 0 and i2 = 0 and i3 = 0 and 0 <= i1 <= 1 and 0 <= i4 <= 2
> and 3 <= i5 <= 4 }.
> After using isl_union_pw_qpolynomial_bound, I get { A[i0, i1] -> max((3 -
> i1)) : i0 = 0 and 0 <= i1 <= 1; A[i0, i1] -> max((8 - 2 * i1)) : i0 = 1 and
> 0 <= i1 <= 1 }.
> That is, {A[0, 0] -> max(3); A[0, 1] -> max(2); A[1, 0] -> max(8); A[1, 1]
> -> max(6)}.
>
> I have two questions:
> 1. How can I get {max(8)} from the previous output? 8 is greater than
> others.
You could either do the original computation on [[] -> [A[] -> B[]]]
instead of on [A[] -> B[]], or you could perform
a second level bound computation
by calling isl_union_set_apply_union_pw_qpolynomial_fold
(as the first argument, you can take the domain of the second).
This is what the second looks like in iscc, with F the function above:
ub(F);
$0 := ({ A[i0, i1] -> max((3 - i1)) : i0 = 0 and 0 <= i1 <= 1; A[i0, i1] -> max((8 - 2 * i1)) : i0 = 1 and 0 <= i1 <= 1 }, False)
$0(dom $0);
$1 := ({ max(8) }, True)
> 2. Can I enumerate all elements in isl_union_pw_qpolynomial_fold? For
> example, can I get {A[0, 0] -> max(3); A[0, 1] -> max(2); A[1, 0] ->
> max(8); A[1, 1] -> max(6)} instead of { A[i0, i1] -> max((3 - i1)) : i0 =
> 0 and 0 <= i1 <= 1; A[i0, i1] -> max((8 - 2 * i1)) : i0 = 1 and 0 <= i1 <=
> 1 } since the function in max() is not easy to parsing.
You can iterate over the domain elements and then evaluate
the reduction over all those elements.
See isl_union_pw_qpolynomial_fold_at in iscc.c (in the barvinok repo)
for an example.
Of course, this only works if the domain has a finite number of elements.
skimo