diff options
| author | Tobias Grosser <tobias@grosser.es> | 2017-08-19 12:58:28 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2017-08-19 12:58:28 +0000 |
| commit | 43df2020e728ef38bf54aba0f85b6a573e82cddb (patch) | |
| tree | 810e6e2fced00148fc68743e30d19fecaedcea80 /polly/lib/CodeGen/PPCGCodeGeneration.cpp | |
| parent | ee7d232a415f9152e0c1b8cdeb369d423897fa55 (diff) | |
| download | bcm5719-llvm-43df2020e728ef38bf54aba0f85b6a573e82cddb.tar.gz bcm5719-llvm-43df2020e728ef38bf54aba0f85b6a573e82cddb.zip | |
[GPGPU] Collect parameter dimension used in MemoryAccesses
When using -polly-ignore-integer-wrapping and -polly-acc-codegen-managed-memory
we add parameter dimensions lazily to the domains, which results in PPCG not
including parameter dimensions that are only used in memory accesses in the
kernel space. To make sure these parameters are still passed to the kernel, we
collect these parameter dimensions and align the kernel's parameter space
before code-generating it.
llvm-svn: 311239
Diffstat (limited to 'polly/lib/CodeGen/PPCGCodeGeneration.cpp')
| -rw-r--r-- | polly/lib/CodeGen/PPCGCodeGeneration.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index e95cf2ff548..80b61349d19 100644 --- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp +++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp @@ -436,7 +436,8 @@ private: /// in the scop, nor do they immediately surroung the Scop. /// See [Code generation of induction variables of loops outside /// Scops] - std::tuple<SetVector<Value *>, SetVector<Function *>, SetVector<const Loop *>> + std::tuple<SetVector<Value *>, SetVector<Function *>, SetVector<const Loop *>, + isl::space> getReferencesInKernel(ppcg_kernel *Kernel); /// Compute the sizes of the execution grid for a given kernel. @@ -1434,13 +1435,16 @@ getFunctionsFromRawSubtreeValues(SetVector<Value *> RawSubtreeValues, return SubtreeFunctions; } -std::tuple<SetVector<Value *>, SetVector<Function *>, SetVector<const Loop *>> +std::tuple<SetVector<Value *>, SetVector<Function *>, SetVector<const Loop *>, + isl::space> GPUNodeBuilder::getReferencesInKernel(ppcg_kernel *Kernel) { SetVector<Value *> SubtreeValues; SetVector<const SCEV *> SCEVs; SetVector<const Loop *> Loops; + isl::space ParamSpace = isl::space(S.getIslCtx(), 0, 0).params(); SubtreeReferences References = { - LI, SE, S, ValueMap, SubtreeValues, SCEVs, getBlockGenerator()}; + LI, SE, S, ValueMap, SubtreeValues, SCEVs, getBlockGenerator(), + &ParamSpace}; for (const auto &I : IDToValue) SubtreeValues.insert(I.second); @@ -1507,7 +1511,8 @@ GPUNodeBuilder::getReferencesInKernel(ppcg_kernel *Kernel) { else ReplacedValues.insert(It->second); } - return std::make_tuple(ReplacedValues, ValidSubtreeFunctions, Loops); + return std::make_tuple(ReplacedValues, ValidSubtreeFunctions, Loops, + ParamSpace); } void GPUNodeBuilder::clearDominators(Function *F) { @@ -1751,9 +1756,16 @@ void GPUNodeBuilder::createKernel(__isl_take isl_ast_node *KernelStmt) { SetVector<Value *> SubtreeValues; SetVector<Function *> SubtreeFunctions; SetVector<const Loop *> Loops; - std::tie(SubtreeValues, SubtreeFunctions, Loops) = + isl::space ParamSpace; + std::tie(SubtreeValues, SubtreeFunctions, Loops, ParamSpace) = getReferencesInKernel(Kernel); + // Add parameters that appear only in the access function to the kernel + // space. This is important to make sure that all isl_ids are passed as + // parameters to the kernel, even though we may not have all parameters + // in the context to improve compile time. + Kernel->space = isl_space_align_params(Kernel->space, ParamSpace.release()); + assert(Kernel->tree && "Device AST of kernel node is empty"); Instruction &HostInsertPoint = *Builder.GetInsertPoint(); |

