Commit Graph

54 Commits

Author SHA1 Message Date
Tobias Grosser 5e6813d184 Derive run-time conditions for delinearization
As our delinearization works optimistically, we need in some cases run-time
checks that verify our optimistic assumptions. A simple example is the
following code:

void foo(long n, long m, long o, double A[n][m][o]) {

  for (long i = 0; i < 100; i++)
    for (long j = 0; j < 150; j++)
      for (long k = 0; k < 200; k++)
        A[i][j][k] = 1.0;
}

After clang linearized the access to A and we delinearized it again to
A[i][j][k] we need to ensure that we do not access the delinearized array
out of bounds (this information is not available in LLVM-IR). Hence, we
need to verify the following constraints at run-time:

CHECK:   Assumed Context:
CHECK:   [o, m] -> {  : m >= 150 and o >= 200 }
llvm-svn: 212198
2014-07-02 17:47:48 +00:00
Johannes Doerfert f618339a37 Introduce reduction types
This change is particularly useful in the code generation as we need
  to know which binary operator/identity element we need to combine/initialize
  the privatization locations.

  + Print the reduction type for each memory access
  + Adjusted the test cases to comply with the new output format and
    to test for the right reduction type

llvm-svn: 212126
2014-07-01 20:52:51 +00:00
Johannes Doerfert 9890a05287 [FIX] Don't consider reductions which are partially outside the SCoP
+ Test case

llvm-svn: 212080
2014-07-01 00:32:29 +00:00
Johannes Doerfert e58a012094 Allow multiple reductions per statement
Iterate over all store memory accesses and check for valid binary reduction
  candidate loads by following the operands of the stored value.  For each
  candidate pair we check if they have the same base address and there are no
  other accesses which may overlap with them. This ensures that no intermediate
  value can escape into other memory locations or is overwritten at some point.

  + 17 test cases for reduction detection and reduction dependency modeling

llvm-svn: 211957
2014-06-27 20:31:28 +00:00
Johannes Doerfert 76dd493eff [Fix] Broken tests after r211796.
llvm-svn: 211797
2014-06-26 19:29:11 +00:00
Tobias Grosser 50a5e6dac0 test/ScopInfo: Remove %defaultOpts and list passes explicitly
Due to bad habit we sometimes used a variable %defaultOpts that listed
a set of passes commonly run to prepare for Polly. None of these test cases
actually needs special preparation and only two of them need the 'basicaa' to
be scheduled. Scheduling the required alias analysis explicitly makes the test
cases clearer.

llvm-svn: 211671
2014-06-25 06:38:18 +00:00
Tobias Grosser 08031390d5 Clean up XFAILed test cases
We had a set of test cases that have been incomplete and XFAILED. This patch
completes a couple of the interesting ones and removes the ones which seem
redundant or not sufficiently reduced to be useful.

llvm-svn: 211670
2014-06-25 06:31:19 +00:00
Johannes Doerfert da80386700 Missing reduction detection test cases
llvm-svn: 211235
2014-06-18 23:08:14 +00:00
Tobias Grosser f4fcbf4097 Test delinearization of 2D diagonal matrix
llvm-svn: 210538
2014-06-10 14:48:17 +00:00
Tobias Grosser be7eaddc69 Adjust another test case to not access out of bounds
llvm-svn: 210208
2014-06-04 19:41:47 +00:00
Tobias Grosser 5416a0395f Adjust multidim test cases to not access out-of-bound memory
We do this currently only for test cases where we have integer offsets that
clearly access array dimensions out-of-bound.

-;   for (long i = 0; i < n; i++)
-;     for (long j = 0; j < m; j++)
-;       for (long k = 0; k < o; k++)
+;   for (long i = 0; i < n - 3; i++)
+;     for (long j = 4; j < m; j++)
+;       for (long k = 0; k < o - 7; k++)
 ;         A[i+3][j-4][k+7] = 1.0;

This will be helpful if we later want to simplify the access functions under the
assumption that they do not access memory out of bounds.

llvm-svn: 210179
2014-06-04 11:47:54 +00:00
Sebastian Pop 422e33f363 record delinearization result and reuse it in polyhedral translation
Without this patch, the testcase would fail on the delinearization of the second
array:

; void foo(long n, long m, long o, double A[n][m][o]) {
;   for (long i = 0; i < n; i++)
;     for (long j = 0; j < m; j++)
;       for (long k = 0; k < o; k++) {
;         A[i+3][j-4][k+7] = 1.0;
;         A[i][0][k] = 2.0;
;       }
; }

; CHECK: [n, m, o] -> { Stmt_for_body6[i0, i1, i2] -> MemRef_A[3 + i0, -4 + i1, 7 + i2] };
; CHECK: [n, m, o] -> { Stmt_for_body6[i0, i1, i2] -> MemRef_A[i0, 0, i2] };

Here is the output of FileCheck on the testcase without this patch:

; CHECK: [n, m, o] -> { Stmt_for_body6[i0, i1, i2] -> MemRef_A[i0, 0, i2] };
         ^
<stdin>:26:2: note: possible intended match here
 [n, m, o] -> { Stmt_for_body6[i0, i1, i2] -> MemRef_A[o0] };
 ^

It is possible to find a good delinearization for A[i][0][k] only in the context
of the delinearization of both array accesses.

There are two ways to delinearize together all array subscripts touching the
same base address: either duplicate the code from scop detection to first gather
all array references and then run the delinearization; or as implemented in this
patch, use the same delinearization info that we computed during scop detection.

llvm-svn: 210117
2014-06-03 18:16:31 +00:00
Sebastian Pop fcf68758b8 unxfail passing testcase
llvm-svn: 208233
2014-05-07 18:01:32 +00:00
Tobias Grosser f56af204b9 Add delinearization testcase for ivs that do not follow the loop order
This is a test case that is currently failing, but that should start working
with an upcoming version of our delinearization pass.

llvm-svn: 207678
2014-04-30 17:49:22 +00:00
Sebastian Pop cd3bb59aa2 only delinearize when the access function is not affine
llvm-svn: 205971
2014-04-10 16:08:11 +00:00
Tobias Grosser 79baa21242 ScopInfo: Scalar accesses are zero dimensional
llvm-svn: 205958
2014-04-10 08:38:02 +00:00
Sebastian Pop 1801668af3 delinearize memory access functions
llvm-svn: 205799
2014-04-08 21:20:44 +00:00
Tobias Grosser d6aafa7c2e Do not track location of scalar dependences in ScopInfo
We do not have a use for this information at the moment. If we need this at some
point, the "instruction -> access" mapping needs to be enhanced as a single
instruction could then possibly perform multiple accesses.

This patch allows us to build the polyhedral information for scops with scalar
dependences.

llvm-svn: 201815
2014-02-20 21:29:09 +00:00
Tobias Grosser a1689937ba Check scops a second time before working on them
In rare cases the modification of one scop can effect the validity of other
scops, as code generation of an earlier scop may make the scalar evolution
functions derived for later scops less precise. The example that triggered this
patch was a scop that contained an 'or' expression as follows:

  %add13710 = or i32 %j.19, 1
    -->  {(1 + (4 * %l)),+,2}<nsw><%for.body81>

Scev could only analyze the 'or' as it knew %j.19 is a multiple of 2. This
information was not available after the first scop was code generated (or
independent-blocks was run on it) and SCEV could not derive a precise SCEV
expression any more. This means we could not any more code generate this SCoP.
My current understanding is that there is always the risk that an earlier code
generation change invalidates later scops.  As the example we have seen here is
difficult to avoid, we use this occasion to guard us against all such
invalidations.

This patch "solves" this issue by verifying right before we start working on
a detected scop, if this scop is in fact still valid. This adds a certain
overhead. However the verification we run is anyways very fast and secondly
it is only run on detected scops. So the overhead should not be very large. As
a later optimization we could detect scops only on demand, such that we need
to run scop-detections always only a single time.

This should fix the single last failure in the LLVM test-suite for the new
scev-based code generation.

llvm-svn: 201593
2014-02-18 18:49:49 +00:00
Tobias Grosser 7b6f9ba572 ScopValidator: smax expressions are no parameters
This fixes PR18155 which is a regression introduced in 152913.

llvm-svn: 196827
2013-12-09 21:51:46 +00:00
Tobias Grosser 4f8c0877e8 This test case requires assertions
llvm-svn: 192530
2013-10-12 09:15:56 +00:00
Sebastian Pop 946070f2f0 do not use -polly-cloog in a ScopInfo testcase
llvm-svn: 192109
2013-10-07 16:43:00 +00:00
Tobias Grosser 3613fd7a35 ScopInfo: Correctly handle true/false conditions
This is a modified version of the orignally contributed patch.

Contributed-by: alexandre.isoard@gmail.com
llvm-svn: 190237
2013-09-07 01:54:13 +00:00
Tobias Grosser 22a155a7a6 ScopInfo: add a testcase that share parameters within nested start.
Contributed-by:  Star Tan <tanmx_star@yeah.net>
llvm-svn: 187772
2013-08-06 04:36:45 +00:00
Tobias Grosser e42ddb9ad3 ScopInfo: Split start value from SCEVAddRecExpr to enable parameter sharing.
SCoP invariant parameters with the different start value would deter parameter
sharing. For example, when compiling the following C code:

  void foo(float *input) {
    for (long j = 0; j < 8; j++) {
      // SCoP begin
      for (long i = 0; i < 8; i++) {
        float x = input[j * 64 + i + 1];
        input[j * 64 + i] = x * x;
      }
    }
  }

Polly would creat two parameters for these memory accesses:

    p_0: {0,+,256}
    p_2: {4,+,256}
    [j * 64 + i + 1] => MemRef_input[o0] : 4o0 = p_1 + 4i0
    [j * 64 + i]     => MemRef_input[o0] : 4o0 = p_0 + 4i0

These parameters only differ from start value. To enable parameter sharing,
we split the start value from SCEVAddRecExpr, so they would share a single
parameter that always has zero start value:

    p0: {0,+,256}<%for.cond1.preheader>
    [j * 64 + i + 1] => MemRef_input[o0] : 4o0 = 4 + p_1 + 4i0
    [j * 64 + i]     => MemRef_input[o0] : 4o0 = p_0 + 4i0

Such translation can make the polly-dependence much faster.

Contributed-by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 187728
2013-08-05 15:14:15 +00:00
Tobias Grosser 7032ea6f5b Remove second '-analyze' from command line
llvm-svn: 187341
2013-07-29 05:15:33 +00:00
Rafael Espindola e559af8205 Add not to commands that fail.
Polly devs: please check if these commands really should fail.

llvm-svn: 187263
2013-07-26 22:49:25 +00:00
Tobias Grosser 4f96749351 ScopInfo: Clarify may-write and must-write accesses
llvm-svn: 184658
2013-06-23 05:21:18 +00:00
Tobias Grosser 3e030e178a Correctly convert APInt to gmp values
Previously this happend to work for integers up to i64, but we got it wrong
for larger numbers. Fix this and add test cases to verify this keeps working.

Reported by: Sven Verdoolaege <skimo at kotnet dot org>

llvm-svn: 183986
2013-06-14 16:23:38 +00:00
Tobias Grosser 3ed2600cab SCEVValidator: Correctly store 'k * p' as a parameter
We do not only need to understand that 'k * p' is a parameter expression, but
also need to store this expression in the set of parameters. Before this patch
we wrongly stored the two individual parameters %k and %p.

Reported by: Sebastian Pop <spop@codeaurora.org>

llvm-svn: 179485
2013-04-14 13:15:59 +00:00
Sebastian Pop 1006614228 fix testcase
llvm-svn: 179183
2013-04-10 16:44:08 +00:00
Tobias Grosser 7f54714dcc tests: Properly check if asserts are available
In my previous commits I failed to realise that my new requires lines fully
disabled these tests. We now properly check if we are in an asserts build and
only disable the tests if assertions are not available.

Reported-by: Sean Silva <silvas@purdue.edu>
llvm-svn: 176900
2013-03-12 21:27:39 +00:00
Tobias Grosser c9a72919a5 Move tests that depend on -stats under 'requires asserts'
This fixes issues caused by the following commit:

  r176733 | jvoung | 2013-03-08 17:56:31 -0500
  Disable statistics on Release builds and move tests that depend on -stats.

Reported by: Jack Howarth <howarth@bromo.med.uc.edu>

llvm-svn: 176856
2013-03-12 08:45:15 +00:00
Patrik Hägglund b476cdfde5 Fix tests with broken datalayout strings.
Buildbot failure at r168785.

llvm-svn: 168791
2012-11-28 13:30:31 +00:00
Tobias Grosser 38ea9cd721 Tests: Pipe test files into 'opt'
Use 'opt < %s' instead of just 'opt %s' to ensure that no temporary files are
created.

llvm-svn: 167372
2012-11-04 16:56:20 +00:00
Tobias Grosser dcebf1e9da Tests: remove ModuleID lines
llvm-svn: 167284
2012-11-02 06:09:20 +00:00
Tobias Grosser 6a2da6b9c8 Add test cases for multi-dimensional variable lengths arrays
At the moment we can handle such arrays only by conservatively assuming that
each access to such an array may touch any element in the array. It would be
great if we could improve Polly/LLVM at some point, such that we can
recover the multi-dimensionality of the accesses.

llvm-svn: 163619
2012-09-11 14:03:19 +00:00
Tobias Grosser ed29566c4e ScopInfo: Align parameters when using -polly-allow-nonaffine
This ensures that the isl sets/maps we operate on have the same parameter
dimensions. Operations on objects with different parameter dimensions are not
allow and trigger assertions.

llvm-svn: 163618
2012-09-11 13:50:21 +00:00
Hongbin Zheng 7aee737062 IndependentBLocks: Do not visit the same instruction twice when moving the
operand tree.

This patch fix Bug 13491, and the original "FIXME" in IndependentBlocks.cpp.

Patched by Kevin Fan<kevin.fan@gmail.com>.

llvm-svn: 161105
2012-08-01 08:46:11 +00:00
Tobias Grosser 18daacad61 ScopInfo: Add parameter bounds to context
Derive the maximal and minimal values of a parameter from the type it has. Add
this information to the scop context. This information is needed, to derive
optimal types during code generation.

llvm-svn: 157245
2012-05-22 10:47:27 +00:00
Tobias Grosser 371badaa47 SCEVValidator: Ensure that parameters are recorded correctly
This also fixes UMax where we did not correctly keep track of the parameters.
Fixes PR12275.

Reported-By: Sebastian Pop  <sebpop@gmail.com>
llvm-svn: 152913
2012-03-16 10:16:28 +00:00
Tobias Grosser 3cbe5cfff3 Remove FinalRead
The FinalRead statement represented a virtual read that is executed after the
SCoP. It was used when we verified the correctness of a schedule by checking if
it yields the same FLOW dependences as the original code. This is only works, if
we have a final read that reads all memory at the end of the SCoP.
We now switched to just checking if a schedule does not introduce negative
dependences and also consider WAW WAR dependences. This restricts the schedules
a little bit more, but we do not have any optimizer that would calculate a more
complex schedule. Hence, for now final reads are obsolete.

llvm-svn: 152319
2012-03-08 15:21:51 +00:00
Tobias Grosser a187964bac Support non-affine access functions in Polly.
In case we can not analyze an access function, we do not discard the SCoP, but
assume conservatively that all memory accesses that can be derived from our base
pointer may be accessed.

Patch provided by: Marcello Maggioni <hayarms@gmail.com>

llvm-svn: 146972
2011-12-20 10:43:14 +00:00
Tobias Grosser 8f99c167cd ScopInfo: Use names of simple parameters to name the isl parameter dimensions.
Parameters can be complex SCEV expressions, but they can also be single scalar
values. If a parameters is such a simple scalar value and the value is named,
use this name to name the isl parameter dimensions.

llvm-svn: 144641
2011-11-15 11:38:55 +00:00
Tobias Grosser f50fc50c80 Remove unused parameters from TempScop
llvm-svn: 144232
2011-11-09 22:35:15 +00:00
Tobias Grosser fb47d66a06 Remove unused code from SCEVAffFunc constructor
llvm-svn: 144224
2011-11-09 22:34:39 +00:00
Tobias Grosser 5683df4a23 Remove more of SCEVAffineFunc
llvm-svn: 144223
2011-11-09 22:34:34 +00:00
Tobias Grosser db87142b26 TempScop: Remove more of the buildAffineFunction
llvm-svn: 144221
2011-11-09 22:34:24 +00:00
Tobias Grosser e6efa37e76 TempScopInfo: Remove unneeded construction of SCEVAffFunc
llvm-svn: 144220
2011-11-09 22:34:18 +00:00
Tobias Grosser 60b54f19e6 Detect Parameters directly on the SCEV.
Instead of using TempScop to find parameters, we detect them directly
on the SCEV. This allows us to remove the TempScop parameter detection
in a subsequent commit.

This fixes a bug reported by Marcello Maggioni <hayarms@gmail.com>

llvm-svn: 144087
2011-11-08 15:41:28 +00:00