GCC Middle and Back End API Reference
|
Functions | |
static isl_constraint * | build_linearized_memory_access () |
static void | pdr_stride_in_loop () |
static void | memory_strides_in_loop_1 () |
static void | memory_strides_in_loop () |
static bool | lst_interchange_profitable_p () |
static void | pbb_interchange_loop_depths (graphite_dim_t depth1, graphite_dim_t depth2, poly_bb_p pbb) |
static void | lst_apply_interchange () |
static bool | lst_perfectly_nested_p () |
static void | lst_perfect_nestify (lst_p loop1, lst_p loop2, lst_p *before, lst_p *nest, lst_p *after) |
static bool | lst_try_interchange_loops () |
static bool | lst_interchange_select_inner (scop_p scop, lst_p outer_father, int outer, lst_p inner_father) |
static int | lst_interchange_select_outer () |
int | scop_do_interchange () |
|
static |
@verbatim
Interchange heuristics and transform for loop interchange on polyhedral representation.
Copyright (C) 2009-2013 Free Software Foundation, Inc. Contributed by Sebastian Pop sebas and Harsha Jagasia tian .pop@ amd. comharsh. a.ja gasia @amd .com
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
XXX isl rewrite following comment
Builds a linear expression, of dimension DIM, representing PDR's memory access: L = r_{n}*r_{n-1}*...*r_{1}*s_{0} + ... + r_{n}*s_{n-1} + s_{n}. For an array A[10][20] with two subscript locations s0 and s1, the linear memory access is 20 * s0 + s1: a stride of 1 in subscript s0 corresponds to a memory stride of 20. OFFSET is a number of dimensions to prepend before the subscript dimensions: s_0, s_1, ..., s_n. Thus, the final linear expression has the following format: 0 .. 0_{offset} | 0 .. 0_{nit} | 0 .. 0_{gd} | 0 | c_0 c_1 ... c_n where the expression itself is: c_0 * s_0 + c_1 * s_1 + ... c_n * s_n.
-1 for the already included L dimension.
Go through all subscripts from last to first. First dimension is the alias set, ignore it.
|
static |
Apply the interchange of loops at depths DEPTH1 and DEPTH2 to all the statements below LST.
Referenced by pbb_interchange_loop_depths().
|
static |
Return true when the interchange of loops LOOP1 and LOOP2 is profitable. Example: | int a[100][100]; | | int | foo (int N) | { | int j; | int i; | | for (i = 0; i < N; i++) | for (j = 0; j < N; j++) | a[j][2 * i] += 1; | | return a[N][12]; | } The data access A[j][i] is described like this: | i j N a s0 s1 1 | 0 0 0 1 0 0 -5 = 0 | 0 -1 0 0 1 0 0 = 0 |-2 0 0 0 0 1 0 = 0 | 0 0 0 0 1 0 0 >= 0 | 0 0 0 0 0 1 0 >= 0 | 0 0 0 0 -1 0 100 >= 0 | 0 0 0 0 0 -1 100 >= 0 The linearized memory access L to A[100][100] is: | i j N a s0 s1 1 | 0 0 0 0 100 1 0 TODO: the shown format is not valid as it does not show the fact that the iteration domain "i j" is transformed using the scattering. Next, to measure the impact of iterating once in loop "i", we build a maximization problem: first, we add to DR accesses the dimensions k, s2, s3, L1 = 100 * s0 + s1, L2, and D1: this is the polyhedron P1. L1 and L2 are the linearized memory access functions. | i j N a s0 s1 k s2 s3 L1 L2 D1 1 | 0 0 0 1 0 0 0 0 0 0 0 0 -5 = 0 alias = 5 | 0 -1 0 0 1 0 0 0 0 0 0 0 0 = 0 s0 = j |-2 0 0 0 0 1 0 0 0 0 0 0 0 = 0 s1 = 2 * i | 0 0 0 0 1 0 0 0 0 0 0 0 0 >= 0 | 0 0 0 0 0 1 0 0 0 0 0 0 0 >= 0 | 0 0 0 0 -1 0 0 0 0 0 0 0 100 >= 0 | 0 0 0 0 0 -1 0 0 0 0 0 0 100 >= 0 | 0 0 0 0 100 1 0 0 0 -1 0 0 0 = 0 L1 = 100 * s0 + s1 Then, we generate the polyhedron P2 by interchanging the dimensions (s0, s2), (s1, s3), (L1, L2), (k, i) | i j N a s0 s1 k s2 s3 L1 L2 D1 1 | 0 0 0 1 0 0 0 0 0 0 0 0 -5 = 0 alias = 5 | 0 -1 0 0 0 0 0 1 0 0 0 0 0 = 0 s2 = j | 0 0 0 0 0 0 -2 0 1 0 0 0 0 = 0 s3 = 2 * k | 0 0 0 0 0 0 0 1 0 0 0 0 0 >= 0 | 0 0 0 0 0 0 0 0 1 0 0 0 0 >= 0 | 0 0 0 0 0 0 0 -1 0 0 0 0 100 >= 0 | 0 0 0 0 0 0 0 0 -1 0 0 0 100 >= 0 | 0 0 0 0 0 0 0 100 1 0 -1 0 0 = 0 L2 = 100 * s2 + s3 then we add to P2 the equality k = i + 1: |-1 0 0 0 0 0 1 0 0 0 0 0 -1 = 0 k = i + 1 and finally we maximize the expression "D1 = max (P1 inter P2, L2 - L1)". Similarly, to determine the impact of one iteration on loop "j", we interchange (k, j), we add "k = j + 1", and we compute D2 the maximal value of the difference. Finally, the profitability test is D1 < D2: if in the outer loop the strides are smaller than in the inner loop, then it is profitable to interchange the loops at DEPTH1 and DEPTH2.
References d1, d2, psct_dynamic_dim(), and poly_bb::transformed.
|
static |
Selects the inner loop in LST_SEQ (INNER_FATHER) to be interchanged with the loop OUTER in LST_SEQ (OUTER_FATHER).
|
static |
Interchanges all the loops of LOOP and the loops of its body that are considered profitable to interchange. Return the number of interchanged loops. OUTER is the index in LST_SEQ (LOOP) that points to the next outer loop to be considered for interchange.
|
static |
Transform the loop nest between LOOP1 and LOOP2 into a perfect nest. To continue the naming tradition, this function is called after perfect_nestify. NEST is set to the perfectly nested loop that is created. BEFORE/AFTER are set to the loops distributed before/after the loop NEST.
References free_lst().
|
static |
Return true when the nest starting at LOOP1 and ending on LOOP2 is perfect: i.e. there are no sequence of statements.
|
static |
Try to interchange LOOP1 with LOOP2 for all the statements of the body of LOOP2. LOOP1 contains LOOP2. Return true if it did the interchange.
Sync the transformed LST information and the PBB scatterings before using the scatterings in the data dependence analysis.
Transform the SCOP_TRANSFORMED_SCHEDULE of the SCOP.
Undo the transform.
|
static |
|
static |
Sets STRIDES to the sum of all the strides of the data references accessed in LOOP at DEPTH.
|
static |
Interchanges the loops at DEPTH1 and DEPTH2 of the original scattering and assigns the resulting polyhedron to the transformed scattering.
References lst_apply_interchange().
|
static |
Set STRIDE to the stride of PDR in memory by advancing by one in the loop at DEPTH.
XXX isl rewrite following comments.
Builds a partial difference equations and inserts them into pointset powerset polyhedron P. Polyhedron is assumed to have the format: T|I|T'|I'|G|S|S'|l1|l2. TIME_DEPTH is the time dimension w.r.t. which we are differentiating. OFFSET represents the number of dimensions between columns t_{time_depth} and t'_{time_depth}. DIM_SCTR is the number of scattering dimensions. It is essentially the dimensionality of the T vector. The following equations are inserted into the polyhedron P: | t_1 = t_1' | ... | t_{time_depth-1} = t'_{time_depth-1} | t_{time_depth} = t'_{time_depth} + 1 | t_{time_depth+1} = t'_{time_depth + 1} | ... | t_{dim_sctr} = t'_{dim_sctr}.
Add the equality: t_{time_depth} = t'_{time_depth} + 1. This is the core part of this alogrithm, since this constraint asks for the memory access stride (difference) between two consecutive points in time dimensions.
Add equalities: | t1 = t1' | ... | t_{time_depth-1} = t'_{time_depth-1} | t_{time_depth+1} = t'_{time_depth+1} | ... | t_{dim_sctr} = t'_{dim_sctr} This means that all the time dimensions are equal except for time_depth, where the constraint is t_{depth} = t'_{depth} + 1 step. More to this: we should be careful not to add equalities to the 'coupled' dimensions, which happens when the one dimension is stripmined dimension, and the other dimension corresponds to the point loop inside stripmined dimension.
pdr->accesses: [P1..nb_param,I1..nb_domain]->[a,S1..nb_subscript] ??? [P] not used for PDRs? pdr->extent: [a,S1..nb_subscript] pbb->domain: [P1..nb_param,I1..nb_domain] pbb->transformed: [P1..nb_param,I1..nb_domain]->[T1..Tnb_sctr] [T] includes local vars (currently unused) First we create [P,I] -> [T,a,S].
Add a dimension for L: [P,I] -> [T,a,S,L].
Build a constraint for "lma[S] - L == 0", effectively calculating L in terms of subscripts.
And add it to the map, so we now have: [P,I] -> [T,a,S,L] : lma([S]) == L.
Then we create [P,I,P',I'] -> [T,a,S,L,T',a',S',L'].
Now add the equality T[time_depth] == T'[time_depth]+1. This will force L' to be the linear address at T[time_depth] + 1.
Length of [a,S] plus [L] ...
... plus [T].
Now we equate most of the T/T' elements (making PITaSL nearly the same is (PITaSL)', except for one dimension, namely for 'depth' (an index into [I]), after translating to index into [T]. Take care to not produce an empty map, which indicates we wanted to equate two dimensions that are already coupled via the above time_depth dimension. Happens with strip mining where several scatter dimension are interdependend.
Length of [T].
Now maximize the expression L' - L.
int scop_do_interchange | ( | ) |
Interchanges all the loop depths that are considered profitable for SCOP. Return the number of interchanged loops.