1 \section{\protect\isl/ interface
}
9 The
\barvinok/ library currently supports only a few
10 functions that interface with the
\isl/ library.
11 In time, this interface will grow and is set to replace
12 the
\PolyLib/ interface.
13 For more information on the
\isl/ data structures, see
14 the
\isl/ user manual.
17 __isl_give isl_pw_qpolynomial *isl_basic_set_card(
18 __isl_take isl_basic_set *bset);
19 __isl_give isl_pw_qpolynomial *isl_set_card(__isl_take isl_set *set);
20 __isl_give isl_union_pw_qpolynomial *isl_union_set_card(
21 __isl_take isl_union_set *uset);
23 Compute the number of elements in an
\ai[\tt]{isl
\_basic\_set},
24 \ai[\tt]{isl
\_set} or
\ai[\tt]{isl
\_union\_set}.
25 The resulting
\ai[\tt]{isl
\_pw\_qpolynomial}
26 or
\ai[\tt]{isl
\_union\_pw\_qpolynomial} has purely parametric cells.
29 __isl_give isl_pw_qpolynomial *isl_basic_map_card(
30 __isl_take isl_basic_map *bmap);
31 __isl_give isl_pw_qpolynomial *isl_map_card(__isl_take isl_map *map);
32 __isl_give isl_union_pw_qpolynomial *isl_union_map_card(
33 __isl_take isl_union_map *umap);
35 Compute a closed form expression for the number of image elements
36 associated to any element in the domain of the given
\ai[\tt]{isl
\_basic\_map},
37 \ai[\tt]{isl
\_map} or
\ai[\tt]{isl
\_union\_map}.
38 The union of the cells in the resulting
\ai[\tt]{isl
\_pw\_qpolynomial}
39 is equal to the domain of the input
\ai[\tt]{isl
\_map}.
42 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sum(
43 __isl_take isl_pw_qpolynomial *pwqp);
44 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sum(
45 __isl_take isl_union_pw_qpolynomial *upwqp);
47 Compute the sum of the given piecewise quasipolynomial over
48 all integer points in the domain. The result is a piecewise
49 quasipolynomial that only involves the parameters.
50 If, however, the domain of the piecewise quasipolynomial wraps
51 a relation, then the sum is computed over all integer points
52 in the range of that relation and the domain of the relation
53 becomes the domain of the result.
56 __isl_give isl_pw_qpolynomial *isl_set_apply_pw_qpolynomial(
57 __isl_take isl_set *set, __isl_take isl_pw_qpolynomial *pwqp);
58 __isl_give isl_union_pw_qpolynomial *isl_union_set_apply_union_pw_qpolynomial(
59 __isl_take isl_union_set *uset,
60 __isl_take isl_union_pw_qpolynomial *upwqp);
62 Compute the sum of the given piecewise quasipolynomial over
63 all integer points in the intersection of the domain and the given set.
66 __isl_give isl_pw_qpolynomial *isl_map_apply_pw_qpolynomial(
67 __isl_take isl_map *map, __isl_take isl_pw_qpolynomial *pwqp);
68 __isl_give isl_union_pw_qpolynomial *isl_union_map_apply_union_pw_qpolynomial(
69 __isl_take isl_union_map *umap,
70 __isl_take isl_union_pw_qpolynomial *upwqp);
72 Compose the given map with the given piecewise quasipolynomial.
73 That is, compute the sum over all elements in the intersection
74 of the range of the map and the domain of the piecewise quasipolynomial
75 as a function of an element in the domain of the map.
77 \subsection{Calculator
}
79 The
\ai[\tt]{iscc
} calculator offers an interface to some
80 of the functionality provided by the
\isl/,
\cloog/ and
\barvinok/
82 The language used by
\ai[\tt]{iscc
} is extremely simple. The calculator
83 supports operations on constants and dynamically typed variables and
84 assignments (
\ai[\tt]{:=
}) to those variables. If the result of an expression
85 is not used inside another expression and not assigned to a variable,
86 then this result is printed on the screen. The operators are overloaded
87 based on the types of the arguments, which may be sets, relations,
88 piecewise quasipolynomials, piecewise quasipolynomial folds, lists,
90 The supported operations are shown in
\autoref{t:iscc
}.
91 Note that when an operation requires an argument of a certain
92 type, a binary list with the first element of the required type
93 may also be used instead.
95 \subsubsection{Sets and Iteration Domains
}
98 \begin{lstlisting
}[escapechar=@
]{}
99 for (i =
1; i <= n; ++i)
100 for (j =
1; j <= i; ++j)
103 \caption{A loop nest
}
108 \begin{tikzpicture
}[>=stealth,x=
0.7cm,y=-
0.7cm
]
109 \draw[thick
] (
1,
1)--(
5,
5)--(
1,
5)--(
1,
1);
110 \draw[->
] (-
0.6,
0) to (
5.6,
0) node
[anchor=south east
] {$j$
};
111 \draw[->
] (
0,-
0.6) to (
0,
5.6) node
[anchor=south east
] {$i$
};
112 \draw[help lines,step=
0.7cm
] (-
0.6,
5.6) grid (
5.6,-
0.6);
113 \foreach \i in
{1,...,
5}{
114 \foreach \j in
{1,...,
\i}{
115 \fill (
\j,
\i) circle (
2pt);
119 \caption{The iteration domain of the loop nest in
\autoref{f:loop nest
}}
120 \label{f:iteration domain
}
123 Within the polyhedral model for analysis and transformation of
124 static affine programs, the most basic kind of set is the
125 \defindex{iteration domain
}.
126 The iteration domain represents the iterations of a statement in a loop nest.
127 Take, for example, the loop nest in
\autoref{f:loop nest
}
128 and assume first that
\lstinline{n
} has a fixed value, say
5.
129 The pairs of values of
\lstinline{i
} and
\lstinline{j
} for
130 which statement
\lstinline{S
} is executed are shown graphically
131 in
\autoref{f:iteration domain
}.
132 Mathematically, this set of pairs can be represented as
135 (i,j)
\in \ZZ^
2 \mid 1 \le i
\le 5 \wedge 1 \le j
\le i
138 and the
\isl/ notation is very similar:
139 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
140 { [i,j
] :
1 <= i <=
5 and
1 <= j <= i
}
143 the coordinates are separated by commas and enclosed in square
144 brackets. This description of the space in which the set lives
145 is followed by a colon and the constraints on the coordinates.
146 Assuming the iterators are incremented by one in every iterations
147 of the loop, a lower and upper bound on each loop iterator
148 can be read off from the initialization and the test.
149 Note that in an
\iscc/ set,
150 the coordinates are assumed to be integer by default.
151 For an iteration domain to be representable by such a set,
152 the iterators therefore need to be integers.
154 The constraints of a set need to be affine, i.e., linear plus constant term.
155 These affine constraint may be combined through conjunctions (
\texttt{and
}),
156 disjunctions (
\texttt{or
}), projections (
\texttt{exists
}) and
157 negations (
\texttt{not
}).
158 Note that the formula is immediately converted
159 into
\indac{DNF
}, so it may sometimes be more efficient
160 to construct a set from smaller sets by applying
161 basic operations such as intersection (
{\tt *
}),
162 union (
{\tt +
}) and difference (
{\tt -
}).
163 For example, the following square with its diagonal removed,
166 (i,j)
\mid 0 \le i,j
\le 10 \wedge \lnot (i = j)
169 can be constructed as
170 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
171 { [i,j
] :
0 <= i,j <=
10 } -
{ [i,i
] }
174 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
175 { [i,j
] :
0 <= i,j <=
10 and not (i = j)
}
177 Note that an occurrence of a relational operator in a set description
178 may define several constraints, one for each pair of arguments.
179 The elements in a list of arguments are separated by a comma.
180 If there are no constraints on the coordinates, i.e., in case of
181 a universe set, the colon may be omitted as well.
183 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
186 represents the entire (unnamed) zero-dimensional space,
187 and should not be confused with
188 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
191 which represents the empty set.
193 Returning to the iteration domain of the loop nest
194 in
\autoref{f:loop nest
}, we usually do not want to analyze
195 such a program for a specific value of
\lstinline{n
},
196 but instead for all possible values of
\lstinline{n
} at once.
197 A generic description of the iteration domain can be obtained
198 through the introduction of a (free) parameter, as in
199 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
200 [n
] ->
{ [i,j
] :
1 <= i <= n and
1 <= j <= i
}
202 The optional parameters should
203 be declared by placing them in a comma delimited list inside
\lstinline!
[]!
204 (followed by an ``
\lstinline!->!'') in front of the main set description.
205 The parameters are global and are identified by their names,
206 so the order inside the list is arbitrary.
207 This should be contrasted to the coordinates of a space, the names of
208 which are only relevant within the description of the set and which
209 are instead identified by their positions.
211 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
212 [n
] ->
{ [i,j
] :
1 <= i <= n and
1 <= j <= i
}
215 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
216 [n
] ->
{ [a,b
] :
1 <= a <= n and
1 <= b <= a
}
218 but it is not equal to
219 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
220 [n
] ->
{ [j,i
] :
1 <= i <= n and
1 <= j <= i
}
222 (because the order of the coordinates has changed)
224 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
225 [m
] ->
{ [i,j
] :
1 <= i <= m and
1 <= j <= i
}
227 (because it involves a different parameter).
229 It is sometimes convenient to represent constraints that only
230 involve parameters and that are not tied to any particular space.
231 To construct such a parameter domain, the list of coordinates
232 should simply be omitted. Note that the colon is required
233 in this case, even if there are no constraints.
235 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
238 represents the universal parameter domain, which is very different
241 To plug in a particular value for a parameter, the user should
242 take the
\ai{intersection
} (
\ai[\tt]{*
}) with a parameter domain
243 assigns a particular value to the parameter.
245 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
246 S :=
[n
] ->
{ [i,j
] :
1 <= i <= n and
1 <= j <= i
};
247 S *
[n
] ->
{ : n =
5 };
249 It should be noted, though, that the result is not the same
250 as simply replacing
\lstinline{n
} by
5 as the result of the above
251 sequence will still have the global parameter
\lstinline{n
} set to
5.
252 To avoid this assignment, the user should instead compute
253 the
\ai{gist
} (
\ai[\tt]{\%
}) of the original set in the context
254 of setting
\lstinline{n
} to
5.
255 That is, the result of the sequence below is
\lstinline{True
}.
256 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
257 S1 :=
{ [i,j
] :
1 <= i <=
5 and
1 <= j <= i
};
258 S2 :=
[n
] ->
{ [i,j
] :
1 <= i <= n and
1 <= j <= i
};
259 (S2
% [n] -> { : n = 5}) = S1;
263 \begin{lstlisting
}[escapechar=@
]{}
264 for (i =
1; i <= n; i +=
3)
267 \caption{A loop with non-unit stride
}
271 If a loop has a non-unit stride as in
\autoref{f:stride
}
272 then affine constraints on the coordinates and the parameters
273 are not sufficient to represent the iteration domain.
274 What is needed is a way to express that the value of
275 \lstinline{i
} is equal to
1 plus
3 times some integer and
276 this is where existentially quantified variables can be used.
277 Existentially quantified variables are introduced by the
278 \ai[\tt]{exists
} keyword and followed by a colon.
279 They can only be used within a single disjunct.
280 As an example, the iteration domain of the loop in
\autoref{f:stride
}
281 can be represented as
282 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
283 [n
] ->
{ [i
] : exists a :
1 <= i <= n and i =
1 +
3 a
}
287 \begin{lstlisting
}[escapechar=@
]{}
288 for (i =
1; i <= n; ++i)
289 if ((i +
1)
% 5 <= 2)
292 \caption{A loop with a modulo condition
}
296 Existentially quantified variables are also useful to represent
297 modulo constraints. Consider for example the loop in
298 \autoref{f:modulo
}. The iterator values
\lstinline!i! for which
299 the statement
\lstinline!S! is executed lie between
300 1 and
\lstinline!n! and are such that the remainder of
301 \lstinline!i +
1! on division by
5 is less than or equal to
2.
302 The constraint $(i +
1)
\bmod 5 \le 2$ can be written
303 as $(i +
1) -
5 \floor{\frac{i+
1}5} \le 2$, where
304 $f =
\floor{\frac{i+
1}5}$ is the greatest integer part of $
\frac{i+
1}5$.
305 That is, $f$ is the unique integer value satisfying the constraints
306 $
5 f
\le i +
1$ and $
5 f
\ge (i+
1) -
4$.
307 The iteration domain of the statement in
\autoref{f:modulo
}
308 can therefore be represented as
309 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
310 [n
] ->
{ [i
] : exists f :
1 <= i <= n and (i +
1) -
5 f <=
2 and
311 (i +
1) -
4 <=
5 f <= i +
1 }
313 Since greatest integer parts occur relatively frequently, there is
314 a special notation for them in
\isl/ using
\lstinline!
[]!.
315 The above set can therefore also be represented as
316 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
317 [n
] ->
{ [i
] :
1 <= i <= n and (i +
1) -
5 *
[(i +
1)/
5] <=
2 }
319 Actually, since modulos are pretty common too,
\isl/ also has
320 a special notation for them and the set can therefore also be respresented as
321 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
322 [n
] ->
{ [i
] :
1 <= i <= n and (i +
1)
% 5 <= 2 }
324 It should be noted that
\lstinline!
[]! always rounds down
325 (towards $-
\infty$), while integer division in C truncates
326 (towards
0). When translating conditions in C containing integer
327 divisions and/or modulos to
\isl/ constraints, the user should therefore
328 make sure the sign of the dividend is positive. If not, the integer
329 division needs to be translated differently for positive and negative
333 \begin{lstlisting
}[escapechar=@
]{}
334 for (i =
0; i < n; ++i)
336 for (i =
0; i < n; ++i)
337 for (j =
0; j < n - i; ++j)
338 F: t
[j
] = f(t
[j
], t
[j+
1]);
339 for (i =
0; i < n; ++i)
342 \caption{A program with three loop nests
}
343 \label{f:three loops
}
346 Most programs involve more than one statement.
347 Although it is possible to work with different sets, each
348 representing the iteration domain of a statement,
349 it is usually more convenient to collect all iteration domains
350 in a single set. To be able to differentiate between iterations
351 of different statements with the same values for the iterators,
352 \isl/ allows spaces to be named. The name is placed in front
353 of the
\lstinline!
[]! enclosing the iterators.
354 Consider for example the program in
\autoref{f:three loops
}.
355 The program contains three statements which have been labeled
357 The iteration domain of the first statement (
\lstinline!T!)
358 can be represented as
359 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
360 [n
] ->
{ T
[i
] :
0 <= i < n
}
362 The union of all iteration domains can be represented as
363 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
366 F
[i,j
] :
0 <= i < n and
0 <= j < n - i;
370 The semicolon
\lstinline{;
} is used to express a disjunction
371 between spaces. This should be contrasted with the
\lstinline{or
}
372 keyword which expresses a disjunction between conjunctions of constraints.
373 For example, the result of the following
\iscc/ statement is
375 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
376 { [i
] : i =
3 or i =
5 } =
{ [3];
[5] };
379 \subsubsection{Maps and Access Relations
}
381 A second important concept in the polyhedral model is that
382 of an
\defindex{access relation
}.
383 An access relation connects iterations of a statement
384 to the array elements accessed by those iterations.
385 Such a binary relation can be represented by a map in
\isl/.
386 Maps are defined in similar way to sets,
387 except that the single space is replaced by a pair of spaces separated
389 As an example, consider once more the program in
\autoref{f:three loops
}.
390 In particular, consider the access
\lstinline{t
[j+
1]} in
391 statement
\lstinline{F
}.
392 The index expression maps the pair of iterations
\lstinline{i
}
393 and
\lstinline{j
} to
\lstinline{t
[j+
1]}, i.e., element
\lstinline{j+
1}
394 of a space with name
\lstinline{t
}.
395 Ignoring the loop bound constraints, this access relation can
397 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
398 { F
[i,j
] -> t
[j +
1] }
400 It is however customary to include the constraints on the iterators
401 in the access relation, resulting in
402 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
403 [n
] ->
{ F
[i,j
] -> t
[j +
1] :
0 <= i < n and
0 <= j < n - i
}
405 The constraints can be added by intersecting the domains
406 of the access relations with the iteration domains.
407 For example, the following sequence constructs the access
408 relation for all reads in the program.
409 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
412 F
[i,j
] :
0 <= i < n and
0 <= j < n - i;
423 In this sequence, the
\lstinline{*
} operator, when applied
424 to a map and a set, intersects the domain of the map with the set.
426 The notation
\lstinline{R(S)
} can be used to compute the image
427 of the set
\lstinline{S
} under the map
\lstinline{R
}.
428 For example, given the sequence above,
\lstinline!Read(
{F
[0,
1]})!
429 computes the array elements read in iteration $(
0,
1)$ of statement
430 \lstinline{F
} and is equal to
431 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
432 [n
] ->
{ t
[2] : n >=
2; t
[1] : n >=
2 }
434 That is, elements
1 and
2 of the
\lstinline{t
} array are read,
435 provided
\lstinline{n
} is at least
2.
437 Maps need not be single-valued.
438 As an example, assume that
\lstinline{A
} is a two-dimensional
439 array of size
\lstinline{n
} in both dimensions.
440 Iterations
\lstinline{i
} of
441 a statement
\lstinline{S
} may pass a pointer to an entire row
442 of
\lstinline{A
} to a function as in
\lstinline{f(A
[i
])
}.
443 Without knowing anything about
\lstinline{f
}, we would have
444 to assume that this function may access any element of the row.
445 The access relation corresponding to
\lstinline{A
[i
]} is therefore
446 \begin{lstlisting
}[columns=flexible,escapechar=@,language=
]{}
447 [n
] ->
{ S
[i
] -> A
[i,j
] :
0 <= i,j < n
}
449 This map associates
\lstinline{n
} elements of
\lstinline{A
}
450 to each iteration of
\lstinline{S
}.
452 \subsubsection{Nested Spaces
}
454 Each space may contain a nested pair of spaces. Such nested spaces
455 are extremely useful in more advanced applications.
456 As an example, suppose that during equivalence checking
457 \shortcite{Verdoolaege2009equivalence
}
458 of two programs the iterations of
\verb!S1! in one program are supposed to
459 produce the same results as the same iterations of
\verb!SA! in the other program,
460 which may be described using the following map
462 [n
] ->
{ S1
[i
] -> SA
[i
] :
0 <= i <= n
}
464 If the iterations of
\verb!S1! depend on the same iterations
465 of
\verb!S2!, i.e.,
\verb!
{S1
[i
]->S2
[i
]}!, while those of
\verb!SA!
466 depend on the next iteration of
\verb!B!, i.e.,
\verb!
{SA
[i
]->SB
[i+
1]}!,
467 then we can apply the cross product of these two dependence maps, i.e.,
469 { [S1
[i
] -> SA
[i'
]] ->
[S2
[i
] -> SB
[1+i'
]] }
471 to the original map to find
472 out which iterations of
\verb!S2! should correspond to which
473 iterations of
\verb!SB!.
475 \subsubsection{Basic Operations
}
477 Basic operations on sets and maps include intersection (
\ai[\tt]{*
}),
478 union (
\ai[\tt]{+
}), difference (
\ai[\tt]{-
}), cross product (
\ai[\tt]{cross
}),
479 sampling (
\ai[\tt]{sample
}), affine hull (
\ai[\tt]{aff
}),
480 lexicographic optimization (
\ai[\tt]{lexmin
} or
\ai[\tt]{lexmax
}),
481 subset (
\ai[\tt]{<=
}) and equality (
\ai[\tt]{=
}) tests,
482 code generation (
\ai[\tt]{codegen
})
483 and the cardinality (
\ai[\tt]{card
}).
484 Additional operations on maps include computing domain (
\ai[\tt]{dom
})
485 and range (
\ai[\tt]{ran
}), differences between image and domain (
\ai[\tt]{deltas
}),
486 join (
\ai[\tt]{.
}), inverse (
\ai[\tt]{\^
{}-
1}) and transitive closure (
\ai[\tt]{\^
{}+
}).
487 The latter may result in an overapproximation.
489 The
\ai[\tt]{card
} operation computes the number of elements in a set
490 or the number of elements in the image of a domain element of a map.
491 The operation is performed exactly and completely symbolically and
492 the result is a piecewise quasipolynomial, i.e., a subdivision of one
493 or more spaces, with a quasipolynomial associated to each cell in the subdivision.
494 As a trivial example, the result of
496 card
{ A
[i
] -> B
[j
] :
0 <= j <= i
}
498 is
\verb!
{ A
[i
] -> (
1+i) : i >=
0 }!.
499 Operations on piecewise quasipolynomials include sum (
\ai[\tt]{+
})
500 and difference (
\ai[\tt]{-
}) and the computation of an upper bound over the domain.
501 If the domain contains a pair of nested spaces, then the upper bound is computed over
502 the nested range. As another trivial example, the result of
504 ub
{ [[i
] ->
[j
]] -> j^
2 : -i <= j <= i
}
507 \verb!(
{ [i
] -> max(i^
2) : i >=
0 }, True)!.
508 The first element in this list is the actual bound in the form
509 of a piecewise quasipolynomial fold,
510 i.e., a maximum of quasipolynomials defined over cells.
511 The second indicates whether the bound is tight, i.e., whether
512 a maximum has been computed.
514 \subsubsection{Advanced Operations
}
516 While the basic
{\tt card
} operation simply counts the number of elements
517 in an affine set, it is also possible to assign a weight to each element
518 of the set and to compute the sum of those weights over all the points in the set.
519 The syntax for this weighted counting is to compute the
{\tt sum
} of
520 a piecewise quasipolynomial over its domain. As in the case of the
{\tt ub
}
521 operator, if the domain contains a pair of nested space, the sum is computed
522 over the range. As an example, the result
525 sum
{ [[i
] ->
[j
]] -> i*j :
0 <= j <= i
}
528 \verb|
{ [i
] -> (
1/
2*i^
2+
1/
2*i^
3) : i >=
0 }|.
530 After the computation of some sum or bound, the result may have to
531 be reformulated in terms of other variables. For example, during
532 inter procedural analysis, a result computed in terms of the formal
533 parameters may have to be reformulated in terms of the actual parameters.
534 {\tt iscc
} therefore allows maps and
535 piecewise quasipolynomials or folds to be composed.
536 If the map is multi-valued, then the composition maps each domain element
537 to the sum or upper bound of the values at its image elements.
539 Finally, because of its high-level representation,
{\tt iscc
} can
540 provide a dependence analysis operation taking only three maps as input,
541 the sink accesses, the potential source accesses and a schedule.
542 The result is a single dependence map.
545 \subsubsection{More Examples
}
547 P :=
[n, m
] ->
{ [i,j
] :
0 <= i <= n and i <= j <= m
};
550 f :=
[n,m
] ->
{ [i,j
] -> i*j + n*i*i*j : i,j >=
0 and
5i +
27j <= n+m
};
553 s @
[n,m
] ->
{ :
0 <= n,m <=
20 };
555 f :=
[n
] ->
{ [i
] ->
2*n*i - n*n +
3*n -
1/
2*i*i -
3/
2*i-
1 :
556 (exists j :
0 <= i <
4*n-
1 and
0 <= j < n and
557 2*n-
1 <= i+j <=
4*n-
2 and i <=
2*n-
1 )
};
560 u @
[n
] ->
{ :
0 <= n <=
10 };
562 m :=
[n
] ->
{ [i,j
] ->
[i+
1,j+
1] :
1 <= i,j < n;
563 [i,j
] ->
[i+
1,j-
1] :
1 <= i < n and
2 <= j <= n
};
567 codegen
[N
] ->
{ A
[i
] ->
[i,
0] :
0 <= i <= N; B
[i
] ->
[i,
1] :
1 <= i <= N
};
569 { [k
] ->
[i
] :
1 <= i <= k
} .
{ [n
] ->
2 * n : n >=
1 };
571 { [m
] ->
[c
] :
1 <= c <= m
} .
{ [k
] -> max((
3 * k + k^
2)) : k >=
1 };
574 \subsubsection{Comparison to other Interactive Polyhedral Tools
}
576 Two related interactive polyhedral tools are
577 the Omega calculator
\shortcite{Omega_calc
}
578 and
{\tt SPPoC
} \shortcite{Boulet2001SPPoC
}.
579 The syntax of
{\tt iscc
} was very much inspired
580 by that of the Omega calculator. However, the Omega
581 calculator only knows sets and maps. In particular,
582 it does not perform any form of counting. An earlier version
583 of
\barvinok/ came with a modified version of
584 the Omega calculator that introduced an operation
585 for counting the number of elements in a set, but it
586 would simply print the result and not allow any further
588 {\tt SPPoC
} does support counting, but only the basic
589 operation of counting the elements in a set.
590 In particular, it does not support weighted counting,
591 nor the computation of upper bounds.
592 It also only supports (single-valued) functions
593 and not generic relations like the Omega calculator and
{\tt iscc
}.
594 Internally,
{\tt SPPoC
} uses
{\tt PolyLib
},
{\tt PipLib
} and
{\tt omega
}
596 its operations. Although the first two of these libraries may have been
597 state-of-the-art at the time
{\tt SPPoC
} was created, they are
598 no longer actively maintained and have been largely
599 superseded by more recent libraries.
600 In particular,
{\tt PipLib
} effectively only supports a single
601 operation, which is now also available in both
{\tt isl
} and
{\tt PPL
}.
602 The operations on rational polyhedra in
{\tt PolyLib
} are also
603 available in
{\tt PPL
}, usually through a cleaner interface and
604 with a more efficient implementation. As to counting the elements
605 in a parametric polytope, Barvinok's algorithm,
606 implemented in the
{\tt barvinok
} library, is usually much faster
607 than the algorithm implemented in
{\tt PolyLib
}
608 \shortcite{Verdoolaege2007parametric
}.
610 the ability to work with named and nested spaces and the ability
611 of sets and maps to contain (pairs of) elements from different spaces
612 are not available in the Omega calculator and
{\tt SPPoC
}.
615 \tablecaption{{\tt iscc
} operations. The variables
616 have the following types,
619 $q$: piecewise quasipolynomial,
620 $f$: piecewise quasipolynomial fold,
625 $o$: object of any type
635 \multicolumn{2}{r
}{\small\sl continued on next page
}
639 \begin{supertabular
}{p
{0.35\textwidth}p
{0.6\textwidth}}
640 $s_2$ :=
\ai[\tt]{aff
} $s_1$ & affine hull of $s_1$
642 $m_2$ :=
\ai[\tt]{aff
} $m_1$ & affine hull of $m_1$
644 $q$ :=
\ai[\tt]{card
} $s$ &
645 number of elements in the set $s$
647 $q$ :=
\ai[\tt]{card
} $m$ &
648 number of elements in the image of a domain element
650 $s_2$ :=
\ai[\tt]{coalesce
} $s_1$ &
651 simplify the representation of set $s_1$ by trying
652 to combine pairs of basic sets into a single
655 $m_2$ :=
\ai[\tt]{coalesce
} $m_1$ &
656 simplify the representation of map $m_1$ by trying
657 to combine pairs of basic maps into a single
660 $q_2$ :=
\ai[\tt]{coalesce
} $q_1$ &
661 simplify the representation of $q_1$ by trying
662 to combine pairs of basic sets in the domain
663 of $q_1$ into a single basic set
665 $f_2$ :=
\ai[\tt]{coalesce
} $f_1$ &
666 simplify the representation of $f_1$ by trying
667 to combine pairs of basic sets in the domain
668 of $f_1$ into a single basic set
670 \ai[\tt]{codegen
} $s$ &
671 generate code for the given domain.
672 This operation is only available if
\ai[\tt]{CLooG
}
673 support was compiled in.
675 \ai[\tt]{codegen
} $m$ &
676 generate code for the given scattering function.
677 This operation is only available if
\ai[\tt]{CLooG
}
678 support was compiled in.
680 $s_2$ :=
\ai[\tt]{coefficients
} $s_1$ &
681 The set of coefficients of valid constraints for $s_1$
683 $s_2$ :=
\ai[\tt]{solutions
} $s_1$ &
684 The set of elements satisfying the constraints with coefficients in $s_1$
686 $s_3$ := $s_1$
\ai[\tt]{cross
} $s_2$ &
687 Cartesian product of $s_1$ and $s_2$
689 $m_3$ := $m_1$
\ai[\tt]{cross
} $m_2$ &
690 Cartesian product of $m_1$ and $m_2$
692 $s$ :=
\ai[\tt]{deltas
} $m$ &
693 the set $\
{\, y - x
\mid x
\to y
\in m \,\
}$
695 $m_2$ :=
\ai[\tt]{deltas
\_map} $m_1$ &
696 the map $\
{\, (x
\to y)
\to y - x
\mid x
\to y
\in m_1 \,\
}$
698 $s$ :=
\ai[\tt]{dom
} $m$ &
701 $s$ :=
\ai[\tt]{dom
} $q$ &
702 domain of piecewise quasipolynomial $q$
704 $s$ :=
\ai[\tt]{dom
} $f$ &
705 domain of piecewise quasipolynomial fold $f$
707 $s$ :=
\ai[\tt]{domain
} $m$ &
710 $s$ :=
\ai[\tt]{domain
} $q$ &
711 domain of piecewise quasipolynomial $q$
713 $s$ :=
\ai[\tt]{domain
} $f$ &
714 domain of piecewise quasipolynomial fold $f$
716 $m_2$ :=
\ai[\tt]{domain
\_map} $m_1$ &
717 a map from a wrapped copy of $m_1$ to the domain of $m_1$
719 $s$ :=
\ai[\tt]{ran
} $m$ &
722 $s$ :=
\ai[\tt]{range
} $m$ &
725 $m_2$ :=
\ai[\tt]{range
\_map} $m_1$ &
726 a map from a wrapped copy of $m_1$ to the range of $m_1$
728 $m$ :=
\ai[\tt]{identity
} $s$ &
729 identity relation on $s$
731 $q$ :=
\ai[\tt]{lattice
\_width} $s$ &
732 lattice width of the set $s$
734 $s_2$ :=
\ai[\tt]{lexmin
} $s_1$ &
735 lexicographically minimal element of $s_1$
737 $m_2$ :=
\ai[\tt]{lexmin
} $m_1$ &
738 lexicographically minimal image element
740 $s_2$ :=
\ai[\tt]{lexmax
} $s_1$ &
741 lexicographically maximal element of $s_1$
743 $m_2$ :=
\ai[\tt]{lexmax
} $m_1$ &
744 lexicographically maximal image element
746 $s_2$ :=
\ai[\tt]{lift
} $s_1$ &
747 lift $s_1$ to a space with extra dimensions corresponding
748 to the existentially quantified variables in $s_1$ such
749 that
\lstinline!domain(unwrap(lift S))! is equal to
\lstinline!S!
751 $s_2$ :=
\ai[\tt]{params
} $s_1$ &
752 parameter domain of set $s_1$
754 $s$ :=
\ai[\tt]{params
} $m$ &
755 parameter domain of map $m$
757 $l$ :=
\ai[\tt]{parse
\_file} $S$ &
758 parse the file names $S$ and return a list consisting of
759 the iteration domains, the write access relations,
760 the read access relations and the original schedule.
761 This operation is only available if
\ai[\tt]{pet
}
762 support was compiled in.
764 $s_2$ :=
\ai[\tt]{poly
} $s_1$ & polyhedral hull of $s_1$
766 $m_2$ :=
\ai[\tt]{poly
} $m_1$ & polyhedral hull of $m_1$
768 $q_2$ :=
\ai[\tt]{poly
} $q_1$ & polynomial approximation of $q_1$
770 $q_2$ :=
\ai[\tt]{lpoly
} $q_1$ & polynomial underapproximation of $q_1$
772 $q_2$ :=
\ai[\tt]{upoly
} $q_1$ & polynomial overapproximation of $q_1$
774 $l$ :=
\ai[\tt]{pow
} $m$\ &
775 compute an overapproximation of the power
776 of $m$ and return a list containing the overapproximation
777 and a boolean that is true if the overapproximation
780 \ai[\tt]{print
} $o$ &
783 $o$ :=
\ai[\tt]{read
} {\tt "
}{\it filename
}{\tt"
} &
784 read object from file
786 $s_2$ :=
\ai[\tt]{sample
} $s_1$ &
787 a sample element of the set $s_1$
789 $m_2$ :=
\ai[\tt]{sample
} $m_1$ &
790 a sample element of the map $m_1$
792 $s_2$ :=
\ai[\tt]{scan
} $s_1$ &
793 the set $s_1$ split into individual elements,
794 provided $s_1$ contains a finite number of elements
796 $m_2$ :=
\ai[\tt]{scan
} $m_1$ &
797 the map $m_1$ split into individual elements,
798 provided $m_1$ contains a finite number of elements
800 \ai[\tt]{source
} {\tt "
}{\it filename
}{\tt"
} &
801 read commands from file
803 $q_2$ :=
\ai[\tt]{sum
} $q_1$ &
804 sum $q_1$ over all integer points in the domain of $q_1$,
805 or, if the domain of $q_1$ wraps a map, over all integer
806 points in the range of the wrapped map.
808 $S$ :=
\ai[\tt]{typeof
} $o$ &
809 a string representation of the type of $o$
811 $l$ :=
\ai[\tt]{ub
} $q$ &
813 upper bound on the piecewise quasipolynomial $q$ over
814 all integer points in the domain of $q$
815 and return a list containing the upper bound
816 and a boolean that is true if the upper bound
817 is known to be tight.
818 If the domain of $q$ wraps a map, then the upper
819 bound is computed over all integer points in
820 the range of the wrapped map instead.
822 $l$ :=
\ai[\tt]{vertices
} $s$ &
823 a list of vertices of the rational polytope defined by the same constraints
826 $s$ :=
\ai[\tt]{wrap
} $m$ &
827 wrap the map in a set
829 $m$ :=
\ai[\tt]{unwrap
} $s$ &
830 unwrap the map from the set
832 \ai[\tt]{write
} {\tt "
}{\it filename
}{\tt"
} $o$ &
835 $m_2$ :=
\ai[\tt]{zip
} $m_1$ &
836 the cross product of domain and range of $m_1$, i.e.,
837 $\
{\, (
\vec w
\to \vec y)
\to (
\vec x
\to \vec z)
838 \mid (
\vec w
\to \vec x)
\to (
\vec y
\to \vec z)
\in m_1 \,\
}$
840 $m_4$ :=
\ai[\tt]{any
} $m_1$
\ai[\tt]{before
} $m_2$
\ai[\tt]{under
} $m_3$ &
841 compute a map from any element $x$ in the domain of $m_1$
842 to any element $y$ in the domain of $m_2$
843 such that their images $m_1(x)$ and $m_2(y)$ overlap
844 and such that $m_3(x)
\llt m_3(y)$.
846 $l$ :=
\ai[\tt]{last
} $m_1$
\ai[\tt]{before
} $m_2$
\ai[\tt]{under
} $m_3$ &
847 compute a map that contains for any element $y$ in the domain of $m_2$
848 a mapping from the lexicographically last element $x$ in the domain of $m_1$
849 (according to the schedule $m_3$) to $y$
850 such that $m_1(x)$ and $m_2(y)$ overlap and such that $m_3(x)
\llt m_3(y)$.
851 Return a list containing this map and the set of elements in the domain of
852 $m_2$ for which there is no corresponding element in the domain of $m_1$.
854 $m_5$ :=
\ai[\tt]{any
} $m_1$
\ai[\tt]{last
} $m_2$
\ai[\tt]{before
} $m_3$
855 \ai[\tt]{under
} $m_4$ &
856 compute a map that contains for any element $y$ in the domain of $m_3$
857 a mapping from the lexicographically last element $x$ in the domain of $m_2$
858 (according to the schedule $m_4$) to $y$
859 such that $m_2(x)$ and $m_3(y)$ overlap and such that $m_4(x)
\llt m_4(y)$
860 as well as from any element $z$ in the domain of $m_1$ such that
861 $m_1(z)$ and $m_3(y)$ overlap, $m_4(z)
\llt m_4(y)$ and such that there
862 is no $x$ in the domain of $m_2$ with
863 $m_2(x)
\cap m_3(y)
\ne \emptyset$ and $m_4(z)
\llt m_4(x)
\llt m_4(y)$.
865 $m_3$ :=
\ai[\tt]{schedule
} $s$
\ai[\tt]{respecting
} $m_1$
\ai[\tt]{minimizing
} $m_2$ &
866 compute a schedule for the domains in $s$ that respects all dependences
867 in $m_1$ and tries to minimize the dependences in $m_2$.
869 $l$ :=
\ai[\tt]{schedule
\_forest} $s$
\ai[\tt]{respecting
} $m_1$
\ai[\tt]{minimizing
} $m_2$ &
870 compute a schedule for the domains in $s$ that respects all dependences
871 in $m_1$ and tries to minimize the dependences in $m_2$ and return
872 the forest of bands in the schedule.
874 $i_3$ := $i_1$
\ai{$+$
} $i_2$ & sum
876 $s_3$ := $s_1$
\ai{$+$
} $s_2$ & union
878 $m_3$ := $m_1$
\ai{$+$
} $m_2$ & union
880 $q_3$ := $q_1$
\ai{$+$
} $q_2$ & sum
882 $f_2$ := $f_1$
\ai{$+$
} $q$ & sum
884 $f_2$ := $q$
\ai{$+$
} $f_1$ & sum
886 $S_3$ := $S_1$
\ai{$+$
} $S_2$ & concatenation
888 $S_2$ := $o$
\ai{$+$
} $S_1$ &
889 concatenation of stringification of $o$ and $S_1$
891 $S_2$ := $S_1$
\ai{$+$
} $o$ &
892 concatenation of $S_1$ and stringification of $o$
894 $i_3$ := $i_1$
\ai{$-$
} $i_2$ & difference
896 $s_3$ := $s_1$
\ai{$-$
} $s_2$ & set difference
898 $m_3$ := $m_1$
\ai{$-$
} $m_2$ & set difference
900 $q_3$ := $q_1$
\ai{$-$
} $q_2$ & difference
902 $i_3$ := $i_1$
\ai{$*$
} $i_2$ & product
904 $s_3$ := $s_1$
\ai{$*$
} $s_2$ & intersection
906 $m_3$ := $m_1$
\ai{$*$
} $m_2$ & intersection
908 $q_2$ := $i$
\ai{$*$
} $q_1$ & product
910 $q_2$ := $q_1$
\ai{$*$
} $i$ & product
912 $q_3$ := $q_1$
\ai{$*$
} $q_2$ & product
914 $f_2$ := $i$
\ai{$*$
} $f_1$ & product
916 $f_2$ := $f_1$
\ai{$*$
} $i$ & product
918 $m_2$ := $m_1$
\ai{$*$
} $s$ & intersect domain of $m_1$ with $s$
920 $q_2$ := $q_1$
\ai{$*$
} $s$ & intersect domain of $q_1$ with $s$
922 $f_2$ := $f_1$
\ai{$*$
} $s$ & intersect domain of $f_1$ with $s$
924 $s_2$ := $m$($s_1$) & apply map $m$ to set $s_1$
926 $q_2$ := $q_1$($s$) & apply $q_1$ to each element in $s$ and compute
927 the sum of the results
929 $l$ := $f$($s$) & apply $f$ to each element in $s$, compute
930 a bound of the results
931 and return a list containing the bound
932 and a boolean that is true if the bound
933 is known to be tight.
935 $m_3$ := $m_1$
\ai[\tt]{.
} $m_2$ & join of $m_1$ and $m_2$
937 $m_3$ := $m_1$
\ai[\tt]{before
} $m_2$ & join of $m_1$ and $m_2$
939 $m_3$ := $m_2$($m_1)$ & join of $m_1$ and $m_2$
941 $m_3$ := $m_2$
\ai[\tt]{after
} $m_1$ & join of $m_1$ and $m_2$
943 $f_3$ := $f_1$
\ai[\tt]{.
} $f_2$ & join of $f_1$ and $f_2$, combining
944 the lists of quasipolynomials over shared domains
946 $q_2$ := $m$
\ai[\tt]{.
} $q_1$ & join of $m$ and $q_1$, taking the sum
947 over all elements in the intersection of the range of $m$ and the domain
950 $q_2$ := $m$
\ai[\tt]{before
} $q_1$ & $q_2$ := $m$
\ai[\tt]{.
} $q_1$
952 $q_2$ := $q_1(m)$ & $q_2$ := $m$
\ai[\tt]{.
} $q_1$
954 $q_2$ := $q_1$
\ai[\tt]{after
} $m$ & $q_2$ := $m$
\ai[\tt]{.
} $q_1$
956 $l$ := $m$
\ai[\tt]{.
} $f$ & join of $m$ and $f$, computing a bound
957 over all elements in the intersection of the range of $m$ and the domain
958 of $f$ and returning a list containing the bound
959 and a boolean that is true if the bound is known to be tight.
961 $l$ := $m$
\ai[\tt]{before
} $f$ & $l$ := $m$
\ai[\tt]{.
} $f$
963 $l$ := $f(m)$ & $l$ := $m$
\ai[\tt]{.
} $f$
965 $l$ := $f$
\ai[\tt]{after
} $m$ & $l$ := $m$
\ai[\tt]{.
} $f$
967 $m$ := $s_1$
\ai[\tt]{->
} $s_2$ & universal map with domain $s_1$
970 $q_2$ := $q_1$
\ai{@
} $s$ &
971 evaluate the piecewise quasipolynomial $q_1$ in each element
972 of the set $s$ and return a piecewise quasipolynomial
973 mapping each of the individual elements to the resulting
976 $q$ := $f$
\ai{@
} $s$ &
977 evaluate the piecewise quasipolynomial fold $f$ in each element
978 of the set $s$ and return a piecewise quasipolynomial
979 mapping each of the individual elements to the resulting
982 $s_3$ := $s_1$
\ai[\tt]{\%
} $s_2$ &
983 simplify $s_1$ in the context of $s_2$, i.e., compute
984 the gist of $s_1$ given $s_2$
986 $m_3$ := $m_1$
\ai[\tt]{\%
} $m_2$ &
987 simplify $m_1$ in the context of $m_2$, i.e., compute
988 the gist of $m_1$ given $m_2$
990 $m_2$ := $m_1$
\ai[\tt]{\%
} $s$ &
991 simplify $m_1$ in the context of the domain $s$, i.e., compute
992 the gist of $m_1$ given domain $s$
994 $q_2$ := $q_1$
\ai[\tt]{\%
} $s$ &
995 simplify $q_1$ in the context of the domain $s$, i.e., compute
996 the gist of $q_1$ given $s$
998 $f_2$ := $f_1$
\ai[\tt]{\%
} $s$ &
999 simplify $f_1$ in the context of the domain $s$, i.e., compute
1000 the gist of $f_1$ given $s$
1002 $m_2$ := $m_1$
\ai[\tt]{\^
{}-
1} & inverse of $m_1$
1004 $l$ := $m$
\ai[\tt]{\^
{}+
} &
1005 compute an overapproximation of the transitive closure
1006 of $m$ and return a list containing the overapproximation
1007 and a boolean that is true if the overapproximation
1008 is known to be exact
1011 the element at position $i$ in the list $l$
1013 $b$ := $q_1$
\ai[\tt]{==
} $q_2$ & is $q_1$ obviously equal to $q_2$?
1015 $b$ := $f_1$
\ai[\tt]{==
} $f_2$ & is $f_1$ obviously equal to $f_2$?
1017 $b$ := $s_1$
\ai[\tt]{=
} $s_2$ & is $s_1$ equal to $s_2$?
1019 $b$ := $m_1$
\ai[\tt]{=
} $m_2$ & is $m_1$ equal to $m_2$?
1021 $b$ := $s_1$
\ai[\tt]{<=
} $s_2$ & is $s_1$ a subset of $s_2$?
1023 $b$ := $m_1$
\ai[\tt]{<=
} $m_2$ & is $m_1$ a subset of $m_2$?
1025 $b$ := $s_1$
\ai[\tt]{<
} $s_2$ & is $s_1$ a proper subset of $s_2$?
1027 $b$ := $m_1$
\ai[\tt]{<
} $m_2$ & is $m_1$ a proper subset of $m_2$?
1029 $b$ := $s_1$
\ai[\tt]{>=
} $s_2$ & is $s_1$ a superset of $s_2$?
1031 $b$ := $m_1$
\ai[\tt]{>=
} $m_2$ & is $m_1$ a superset of $m_2$?
1033 $b$ := $s_1$
\ai[\tt]{>
} $s_2$ & is $s_1$ a proper superset of $s_2$?
1035 $b$ := $m_1$
\ai[\tt]{>
} $m_2$ & is $m_1$ a proper superset of $m_2$?
1037 $m$ := $s_1$
\ai[\tt]{<<
} $s_2$ & a map from
1038 $s_1$ to $s_2$ of those elements that live in the same space and
1039 such that the elements of $s_1$ are lexicographically strictly smaller
1040 than those of $s_2$.
1042 $m_3$ := $m_1$
\ai[\tt]{<<
} $m_2$ & a map from the domain of
1043 $m_1$ to the domain of $m_2$ of those elements such that their images
1044 live in the same space and such that the images of the elements of
1045 $m_1$ are lexicographically strictly smaller than those of $m_2$.
1047 $m$ := $s_1$
\ai[\tt]{<<=
} $s_2$ & a map from
1048 $s_1$ to $s_2$ of those elements that live in the same space and
1049 such that the elements of $s_1$ are lexicographically smaller
1050 than those of $s_2$.
1052 $m_3$ := $m_1$
\ai[\tt]{<<=
} $m_2$ & a map from the domain of
1053 $m_1$ to the domain of $m_2$ of those elements such that their images
1054 live in the same space and such that the images of the elements of
1055 $m_1$ are lexicographically smaller than those of $m_2$.
1057 $m$ := $s_1$
\ai[\tt]{>>
} $s_2$ & a map from
1058 $s_1$ to $s_2$ of those elements that live in the same space and
1059 such that the elements of $s_1$ are lexicographically strictly greater
1060 than those of $s_2$.
1062 $m_3$ := $m_1$
\ai[\tt]{>>
} $m_2$ & a map from the domain of
1063 $m_1$ to the domain of $m_2$ of those elements such that their images
1064 live in the same space and such that the images of the elements of
1065 $m_1$ are lexicographically strictly greater than those of $m_2$.
1067 $m$ := $s_1$
\ai[\tt]{>>=
} $s_2$ & a map from
1068 $s_1$ to $s_2$ of those elements that live in the same space and
1069 such that the elements of $s_1$ are lexicographically greater
1070 than those of $s_2$.
1072 $m_3$ := $m_1$
\ai[\tt]{>>=
} $m_2$ & a map from the domain of
1073 $m_1$ to the domain of $m_2$ of those elements such that their images
1074 live in the same space and such that the images of the elements of
1075 $m_1$ are lexicographically greater than those of $m_2$.