From 79f13b9a80c9382634ee543f7d67663a5fc4fb6a Mon Sep 17 00:00:00 2001 From: Singapuram Sanjay Srivallabh Date: Wed, 5 Jul 2017 16:48:21 +0000 Subject: 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 --- polly/lib/CodeGen/PPCGCodeGeneration.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'polly/lib/CodeGen/PPCGCodeGeneration.cpp') diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index b882455c620..4e49d1c46ff 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 &SubtreeValues) { std::vector 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 &SubtreeValues, SetVector &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) { -- cgit v1.2.3