diff options
author | Singapuram Sanjay Srivallabh <singapuram.sanjay@gmail.com> | 2017-07-05 16:48:21 +0000 |
---|---|---|
committer | Singapuram Sanjay Srivallabh <singapuram.sanjay@gmail.com> | 2017-07-05 16:48:21 +0000 |
commit | 79f13b9a80c9382634ee543f7d67663a5fc4fb6a (patch) | |
tree | 2577fda9cdb97a78064a7889ff51480015b14e82 /polly/lib | |
parent | 7538b35cef29c835879c0a4e8cb333ac886c9be9 (diff) | |
download | llvm-79f13b9a80c9382634ee543f7d67663a5fc4fb6a.zip llvm-79f13b9a80c9382634ee543f7d67663a5fc4fb6a.tar.gz llvm-79f13b9a80c9382634ee543f7d67663a5fc4fb6a.tar.bz2 |
Prefix the name of the calling host function in the name of callee GPU kernel
Summary:
Provide more context to the name of a GPU kernel by prefixing its name with the host function that calls it. E.g. The first kernel called by `gemm` would be `FUNC_gemm_KERNEL_0`.
Kernels currently follow the "kernel_#" (# = 0,1,2,3,...) nomenclature. This patch makes it easier to map host caller and device callee, especially when there are many kernels produced by Polly-ACC.
Reviewers: grosser, Meinersbur, bollu, philip.pfaffe, kbarton!
Reviewed By: grosser
Subscribers: nemanjai, pollydev
Tags: #polly
Differential Revision: https://reviews.llvm.org/D33985
llvm-svn: 307173
Diffstat (limited to 'polly/lib')
-rw-r--r-- | polly/lib/CodeGen/PPCGCodeGeneration.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index b882455..4e49d1c 100644 --- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp +++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp @@ -299,6 +299,9 @@ public: /// The maximal number of loops surrounding a parallel kernel. unsigned DeepestParallel = 0; + /// Return the name to set for the ptx_kernel. + std::string getKernelFuncName(int Kernel_id); + private: /// A vector of array base pointers for which a new ScopArrayInfo was created. /// @@ -662,6 +665,11 @@ private: Value *Parameters); }; +std::string GPUNodeBuilder::getKernelFuncName(int Kernel_id) { + return "FUNC_" + S.getFunction().getName().str() + "_KERNEL_" + + std::to_string(Kernel_id); +} + void GPUNodeBuilder::initializeAfterRTH() { BasicBlock *NewBB = SplitBlock(Builder.GetInsertBlock(), &*Builder.GetInsertPoint(), &DT, &LI); @@ -1621,7 +1629,7 @@ void GPUNodeBuilder::createKernel(__isl_take isl_ast_node *KernelStmt) { Builder.SetInsertPoint(&HostInsertPoint); Value *Parameters = createLaunchParameters(Kernel, F, SubtreeValues); - std::string Name = "kernel_" + std::to_string(Kernel->id); + std::string Name = getKernelFuncName(Kernel->id); Value *KernelString = Builder.CreateGlobalStringPtr(ASMString, Name); Value *NameString = Builder.CreateGlobalStringPtr(Name, Name + "_name"); Value *GPUKernel = createCallGetKernel(KernelString, NameString); @@ -1662,7 +1670,7 @@ Function * GPUNodeBuilder::createKernelFunctionDecl(ppcg_kernel *Kernel, SetVector<Value *> &SubtreeValues) { std::vector<Type *> Args; - std::string Identifier = "kernel_" + std::to_string(Kernel->id); + std::string Identifier = getKernelFuncName(Kernel->id); for (long i = 0; i < Prog->n_array; i++) { if (!ppcg_kernel_requires_array_argument(Kernel, i)) @@ -1926,7 +1934,7 @@ void GPUNodeBuilder::createKernelVariables(ppcg_kernel *Kernel, Function *FN) { void GPUNodeBuilder::createKernelFunction( ppcg_kernel *Kernel, SetVector<Value *> &SubtreeValues, SetVector<Function *> &SubtreeFunctions) { - std::string Identifier = "kernel_" + std::to_string(Kernel->id); + std::string Identifier = getKernelFuncName(Kernel->id); GPUModule.reset(new Module(Identifier, Builder.getContext())); switch (Arch) { |