Commit Graph

3331 Commits

Author SHA1 Message Date
Tobias Grosser 325812ac6d Simplify: Adopt for translation of MemoryAccess::getAccessRelation
For some reason this one was missed earlier.

llvm-svn: 308845
2017-07-23 08:15:28 +00:00
Tobias Grosser 1959dbda75 Move MemoryAccess::get*ArrayId to isl++
llvm-svn: 308843
2017-07-23 04:08:59 +00:00
Tobias Grosser 3b196131b5 Move applyScheduleToAccessRelation to isl++
llvm-svn: 308842
2017-07-23 04:08:52 +00:00
Tobias Grosser 6a87036e0f Move MemoryAccess::getAddressFunction to isl++
llvm-svn: 308841
2017-07-23 04:08:45 +00:00
Tobias Grosser 1515f6b937 Move MemoryAccess::NewAccessRelation to isl++
We also move related accessor functions

llvm-svn: 308840
2017-07-23 04:08:38 +00:00
Tobias Grosser 22da5f087a Move MemoryAccess::getOriginalAccessRelation to isl++
llvm-svn: 308839
2017-07-23 04:08:27 +00:00
Tobias Grosser 0c4c2eef75 Move MemoryAccess::AccessRelation to isl++
llvm-svn: 308838
2017-07-23 04:08:22 +00:00
Tobias Grosser b6e7a85a6d Move MemoryAccess::createBasicAccessMap to isl++
llvm-svn: 308837
2017-07-23 04:08:17 +00:00
Tobias Grosser fe46c3ff3a Move MemoryAccess::id to isl++
llvm-svn: 308836
2017-07-23 04:08:11 +00:00
Michael Kruse ab8f0d57df [Simplify] Remove partial write accesses with empty domain.
If the access relation's domain is empty, the access will never be
executed. We can just remove it.

We only remove write accesses. Partial read accesses are not yet
supported and instructions in the statement might require the
llvm::Value holding the read's result to be defined.

llvm-svn: 308830
2017-07-22 20:33:09 +00:00
Michael Kruse e52ebd1ae4 [ScopInfo] Adapt indentation of instruction list printing.
Change the indention of the last brace to align with the opening line.

Before:

            Instructions {
                  %val = fadd double %arg, 2.100000e+01
                  store double %val, double* %A
                }

After:

            Instructions {
                  %val = fadd double %arg, 2.100000e+01
                  store double %val, double* %A
            }

llvm-svn: 308828
2017-07-22 16:44:39 +00:00
Michael Kruse e5f4706a55 [ForwardOpTree] Support hoisted invariant loads.
Hoisted loads can be trivially supported because there are no
MemoryAccess to be modified, the loaded value is just available
at code generation.

llvm-svn: 308826
2017-07-22 14:30:02 +00:00
Michael Kruse a6b2de3b59 [ForwardOpTree] Introduce the -polly-optree pass.
This pass 'forwards' operand trees into statements that use them in
order to avoid scalar dependencies.

This minimal implementation handles only the case of speculatable
instructions. We will successively add support for:
- Hoisted loads
- Read-only values
- Synthesizable values
- Loads
- PHIs
- Forwarding only parts of the tree

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

llvm-svn: 308825
2017-07-22 14:02:47 +00:00
Tobias Grosser 77eef90f50 Move ScopArrayInfo to isl++
This moves the full ScopArrayInfo class to isl++

llvm-svn: 308801
2017-07-21 23:07:56 +00:00
Philip Pfaffe 8f6c48e2aa Untangle ScopInfo lit-testcases from specifics of the legacy-PM
Summary:
For the ScopInfo lit testsuite, this patch removes some dependences on output behaviour of the legacy PM.

In most cases, these tests checked the tool output for labels created by the pass printer in the legacy PM. This doesn't work for the new PM anymore. Untangling the testcases is the first step to porting the testsuite for the new PM infrastructure.

Reviewers: grosser, Meinersbur, bollu

Reviewed By: grosser

Subscribers: llvm-commits, pollydev

Tags: #polly

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

llvm-svn: 308754
2017-07-21 16:47:36 +00:00
Philipp Schaad 2f3073b5cb [Polly][GPGPU] Added SPIR Code Generation and Corresponding Runtime Support for Intel
Summary:
Added SPIR Code Generation to the PPCG Code Generator. This can be invoked using
the polly-gpu-arch flag value 'spir32' or 'spir64' for 32 and 64 bit code respectively.
In addition to that, runtime support has been added to execute said SPIR code on Intel
GPU's, where the system is equipped with Intel's open source driver Beignet (development
version). This requires the cmake flag 'USE_INTEL_OCL' to be turned on, and the polly-gpu-runtime
flag value to be 'libopencl'.
The transformation of LLVM IR to SPIR is currently quite a hack, consisting in part of regex
string transformations.
Has been tested (working) with Polybench 3.2 on an Intel i7-5500U (integrated graphics chip).

Reviewers: bollu, grosser, Meinersbur, singam-sanjay

Reviewed By: grosser, singam-sanjay

Subscribers: pollydev, nemanjai, mgorny, Anastasia, kbarton

Tags: #polly

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

llvm-svn: 308751
2017-07-21 16:11:06 +00:00
Michael Kruse e186013149 Annotate dump() functions with LLVM_DUMP_METHOD. NFC.
llvm-svn: 308749
2017-07-21 15:54:13 +00:00
Michael Kruse 5d5184698d [ScopInfo] Don't compile dump() functions into non-assert builds. NFC.
This follows a convention used in LLVM.

llvm-svn: 308748
2017-07-21 15:54:07 +00:00
Michael Kruse cd4c977b8b [ScopInfo] Print instructions in dump().
Print a statement's instruction on dump() regardless of
-polly-print-instructions. dump() is supposed to be used in the debugger
only and never in regression tests. While debugging, get all the
information we have and we are not bound to break anything. For non-dump
purposes of print, forward the setting of -polly-print-instructions as
parameters.

Some calls to print() had to be changed because the
PollyPrintInstructions setting is only available in ScopInfo.cpp.
In ScheduleOptimizer.cpp, dump() was used in regression tests.
That's not what dump() is for.

The print parameter "PrintInstructions" will also be useful for an
explicit print SCoP pass in a future patch.

llvm-svn: 308746
2017-07-21 15:35:53 +00:00
Siddharth Bhat 06d4ed6787 [NFC] [RegisterPasses] Fix typo: To early -> too early.
llvm-svn: 308743
2017-07-21 15:12:03 +00:00
Siddharth Bhat a0fb8b23e1 [NFC] [PPCGCodeGeneration] Print `verifyModule` failure to debug stream.
If verifyModule fails, it is helpful to know why it failed. Add a log to
the debug stream that prints the failure.

llvm-svn: 308727
2017-07-21 11:21:44 +00:00
Tobias Grosser 018103d34e Fix typo in function name Bllock -> Block
llvm-svn: 308715
2017-07-21 06:00:38 +00:00
Tobias Grosser 1eeedf4829 [IslNodeBuilder] Relax complexity check in invariant loads and run it early
When performing invariant load hoisting we check that invariant load expressions
are not too complex. Up to this commit, we performed this check by counting the
sum of dimensions in the access range as a very simple heuristic. This heuristic
is a little too conservative, as it prevents hoisting for any scops with a
very large number of parameters. Hence, we update the heuristic to only count
existentially quantified dimensions and set dimensions. We expect this to still
detect the problematic expressions in h264 because of which this check was
originally introduced.

For some unknown reason, this complexity check was originally committed in
IslNodeBuilder. It really belongs in ScopInfo, as there is no point in
optimizing a program which we could have known earlier cannot be code generated.
The benefit of running the check early is that we can avoid to even hoist checks
that are expensive to code generate as invariant loads. This can be seen in
the changed tests, where we now indeed detect the scop, but just not invariant
load hoist the complicated access.

We also improve the formatting of the code, document it, and use isl++ to
simplify expressions.

llvm-svn: 308659
2017-07-20 19:55:19 +00:00
Tobias Grosser 54491db687 Support fabs and copysign in Polly-ACC
llvm-svn: 308649
2017-07-20 18:26:34 +00:00
Michael Kruse b936c4b332 [PPCG] Compile fix for MSVC.
Visual Studio, even the 2017 version, does not support C99 VLAs.

For VLA paramters, the length of the outermost dimension is not
required anyway, so remove it.

llvm-svn: 308643
2017-07-20 18:04:54 +00:00
Michael Kruse 1ce6791e7e [ScopInfo] Get a list of statements for a region node. NFC.
When constructing a schedule true and there are multiple statements for
a basic block, create a sequence node for these statements.

Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in>

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

llvm-svn: 308635
2017-07-20 17:18:58 +00:00
Michael Kruse 6eba4b1031 [ScopInfo] Remove dependency of Scop::getLastStmtFor(BB) on getStmtFor(BB). NFC.
We are working towards removing uses of Scop::getStmtFor(BB). In this
patch, we remove dependency of Scop::getLastStmtFor(BB) on
getStmtFor(BB). To do so, we get the list of all statements
corresponding to the BB and then fetch the last one.

Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in>

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

llvm-svn: 308633
2017-07-20 17:08:50 +00:00
Michael Kruse c4d8f9b11a Fix indention in comment. NFC.
llvm-svn: 308632
2017-07-20 16:52:22 +00:00
Michael Kruse 3562f272cf [ScopInfo] Use map for lookupPHIReadOf. NFC.
Introduce previously missing PHIReads analogous the the already existing
PHIWrites/ValueWrites/ValueReads maps. PHIReads was initially not
required and the later introduced lookupPHIReadOf() used a linear
search instead.

With PHIReads, lookupPHIReadOf() can now also do a map lookup and remove
any surprising performance/behaviour differences to lookupPHIWriteOf(),
lookupValueWriteOf() and lookupValueReadOf().

llvm-svn: 308630
2017-07-20 16:47:57 +00:00
Michael Kruse 22058c3fbb [Simplify] Remove unused instructions and accesses.
Use a mark-and-sweep algorithm to find and remove unused instructions
and MemoryAccesses. This is useful in particular to remove scalar
writes that are never used anywhere. A scalar write in a loop induces
a write-after-write dependency that stops the loop iterations to be
rescheduled. Such writes can be a result of previous transformations
such as DeLICM and operand tree forwarding.

It adds a new class VirtualInstruction that represents an instruction in
a particular statement. At the moment an instruction can only belong to
the statement that represents a BasicBlock. In the future, instructions
can be in one of multiple statements representing a BasicBlock
(Nandini's work), in different statements than its BasicBlock would
indicate, and even multiple statements at once (by forwarding operand
trees). It also integrates nicely with the VirtualUse class.

ScopStmt::contains(Instruction*) currently uses the instruction's parent
BasicBlock to check whether it contains the instruction. It will need to
check the actual statement list when one of the aforementioned features
become possible.

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

llvm-svn: 308626
2017-07-20 16:21:55 +00:00
Siddharth Bhat 9e3db2b756 [PPCGCodeGen] [3/3] Update PPCGCodeGen + tests to latest ppcg.
This commit *WILL COMPILE*.

1. `PPCG` now uses `isl_multi_pw_aff` instead of an array of `pw_aff`.
   This needs us to adjust how we index array bounds and how we construct
   array bounds.

2. `PPCG` introduces two new kinds of nodes: `init_device` and `clear_device`.
   We should investigate what the correct way to handle these are.

3. `PPCG` has gotten smarter with its use of live range reordering, so some of
   the tests have a qualitative improvement.

4. `PPCG` changed its output style, so many test cases need to be updated to
   fit the new style for `polly-acc-dump-code` checks.

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

llvm-svn: 308625
2017-07-20 15:48:36 +00:00
Siddharth Bhat 3d4d752188 [PPCG] [2/3] Make polly specific PPCG Changes.
- This commit *WILL NOT COMPILE*. `PPCGCodeGeneration` requires changes
  since some of PPCG's internal data structures have been modified.

- Has polly-speific changes to PPCG. Polly exports certain functionality that
  is private to PPCG. It also creates stubs for large parts of the pet API as
  well as other functions in `ppcg/external.c` to keep the linker happy.

- This commit includes changes to CMakeLists.txt.

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

llvm-svn: 308624
2017-07-20 15:48:22 +00:00
Siddharth Bhat 951515f236 [PPCG] [1/3] Bump up PPCG version to 0.07.
- This commit *WILL NOT COMPILE*, as it checks in vanilla PPCG 0.07
- We choose to introduce this commit into the history to cleanly display
  the Polly-specific changes made to PPCG.

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

llvm-svn: 308623
2017-07-20 15:48:13 +00:00
Michael Kruse 4642c3ce85 [ScopBuilder] Avoid use of getStmtFor(BB). NFC.
Since there will be no more a 1:1 correspondence between statements
and basic blocks, we would like to get rid of the method getStmtFor(BB)
and its uses. Here we remove one of its uses in ScopBuilder by fetching
the statement in which the instruction lies.

Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in>

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

llvm-svn: 308610
2017-07-20 12:47:09 +00:00
Michael Kruse 0865585eab [ScopInfo] Add support for wrap-around of integers in unsigned comparisons.
This is one possible solution to implement wrap-arounds for integers in
unsigned icmp operations. For example,

    store i32 -1, i32* %A_addr
    %0 = load i32, i32* %A_addr
    %1 = icmp ult i32 %0, 0

%1 should hold false, because under the assumption of unsigned integers,
-1 should wrap around to 2^32-1. However, previously. it was assumed
that the MSB (Most Significant Bit - aka the Sign bit) was never set for
integers in unsigned operations.

This patch modifies the buildConditionSets function in ScopInfo.cpp to
give better information about the integers in these unsigned
comparisons.

Contributed-by: Annanay Agarwal <cs14btech11001@iith.ac.in>

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

llvm-svn: 308608
2017-07-20 12:37:02 +00:00
Michael Kruse 89da6bbcb4 Make byref llvm::Use parameters const. NFC.
llvm-svn: 308522
2017-07-19 20:41:56 +00:00
Philip Pfaffe 17b1ecfdc5 [CMake] Fix r307650: Readd missing dependency.
The commit erroneously removed the dependency of the Polly tests on
things like opt and FileCheck. Add that dependency back.

llvm-svn: 308512
2017-07-19 19:20:58 +00:00
Eli Friedman 84c73fd9fc [docs] Minor formatting fixes.
Patch by Tarun Rajendran.

llvm-svn: 308505
2017-07-19 18:18:37 +00:00
Roman Gareev 5abea0c97a [FIX] Update test/ScheduleOptimizer/pattern-matching-based-opts_11.ll.
llvm-svn: 308501
2017-07-19 18:01:51 +00:00
Roman Gareev 6531df41ae [FIX] Fix pattern-matching-based-opts_11.ll.
llvm-svn: 308499
2017-07-19 17:33:42 +00:00
Michael Kruse 8b8058072f [ScopInfo] Integrate ScalarDefUseChain into polly::Scop. NFC.
Before this patch, ScalarDefUseChain was a tool used by DeLICM to find
all reads and writes of scalar accesses. It iterated once over all
accesses and stores the accesses into maps.

By integrating it into the Scop class, we can keep the maps up-to-date
without the need for recomputing them. It will be needed for more than
DeLICM in the future, such as SCoP simplification, code movement between
virtual statements, and array expansion (GSoC project).

Compared to ScalarUseDefChain, we save two maps by finding the ScopStmt
a Def/PHIRead must reside in, and use its already existing lookup
function to find the MemoryAccess.

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

llvm-svn: 308495
2017-07-19 17:11:25 +00:00
Roman Gareev 750374181b Make the pattern matching work with modified memory accesses
Some optimizations (e.g., DeLICM) can modify memory accesses (e.g., change
their MemoryKind). Consequently, the pattern matching should take it into
the account.

Reviewed-by: Tobias Grosser <tobias@grosser.es>,
             Michael Kruse <llvm@meinersbur.de>

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

llvm-svn: 308494
2017-07-19 16:59:06 +00:00
Tobias Grosser 199ec4af40 [ScopInfo] Do not create entries in map if non exists
Suggested-by:  Michael Kruse <llvm@meinersbur.de>
llvm-svn: 308491
2017-07-19 16:31:10 +00:00
Hans Wennborg 5a1606d562 Clear release notes for 6.0.0
llvm-svn: 308477
2017-07-19 14:11:00 +00:00
Michael Kruse 629f9185bf [Simplify] Ensure all counters are reset before next SCoP is processed. NFC.
llvm-svn: 308473
2017-07-19 14:07:21 +00:00
Hans Wennborg d3ae835c9e Bump docs version to 6.0
llvm-svn: 308464
2017-07-19 13:48:55 +00:00
Tobias Grosser 37eadd55f7 [ScopInfo] Use AnyPHINode in tryGetValueStored()
This was an oversight in the previous commit. Michael already suggested this
beforehand.

llvm-svn: 308440
2017-07-19 11:30:18 +00:00
Michael Kruse bb7d22a31a [Test] Do not pipe binary data to FileCheck.
llvm-svn: 308437
2017-07-19 11:12:16 +00:00
Tobias Grosser 303bd07c6e [ScopInfo] Introduce tryGetValueStored
Summary:
This makes code more readable and allows to reuse this functionality in
the future at other places.

Suggested-by Michael Kruse in post-commit review of r307660.

Reviewers: Meinersbur, bollu, gareevroman, efriedma, huihuiz, sebpop, simbuerg

Reviewed By: Meinersbur

Subscribers: pollydev, llvm-commits

Tags: #polly

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

llvm-svn: 308435
2017-07-19 11:09:16 +00:00
Tobias Grosser 5c88f00765 [Polly][docs][Release Notes] Adding Information about Remarks to Release Notes and Documentation
Summary: Based off of D35399

Reviewers: pollydev, llvm-commits, bollu, grosser

Reviewed By: grosser

Tags: #polly

Contributed-by: Tarun Ranjendran

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

llvm-svn: 308403
2017-07-19 01:16:55 +00:00