hanchenye-llvm-project/polly
Roman Gareev e0d466342b Restore the initial ordering of dimensions before applying the pattern matching
Dimensions of band nodes can be implicitly permuted by the algorithm applied
during the schedule generation.

For example, in case of the following matrix-matrix multiplication,

for (i = 0; i < 1024; i++)
  for (k = 0; k < 1024; k++)
    for (j = 0; j < 1024; j++)
      C[i][j] += A[i][k] * B[k][j];

it can produce the following schedule tree

domain: "{ Stmt_for_body6[i0, i1, i2] : 0 <= i0 <= 1023 and 0 <= i1 <= 1023 and
                                        0 <= i2 <= 1023 }"
child:
  schedule: "[{ Stmt_for_body6[i0, i1, i2] -> [(i0)] },
              { Stmt_for_body6[i0, i1, i2] -> [(i1)] },
              { Stmt_for_body6[i0, i1, i2] -> [(i2)] }]"
  permutable: 1
  coincident: [ 1, 1, 0 ]

The current implementation of the pattern matching optimizations relies on the
initial ordering of dimensions. Otherwise, it can produce the miscompilation
(e.g., [1]).

This patch helps to restore the initial ordering of dimensions by recreating
the band node when the corresponding conditions are satisfied.

Refs.:

[1] - https://bugs.llvm.org/show_bug.cgi?id=32500

Reviewed-by: Michael Kruse <llvm@meinersbur.de>

Differential Revision: https://reviews.llvm.org/D31741

llvm-svn: 299662
2017-04-06 17:09:54 +00:00
..
cmake [Cmake] Generate a PollyConfig.cmake. 2017-03-09 17:58:20 +00:00
docs Porting the example illustrating Polly from HTML to reStructuredText 2017-02-10 11:46:57 +00:00
include/polly [Polly][NewPM] Pull references to the legacy PM interface from utilities and helpers 2017-04-04 10:01:53 +00:00
lib Restore the initial ordering of dimensions before applying the pattern matching 2017-04-06 17:09:54 +00:00
test Restore the initial ordering of dimensions before applying the pattern matching 2017-04-06 17:09:54 +00:00
tools GPURuntime: ensure compilation with C99 2016-09-11 07:32:50 +00:00
unittests [Support] Add functions to ISLTools. 2017-03-22 19:31:06 +00:00
utils
www Add two Polly images 2017-04-05 11:50:31 +00:00
.arcconfig Upgrade all the .arcconfigs to https. 2016-07-14 13:15:37 +00:00
.arclint [External] Move lib/JSON to lib/External/JSON. NFC. 2017-02-05 15:26:56 +00:00
.gitattributes
.gitignore Do not track the isl PDF manual in SVN 2017-01-16 11:48:03 +00:00
CMakeLists.txt [Cmake] Generate a PollyConfig.cmake. 2017-03-09 17:58:20 +00:00
CREDITS.txt
LICENSE.txt [External] Move lib/JSON to lib/External/JSON. NFC. 2017-02-05 15:26:56 +00:00
README

README

Polly - Polyhedral optimizations for LLVM
-----------------------------------------
http://polly.llvm.org/

Polly uses a mathematical representation, the polyhedral model, to represent and
transform loops and other control flow structures. Using an abstract
representation it is possible to reason about transformations in a more general
way and to use highly optimized linear programming libraries to figure out the
optimal loop structure. These transformations can be used to do constant
propagation through arrays, remove dead loop iterations, optimize loops for
cache locality, optimize arrays, apply advanced automatic parallelization, drive
vectorization, or they can be used to do software pipelining.