Commit Graph

3241 Commits

Author SHA1 Message Date
Singapuram Sanjay Srivallabh 02ca346e48 Introduce a hybrid target to generate code for either the GPU or CPU
Summary:
Introduce a "hybrid" `-polly-target` option to optimise code for either the GPU or CPU.

When this target is selected, PPCGCodeGeneration will attempt first to optimise a Scop. If the Scop isn't modified, it is then sent to the passes that form the CPU pipeline, i.e. IslScheduleOptimizerPass, IslAstInfoWrapperPass and CodeGeneration.

In case the Scop is modified, it is marked to be skipped by the subsequent CPU optimisation passes.

Reviewers: grosser, Meinersbur, bollu

Reviewed By: grosser

Subscribers: kbarton, nemanjai, pollydev

Tags: #polly

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

llvm-svn: 306863
2017-06-30 19:42:21 +00:00
Tobias Grosser 37c8ee7611 Fix typo
llvm-svn: 306791
2017-06-30 06:30:51 +00:00
Chandler Carruth 16879be0da Update Polly to reflect a change to a clang-format patch. I'm not sure
this is a great test file name based on this update, but I'll let Polly
folks sort out how they want this to work long-term, I just want tho
bots back.

llvm-svn: 306767
2017-06-29 23:58:03 +00:00
NAKAMURA Takumi b49ca64b18 Test commit
llvm-svn: 306696
2017-06-29 16:35:38 +00:00
Michael Kruse 476f855ec8 [ScopInfo] Do not use ScopStmt in Domain derivation of ScopInfo. NFC
ScopStmts were being used in the computation of the Domain of the SCoPs
in ScopInfo. Once statements are split, there will not be a 1-to-1
correspondence between Stmts and Basic blocks. Thus this patch avoids
the use of getStmtFor() by creating a map of BB to InvalidDomain and
using it to compute the domain of the statements.

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

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

llvm-svn: 306667
2017-06-29 12:47:41 +00:00
NAKAMURA Takumi 6936506f50 Test commit
llvm-svn: 306657
2017-06-29 09:46:01 +00:00
Singapuram Sanjay Srivallabh 42caad0257 Initializing NVPTX backend within Polly
Summary:
The NVPTX backend is now initialised within Polly. A language front-end need not be modified to initialise the backend, just for Polly.

Reviewers: Meinersbur, grosser

Reviewed By: Meinersbur

Subscribers: vchuravy, mgorny

Tags: #polly

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

llvm-svn: 306649
2017-06-29 07:43:22 +00:00
Michael Kruse b738ffa845 Heap allocation for new arrays.
This patch aims to implement the option of allocating new arrays created
by polly on heap instead of stack. To enable this option, a key named
'allocation' must be written in the imported json file with the value
'heap'.

We need such a feature because in a next iteration, we will implement a
mechanism of maximal static expansion which will need a way to allocate
arrays on heap. Indeed, the expansion is very costly in terms of memory
and doing the allocation on stack is not worth considering.

The malloc and the free are added respectively at polly.start and
polly.exiting such that there is no use-after-free (for instance in case
of Scop in a loop) and such that all memory cells allocated with a
malloc are free'd when we don't need them anymore.

We also add :

- In the class ScopArrayInfo, we add a boolean as member called IsOnHeap
  which represents the fact that the array in allocated on heap or not.
- A new branch in the method allocateNewArrays in the ISLNodeBuilder for
  the case of heap allocation. allocateNewArrays now takes a BBPair
  containing polly.start and polly.exiting. allocateNewArrays takes this
  two blocks and add the malloc and free calls respectively to
  polly.start and polly.exiting.
- As IntPtrTy for the malloc call, we use the DataLayout one.

To do that, we have modified :

- createScopArrayInfo and getOrCreateScopArrayInfo such that it returns
  a non-const SAI, in order to be able to call setIsOnHeap in the
  JSONImporter.
- executeScopConditionnaly such that it return both start block and end
  block of the scop, because we need this two blocs to be able to add
  the malloc and the free calls at the right position.

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

llvm-svn: 306540
2017-06-28 13:02:43 +00:00
Tobias Grosser 72d2539937 Test commit
llvm-svn: 306539
2017-06-28 12:58:44 +00:00
Andreas Simbuerger 6d08ec7233 [JSONImport] Check, if the size of an imported array is positive
llvm-svn: 306479
2017-06-27 22:30:44 +00:00
Andreas Simbuerger dbb0ef8e94 [NFC][CodeGen] Use the ExitBlock explicitly.
Before we would 'guess' the correct location for the MergeBlock
that got introduced when executing a Scop conditionally. This
implicitly depends on the situation that at this point during
CodeGen there will be nothing between polly.start and polly.exiting.

With this commit we explicitly state that we want the block that
directly follows polly.exiting.

llvm-svn: 306398
2017-06-27 11:33:22 +00:00
Andreas Simbuerger 4e6eed8566 [FIX] Add %loadPolly to test
This test fails, if polly is not linked into LLVM's tools. Our
lit site-config already deals with this by not adding the -load
option, if polly is linked into LLVM's tools.

llvm-svn: 306395
2017-06-27 10:47:55 +00:00
Siddharth Bhat 65d7f72f2c [PPCGCodeGeneration] Add flag to allow polly to fail in GPU kernel fails.
- This is useful for debugging GPU code.

llvm-svn: 306290
2017-06-26 14:56:56 +00:00
Siddharth Bhat f291c8d510 [PPCGCodeGeneration] Allow intrinsics within kernels.
- In D33414, if any function call was found within a kernel, we would bail out.

- This is an over-approximation. This patch changes this by allowing the
  `llvm.sqrt.*` family of intrinsics.

- This introduces an additional step when creating a separate llvm::Module
  for a kernel (GPUModule). We now copy function declarations from the
  original module to new module.

- We also populate IslNodeBuilder::ValueMap so it replaces the function
  references to the old module to the ones in the new module
  (GPUModule).

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

llvm-svn: 306284
2017-06-26 13:12:06 +00:00
Andreas Simbuerger 256070d85c [NFC] Return both polly.start and polly.exiting from executeScopConditionally.
This commit returns both the start and the exit block that are created
by executeScopConditionally.

In a future commit we will make use of the exit block. Before we would
have to use the implicit property that there won't be any code generated
between polly.start and polly.exiting at the time of use to find the
correct block ('polly.exiting').

All usage location are semantically unchanged.

llvm-svn: 306283
2017-06-26 12:17:11 +00:00
Tobias Grosser 2927cb7520 [tests] Add forgotten pollyacc REQUIRES line
llvm-svn: 306273
2017-06-26 06:07:40 +00:00
Siddharth Bhat a12f807f33 [PPCGCodeGeneration] Enable GPU code generation with invariant loads.
The condition that disallowed code generation in PPCGCodeGeneration with
invariant loads is not required. I haven't been able to construct a
counterexample where this generates invalid code.

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

llvm-svn: 306245
2017-06-25 14:48:24 +00:00
Tobias Grosser 812bc3c983 Test commit
llvm-svn: 306244
2017-06-25 14:22:32 +00:00
Tobias Grosser 1b9d1bcc6d [ScopInfo] Bound the number of array disjuncts in run-time bounds checks
This reduces the compilation time of one reduced test case from Android from
16 seconds to 100 mseconds (we bail out), without negatively impacting any
other test case we currently have.

We still saw occasionally compilation timeouts on the AOSP buildbot. Hopefully,
those will go away with this change.

llvm-svn: 306235
2017-06-25 06:32:00 +00:00
Roman Gareev c4a4d04717 [FIX] A small addition to r305675.
llvm-svn: 306234
2017-06-25 06:30:11 +00:00
Tobias Grosser c948178af8 Update to latest clang-format changes
llvm-svn: 306203
2017-06-24 05:23:10 +00:00
Michael Kruse 7604d9add5 [ScopBuilder] Pass ScopStmts around instead of BasicBlocks. NFC.
During the construction of MemoryAccesses in ScopBuilder, BasicBlocks
were used in function parameters, assuming that the ScopStmt an be
directly derived from it. This won't be true anymore once we split
BasicBlocks into multiple ScopStmt. As a preparation for such a change
in the future, we instead pass the ScopStmt and avoid the use of
getStmtFor().

There are two occasions where a kind of mapping from BasicBlock to
ScopStmt is still required.

1. Get the statement representing the incoming block of a `PHINode`
   using `getLastStmtOf`.

2. One statement is required to write a scalar to be readable by those
   which need it. This is most often the statement which contains its
   definition, which we get using `getStmtFor(Instruction*)`.

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

llvm-svn: 306132
2017-06-23 17:55:36 +00:00
Tobias Grosser 78a7a6cddf Bail out early in case we see an invalid runtime context in buildAliasGroups
llvm-svn: 306088
2017-06-23 08:05:31 +00:00
Tobias Grosser 57a1d36d98 Hoist buildMinMaxAccess computeout to cover full alias-group
This allows us to bail out both in case the lexmin/max computation is too
expensive, but also in case the commulative cost across an alias group is
too expensive. This is an improvement of r303404, which did not seem to
be sufficient to keep the Android Buildbot quiet.

llvm-svn: 306087
2017-06-23 08:05:27 +00:00
Tobias Grosser 8f23fb8486 [islpp] Move buildMinMaxAccess[es] to C++ [NFC]
llvm-svn: 306086
2017-06-23 08:05:20 +00:00
Eli Friedman 5e589ea4b1 [ScopInfo] Fix crash with sum of invariant load and AddRec.
r303971 added an assertion that SCEV addition involving an AddRec
and a SCEVUnknown must involve a dominance relation: either the
SCEVUnknown value dominates the AddRec's loop, or the AddRec's
loop header dominates the SCEVUnknown. This is generally fine
for most usage of SCEV because it isn't possible to write an
expression in IR which would violate it, but it's a bit inconvenient
here for polly.

To solve the issue, just avoid creating a SCEV expression which
triggers the asssertion.

I'm not really happy with this solution, but I don't have any better
ideas.

Fixes https://bugs.llvm.org/show_bug.cgi?id=33464.

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

llvm-svn: 305864
2017-06-20 22:53:02 +00:00
Reid Kleckner df2b283bf9 Fix -Wsign-compare in ScopInfo.cpp
llvm::Loop::getNumBlocks returns an unsigned int, not a long.

llvm-svn: 305717
2017-06-19 17:44:02 +00:00
Tobias Grosser dcd94e3e93 [ScheduleOptimizer] Fix minor typo [NFC]
llvm-svn: 305709
2017-06-19 16:55:48 +00:00
Tobias Grosser 2fb3ed200a [ScheduleOptimizer] Move isolateFullPartialTiles and isolateAndUnrollMatMulInnerLoops to C++
llvm-svn: 305676
2017-06-19 10:40:12 +00:00
Michael Kruse 214deb7960 [CodeGen] Emit aliasing metadata for new arrays.
Ensure that all array base pointers are assigned before generating
aliasing metadata by allocating new arrays beforehand.

Before this patch, getBasePtr() returned nullptr for new arrays because
the arrays were created at a later point. Nullptr did not match to any
array after the created array base pointers have been assigned and when
the loads/stores are generated.

llvm-svn: 305675
2017-06-19 10:19:29 +00:00
Michael Kruse 4aac459ca6 [CodeGen] Deterministic aliasing metadata order. NFC.
Replace DenseMap by a MapVector to enure that aliasing metadata is
always emitted in the same order.

llvm-svn: 305674
2017-06-19 10:19:23 +00:00
Tobias Grosser c016d2d02a [doc] Add Davide's links regarding automated bisecting
llvm-svn: 305634
2017-06-17 08:44:12 +00:00
Tobias Grosser 3addd89dd0 Add information about bisecting
llvm-svn: 305633
2017-06-17 07:45:44 +00:00
Siddharth Bhat c705003275 [Docs] Add a catch-all file to document workflow & tricks.
- Write about `bugpoint` and `git-svn` for now.

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

llvm-svn: 305464
2017-06-15 12:43:12 +00:00
Eli Friedman 127e0cd21b Don't check side effects for functions outside of SCoP
In r304074 we introduce a patch to accept results from side effect free
functions into SCEV modeling. This causes rejection of cases where the
call is happening outside the SCoP. This patch checks if the call is
outside the Region and treats the results as a parameter (SCEVType::PARAM)
to the SCoP instead of returning SCEVType::INVALID.

Patch by Sameer Abu Asal.

llvm-svn: 305423
2017-06-14 22:43:28 +00:00
Tobias Grosser a710dcfb6a [www] Add missing '.' at the end of the sentence
llvm-svn: 305336
2017-06-13 23:09:54 +00:00
Tobias Grosser 0fea84e5b9 [www] Add the new AOSP buildbot to release notes
llvm-svn: 305334
2017-06-13 23:09:09 +00:00
Tobias Grosser 2531a5d827 [www] Remove outdated documentation
Remove examples 'load_Polly_into_clang' and 'manual_matmul'. This information is
now available in our SPHINX docs (*).

(*) Thanks to Singapuram Sanjay Srivallabh <singapuram.sanjay@gmail.com> who
contributed the SPHINX docs update!

llvm-svn: 305186
2017-06-12 12:21:47 +00:00
Siddharth Bhat bccaea57c0 [Polly] [PPCGCodeGeneration] Skip Scops which contain function pointers.
In `PPCGCodeGeneration`, we try to take the references of every `Value`
that is used within a Scop to offload to the kernel. This occurs in
`GPUNodeBuilder::createLaunchParameters`.

This breaks if one of the values is a function pointer, since one of
these cases will trigger:

1. We try to to take the references of an intrinsic function, and this
breaks at `verifyModule`, since it is illegal to take the reference of
an intrinsic.

2. We manage to take the reference to a function, but this fails at
`verifyModule` since the function will not be present in the module that
is created in the kernel.

3. Even if `verifyModule` succeeds (which should not occur), we would
then try to call a *host function* from the *device*, which is
illegal runtime behaviour.

So, we disable this entire range of possibilities by simply not allowing
function references within a `Scop` which corresponds to a kernel.

However, note that this is too conservative. We *can* allow intrinsics
within kernels if the backend can lower the intrinsic correctly. For
example, an intrinsic like `llvm.powi.*` can actually be lowered by the `NVPTX`
backend.

We will now gradually whitelist intrinsics which are known to be safe.

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

llvm-svn: 305185
2017-06-12 11:41:09 +00:00
Siddharth Bhat 8139e2eb75 [NFC] Fix typo in `ImportJScop` declaration.
Contributed by: Singapuram Sanjay

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

llvm-svn: 305183
2017-06-12 09:43:12 +00:00
Tobias Grosser 0b103d92c1 [isl-cpp] Remove isl/mat.h and add insert_partial_schedule
The isl/mat.h functionality was incomplete (we returned 'void *' instead of
'isl::mat') and is likely not needed.

*.insert_partial_schedule was until know not exported in the bindings, but will
be needed in the next step.

llvm-svn: 305161
2017-06-11 04:39:21 +00:00
Siddharth Bhat 286c916dde [Polly] [ScopDetection] Allow passing multiple functions to `-polly-only-func`.
- This is useful to run optimisations on only certain functions.

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

llvm-svn: 305060
2017-06-09 08:23:40 +00:00
Michael Kruse a6d48f59a1 Fix a lot of typos. NFC.
llvm-svn: 304974
2017-06-08 12:06:15 +00:00
Tobias Grosser 4071cb571a [ScopInfo] Translate getNonHoistableCtx to C++ [NFC]
llvm-svn: 304841
2017-06-06 23:13:02 +00:00
Philip Pfaffe 182807a88f [CMake] Retire Polly's FindCUDA.cmake in favour of CMake's default FindCUDA.cmake script.
Patch by: Singapuram Sanjay

Reviewers: grosser, philip.pfaffe

Reviewed By: philip.pfaffe

Subscribers: pollydev, mgorny

Tags: #polly

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

llvm-svn: 304818
2017-06-06 19:20:48 +00:00
Michael Kruse 281f414c9d [JScop] Emit error messages on error.
In importArrays instead of silently ignoring the file.

llvm-svn: 304817
2017-06-06 19:17:32 +00:00
Michael Kruse ad7a1805be [Simplify] Use execution order of memory accesses.
Iterate through memory accesses in execution order (first all implicit reads,
then explicit accesses, then implicit writes).

In the test case this caused an implicit load to be handled as if it was loaded
after the write. That is, the value being written before it is available.

This fixes llvm.org/PR33323

llvm-svn: 304810
2017-06-06 17:46:42 +00:00
Tobias Grosser deefbced96 [Polly] [BlockGen] Support partial writes in regions
Summary:
The RegionGenerator traditionally kept a BlockMap that mapped from original
basic blocks to newly generated basic blocks. With the introduction of partial
writes such a 1:1 mapping is not possible any more, as a single basic block
can be code generated into multiple basic blocks. Hence, depending on the use
case we need to either use the first basic block or the last basic block.

This is intended to address the last four cases of incorrect code generation
in our AOSP buildbot and hopefully should turn it green.

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

Reviewed By: Meinersbur

Subscribers: pollydev, llvm-commits

Tags: #polly

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

llvm-svn: 304808
2017-06-06 17:17:30 +00:00
Michael Kruse be194d4efd [CodeGen] Remove extra ';'. NFC.
Fix compiler warning:

polly/lib/CodeGen/PerfMonitor.cpp:81:2: warning: extra ‘;’ [-Wpedantic]
 };
  ^

llvm-svn: 304802
2017-06-06 15:56:50 +00:00
Tobias Grosser 1fa569db23 [www] Fix links to bug tracker
The LLVM bug tracker is now available at bugs.llvm.org instead of llvm.org/bugs.
By updating our links to the tracker we do not only avoid unnecessary redirects,
but also certificate warnings.

We use this opportunity to shorten the text and to rename the link 'open bugs'
to 'show open bugs' to clearify its meaning.

llvm-svn: 304768
2017-06-06 06:23:20 +00:00