Commit Graph

1530 Commits

Author SHA1 Message Date
Tobias Grosser 1a07e19180 Increase the dependence-analysis compute out
As Polly got a lot faster after the small-integer-optimization imath
patch, we now increase the compute out to optimize larger kernels. This
should also expose additional slow-downs for us to address.

In LNT this gives us a 3.4x speedup on 3mm, at a cost of a 2x increase in
compile time (now 0.77s). reg_detect, oorafft and adi also show some compile
time increases. This compile time cost is divided between more time in isl and
more time in LLVM's backends due to increased code size (versioning and tiling).

llvm-svn: 240840
2015-06-26 21:58:42 +00:00
Tobias Grosser f54bb7743a Drop divs before adding array-out-of-bounds assumptions
In case we have modulo operations in the access function (supported since
r240518), the assumptions generated to ensure array accesses remain within
bounds can contain existentially quantified dimensions which results in more
complex and more difficult to handle integer sets. As a result LNT's linpack
benchmark started to fail due to excessive compile time.

We now just drop the existentially quantified dimensions. This should be
generally save, but may result in less precise assumptions which may
consequently make us fall back to the original (unoptimized) code more often. In
practice, these cases probably do not appear to often.

I had difficulties to extract a good test case, but fortunately our LNT bots
cover this one well.

llvm-svn: 240775
2015-06-26 12:09:28 +00:00
Tobias Grosser af4e809ca6 Remove code for scalar and PHI to array translation
This removes old code that has been disabled since several weeks and was hidden
behind the flags -disable-polly-intra-scop-scalar-to-array=false and
-polly-model-phi-nodes=false. Earlier, Polly used to translate scalars and
PHI nodes to single element arrays, as this avoided the need for their special
handling in Polly. With Johannes' patches adding native support for such scalar
references to Polly, this code is not needed any more. After this commit both
-polly-prepare and -polly-independent are now mostly no-ops. Only a couple of
simple transformations still remain, but they are scheduled for removal too.

Thanks again to Johannes Doerfert for his nice work in making all this code
obsolete.

llvm-svn: 240766
2015-06-26 07:31:18 +00:00
Michael Kruse f1ac0fcf56 Enable ISL's small integer optimization
Summary:
With small integer optimization (short: sio) enabled, ISL uses 32 bit
integers for its arithmetic and only falls back to a big integer library
(in the case of Polly: IMath) if an operation's result is too large.
This gives a massive performance boost for most application using ISL.
For instance, experiments with ppcg (polyhedral source-to-source
compiler) show speed-ups of 5.8 (compared to plain IMath), respectively
2.7 (compared to GMP).

In Polly, a smaller fraction of the total compile time is taken by ISL,
but the speed-ups are still very significant. The buildbots measure
compilation speed-up up to 1.8 (oourafft, floyd-warshall, symm). All
Polybench benchmarks compile in at least 9% less time, and about 20%
less on average.

Detailed Polybench compile time results (median of 10):
correlation     -25.51%
covariance      -24.82%
2mm             -26.64%
3mm             -28.69%
atax            -13.70%
bicg            -10.78%
cholesky        -40.67%
doitgen         -11.60%
gemm            -11.54%
gemver          -10.63%
gesummv         -11.54%
mvt              -9.43%
symm            -41.25%
syr2k           -14.71%
syrk            -14.52%
trisolv         -17.65%
trmm             -9.78%
durbin          -19.32%
dynprog          -9.09%
gramschmidt     -15.38%
lu              -21.77%
floyd-warshall  -42.71%
reg_detect      -41.17%
adi             -36.69%
fdtd-2d         -32.61%
fdtd-apml       -21.90%
jacobi-1d-imper  -9.41%
jacobi-2d-imper -27.65%
seidel-2d       -31.00%

Reviewers: grosser

Reviewed By: grosser

Subscribers: Meinersbur, llvm-commits, pollydev

Projects: #polly

Differential Revision: http://reviews.llvm.org/D10506

llvm-svn: 240689
2015-06-25 20:47:35 +00:00
Michael Kruse dddfeb6992 Fix autotools build
There were two issues:
* ISL's configure generates include/isl/stdint.h, not isl/stdint.h as
  assumed. This is also changed in the CMake build.

* Need to pass --with-int=imath to ISL's configure; the default is gmp. 

Polly's configure has been regenerated due to changing configure.ac

llvm-svn: 240657
2015-06-25 16:50:13 +00:00
Tobias Grosser 50165ffdee Add support for srem instruction
Remainder operations with constant divisor can be modeled as quasi-affine
expression. This patch adds support for detecting and modeling them. We also
add a test that ensures they are correctly code generated.

This patch was extracted from a larger patch contributed by Johannes Doerfert
in http://reviews.llvm.org/D5293

llvm-svn: 240518
2015-06-24 04:13:29 +00:00
Tobias Grosser a608569856 Replace srem by function call in nonaffine test cases
This makes the test cases nonaffine even if Polly some days gains support for
the srem instruction, an instruction which is currently not modeled but which
can clearly be modeled statically. A call to a function without definition
will always remain non-affine, as there is just insufficient static information
for it to be modeled more precisely.

llvm-svn: 240458
2015-06-23 20:55:05 +00:00
Tobias Grosser 6ca162e6e0 Add git patch files to .gitignore
llvm-svn: 240457
2015-06-23 20:55:01 +00:00
Michael Kruse f22855079a Use C99 to compile ISL
ISL with small integer optimization requires C99 to compile. gcc < 5.0
still uses C89 as default, so we need to enable the options to compile
in C99 mode.

This patch is preparing the actual activation of small integer
optimization.

Differential version: http://reviews.llvm.org/D10610

Reviewers: grosser
llvm-svn: 240322
2015-06-22 20:31:16 +00:00
Michael Kruse 9a4e22eea1 Make CMake generate isl/stdint.h
ISL's ./configure examines the system for the stdint.h to include and
creates a header file that points to it. On C99-compatible system

    #include <stdint.h>

is always valid such there no need for system introspection. This should
unbreak the build bots.

llvm-svn: 240315
2015-06-22 18:47:39 +00:00
Tobias Grosser 967c1e0b93 Handle zero-element ArrayRefs in CUDA run-time debug builder
llvm-svn: 240312
2015-06-22 18:45:23 +00:00
Michael Kruse 0c1c55345d Replace repository version of ISL by 'make dist' output
The 'make dist' archive is not dependent on ./configure output and
contains a GIT_HEAD_ID file that identifies the version of ISL used.

None of the files added or removed are used part of Polly's build
process (except of GIT_HEAD_ID since the previous revision r240301). No
functional change intended.

llvm-svn: 240306
2015-06-22 18:07:42 +00:00
Michael Kruse ee512e58a3 Prepare replacing ISL by its 'make dist' files
Currently the Polly repository contains the ISL sources with bogus
isl_config.h and gitversion.h. This is problematic. In this state a
 macro

    #define __attribute__(x)

becomes active in the source, leading to various problems e.g. when
included before system header files. This patch will instead generate
the two files specific to the host system at configure-time.

For CMake, we replicate the tests that ISL's configure performs using
try_compile(). In autotools build, we just invoke ISL's configure to
generate the two files. This consequently required regenerating
autoconf/configure.

'make dist' distributions of ISL contain a file GIT_HEAD_ID which
contains the version the distribution is derived from. The repository
files themselves do not contain such a hint. In a later commit we will
replace the isl directory by the contents of such a .tar.gz. It does
not contain the files imdrover.c iprime.c pi.c and rsamath.c currently
compiled into Polly, but not used and therefore are removed by this
patch.

In the long term we plan to generate a dedicated library for ISL instead
of adding its files to Polly.

This also does not yet include the switch to small-integer optimized ISL
nor enabling C99 mode required for the former. Those will come as well
in separate patches.

Differential version: http://reviews.llvm.org/D10603

Reviewers: grosser 
llvm-svn: 240301
2015-06-22 17:52:33 +00:00
David Blaikie de867e1ee9 Fix the clang -Werror build (-Wbraced-scalar-init)
llvm-svn: 240172
2015-06-19 20:07:18 +00:00
Tobias Grosser e7e628cc07 Add NVIDIA vprintf printing to RuntimeDebugBuilder
2nd try, this time with the corresponding LLVM IRBuilder changes in place.

llvm-svn: 240119
2015-06-19 02:33:45 +00:00
Michael Kruse 21a24730d0 Update external project versions in README.txt
This was meant to committed in r240027, but was left behind because 
svn, in contrast to git, only commits the changes in the directory you
are currently in.

llvm-svn: 240034
2015-06-18 18:07:06 +00:00
Michael Kruse c59f22c556 Update ISL to isl-0.15-3-g532568a
This version adds small integer optimization, but is not active by
default. It will be enabled in a later commit.
    
The schedule-fuse=min/max option has been replaced by the
serialize-sccs option. Adapting Polly was necessary, but retaining the
name polly-opt-fusion=min/max.

Differential Revision: http://reviews.llvm.org/D10505

Reviewers: grosser
llvm-svn: 240027
2015-06-18 16:45:40 +00:00
Tobias Grosser aa9f575ae1 Adjust to personality function change in 239940
llvm-svn: 239992
2015-06-18 05:02:11 +00:00
Chandler Carruth afa4ea7121 [PM/AA] Update Polly for r239886 which removed UnknownSize from
AliasAnalysis by getting it from its newly canonical home of
MemoryLocation::UnknownSize.

llvm-svn: 239890
2015-06-17 08:29:32 +00:00
Michael Kruse dd6011c494 Orthography: substracting -> subtracting
This is a test commit for being granted commit-after-approval access.

llvm-svn: 239725
2015-06-15 10:52:28 +00:00
Tobias Grosser 039955a44c Revert "Add NVIDIA vprintf printing to RuntimeDebugBuilder"
This reverts commit 239219 which requires some LLVM changes I forgot to commit.

Reported-by: Marshall Clow
llvm-svn: 239306
2015-06-08 16:24:49 +00:00
Tobias Grosser 6091417ebc Add NVIDIA vprintf printing to RuntimeDebugBuilder
llvm-svn: 239219
2015-06-06 08:43:22 +00:00
Tobias Grosser d8308fbed9 Avoid the use of std::map emplace
This functionality does not yet seem to exist on all buildbots.

llvm-svn: 239133
2015-06-05 05:52:15 +00:00
Tobias Grosser 785ee20cac Free two strings produced by isl
With this commit 'make check-polly' is now address sanitizer clean.

llvm-svn: 239131
2015-06-05 05:31:46 +00:00
Tobias Grosser d5d93ecd03 Use owning pointers to avoid memory leaks
This fixes a memory leak caused by us not freeing the expanded region nodes.

llvm-svn: 239061
2015-06-04 17:59:54 +00:00
Tobias Grosser 8199c722c7 Disable output for test case that does not need output
llvm-svn: 239060
2015-06-04 17:59:51 +00:00
Tobias Grosser a5c092d844 Store ArrayShape in shared_ptr and MemAccs as actual objects
This fixes two more memory leaks.

llvm-svn: 239050
2015-06-04 16:03:16 +00:00
Tobias Grosser ff22e9e5f6 Store comparison objects as objects, not pointers
This fixes a memory leak. If we store the actual objects we can not forget to
free them.

llvm-svn: 239033
2015-06-04 11:44:09 +00:00
Tobias Grosser 22adfb4373 Mark sdivs as 'exact' instead of lowering them ourselves
LLVM's instcombine already translates power-of-two sdivs that are known to be
exact to fast ashr instructions. Hence, there is no need to add this logic
ourselves.

Pointed-out-by: Johannes Doerfert
llvm-svn: 239025
2015-06-04 07:45:09 +00:00
Tobias Grosser 5cf7860704 Ensure memory access mappings are defined for full domain
We now verify that memory access functions imported via JSON are indeed defined
for the full iteration domain. Before this change we accidentally imported
memory mappings such as i -> i / 127, which only defined a mapped for values of
i that are evenly divisible by 127, but which did not define any mapping for the
remaining values, with the result that isl just generated an access expression
that had undefined behavior for all the unmapped values.

In the incorrect test cases, we now either use floor(i/127) or we use p/127 and
provide the information that p is indeed a multiple of 127.

llvm-svn: 239024
2015-06-04 07:44:35 +00:00
Chandler Carruth bdb4a39ad8 Update Polly for the AA/MemoryLocation refactoring.
llvm-svn: 239008
2015-06-04 03:49:46 +00:00
Tobias Grosser a441305564 [doc] Rename -polly-detect-only= to -polly-only-func=
llvm-svn: 238930
2015-06-03 15:45:19 +00:00
Tobias Grosser 244c8297cf Lower signed-divisions without rounding to ashr instructions
llvm-svn: 238929
2015-06-03 15:14:58 +00:00
Tobias Grosser 224b162280 Only convert power-of-two floor-division with non-negative denominator
floord(a,b) === a ashr log_2 (b) holds for positive and negative a's, but
shifting only makes sense for positive values of b. The previous patch did
not consider this as isl currently always produces postive b's. To avoid future
surprises, we check that b is positive and only then apply the optimization.

We also now correctly check the return value of the dyn-cast.

No additional test case, as isl currently does not produce negative
denominators.

Reported-by: David Majnemer <david.majnemer@gmail.com>
llvm-svn: 238927
2015-06-03 14:43:01 +00:00
Tobias Grosser cb73f150d4 Translate power-of-two floor-division into ashr
Power-of-two floor divisions can be translated into an arithmetic shift
operation. This allows us to replace a complex lowering that requires division
operations:

  %pexp.fdiv_q.0 = sub i64 %21, 128
  %pexp.fdiv_q.1 = add i64 %pexp.fdiv_q.0, 1
  %pexp.fdiv_q.2 = icmp slt i64 %21, 0
  %pexp.fdiv_q.3 = select i1 %pexp.fdiv_q.2, i64 %pexp.fdiv_q.1, i64 %21
  %pexp.fdiv_q.4 = sdiv i64 %pexp.fdiv_q.3, 128

with a simple ashr:

  %polly.fdiv_q.shr = ashr i64 %21, 7

llvm-svn: 238905
2015-06-03 06:31:30 +00:00
Tobias Grosser 97d8745087 Dump YAML schedule tree as properly indented tree in DEBUG output
llvm-svn: 238645
2015-05-30 06:46:59 +00:00
Tobias Grosser d6a50b3a1e Add DEBUG output to -polly-scops pass
llvm-svn: 238644
2015-05-30 06:26:21 +00:00
Tobias Grosser 3e77d14563 Add indvar pass to canonicalization sequence
Running indvar before Polly is useful as this eliminates zexts as they commonly
appear when a 32 bit induction variable (type int) was used on a 64 bit system.
These zexts confuse our delinearization and prevent for example the successful
delinearization of the nussinov kernel in polybench-c-4.1.

This fixes http://llvm.org/PR23426

Suggested-by: Xing Su <xsu.llvm@outlook.com>
llvm-svn: 238643
2015-05-30 06:16:41 +00:00
Tobias Grosser cdb38e5625 Exploit non-negative numerators
isl marks known non-negative numerators in modulo (and soon also division)
operations. We now exploit this by generating unsigned operations. This is
beneficial as unsigned operations with power-of-two denominators will be
translated by isl to fast bitshift or bitwise and operations.

llvm-svn: 238577
2015-05-29 17:08:19 +00:00
Tobias Grosser b2f399264d Update isl to 93b8e43d
This update brings mostly interface cleanups, but also fixes two bugs in
imath (a memory leak, some undefined behavior).

llvm-svn: 238422
2015-05-28 13:32:11 +00:00
Tobias Grosser 57411e3fc6 Drop const in front of iterator
David Blaikie:

"find returns an iterator by value, so it's just added complexity/strangeness to
then use reference lifetime extension to give it the same semantics as if you'd
used a value type instead of a reference type."

llvm-svn: 238294
2015-05-27 06:51:34 +00:00
Tobias Grosser 7c3bad52dd Use value semantics for list of ScopStmt(s) instead of std::owningptr
David Blaike suggested this as an alternative to the use of owningptr(s) for our
memory management, as value semantics allow to avoid the additional interface
complexity caused by owningptr while still providing similar memory consistency
guarantees. We could also have used a std::vector, but the use of std::vector
would yield possibly changing pointers which currently causes problems as for
example the memory accesses carry pointers to their parent statements. Such
pointers should not change.

Reviewer: jblaikie, jdoerfert

Differential Revision: http://reviews.llvm.org/D10041

llvm-svn: 238290
2015-05-27 05:16:57 +00:00
Tobias Grosser eeb9f3ce15 Drop unnecessary 'this->' pointers
llvm-svn: 238257
2015-05-26 21:37:31 +00:00
Tobias Grosser c825fae020 Tighten the PHI modeling test cases
While looking through the test cases I realized we did not have a CHECK line
for a duplicate memory access which we may want to eliminate later. To ensure
we do not have (or later introduce) unnecessary memory accesses, we now tighten
the test cases to look for such a pattern (and add the CHECK: line that shows
the redundant memory access).

llvm-svn: 238227
2015-05-26 18:05:45 +00:00
Tobias Grosser 2d7611f45e Remove unnecessary indirection through SCEV
llvm-svn: 238092
2015-05-23 05:58:30 +00:00
Tobias Grosser ab6714464a Use unique_ptr to clarify ownershop of ScopArrayInfoMap
llvm-svn: 238091
2015-05-23 05:58:27 +00:00
Tobias Grosser 679dfafd33 Use unique_ptr to clarify ownership of ScopStmt
llvm-svn: 238090
2015-05-23 05:14:09 +00:00
Tobias Grosser ac60f4594f Enable scalar and PHI code generation for Polly
The feature itself has been committed by Johannes in r238070. As this is the
way forward, we now enable it to ensure we get test coverage.

Thank you Johannes for this nice work!

llvm-svn: 238088
2015-05-23 03:34:41 +00:00
Tobias Grosser 268205939f Make use of scalar/phi code generation explicit in the tests
This ensures we pass all tests independently of how we set the options
-disable-polly-intra-scop-scalar-to-array and -polly-model-phi-nodes.

(At least if we enable both or disable both. Enabling them individually makes
 little sense, as they will hopefully disappear soon anyhow).

llvm-svn: 238087
2015-05-23 03:34:35 +00:00
Johannes Doerfert ecff11dcfb Add scalar and phi code generation
To reduce compile time and to allow more and better quality SCoPs in
  the long run we introduced scalar dependences and PHI-modeling. This
  patch will now allow us to generate code if one or both of those
  options are set. While the principle of demoting scalars as well as
  PHIs to memory in order to communicate their value stays the same,
  this allows to delay the demotion till the very end (the actual code
  generation). Consequently:
    - We __almost__ do not modify the code if we do not generate code
      for an optimized SCoP in the end. Thus, the early exit as well as
      the unprofitable option will now actually preven us from
      introducing regressions in case we will probably not get better
      code.
    - Polly can be used as a "pure" analyzer tool as long as the code
      generator is set to none.
    - The original SCoP is almost not touched when the optimized version
      is placed next to it. Runtime regressions if the runtime checks
      chooses the original are not to be expected and later
      optimizations do not need to revert the demotion for that part.
    - We will generate direct accesses to the demoted values, thus there
      are no "trivial GEPs" that select the first element of a scalar we
      demoted and treated as an array.

Differential Revision: http://reviews.llvm.org/D7513

llvm-svn: 238070
2015-05-22 23:43:58 +00:00