[polly] r275955 - GPGPU: add scop parameters to kernel arguments
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 19 00:33:07 PDT 2016
Author: grosser
Date: Tue Jul 19 02:33:06 2016
New Revision: 275955
URL: http://llvm.org/viewvc/llvm-project?rev=275955&view=rev
Log:
GPGPU: add scop parameters to kernel arguments
Added:
polly/trunk/test/GPGPU/kernel-params-scop-parameter.ll
Modified:
polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=275955&r1=275954&r2=275955&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Tue Jul 19 02:33:06 2016
@@ -141,7 +141,7 @@ private:
///
/// - One i8 pointer for each external array reference used in the kernel.
/// - Host iterators
- /// - Parameters (TODO)
+ /// - Parameters
/// - Other LLVM Value references (TODO)
///
/// @param Kernel The kernel to generate the function declaration for.
@@ -228,6 +228,11 @@ Function *GPUNodeBuilder::createKernelFu
for (long i = 0; i < NumHostIters; i++)
Args.push_back(Builder.getInt64Ty());
+ int NumVars = isl_space_dim(Kernel->space, isl_dim_param);
+
+ for (long i = 0; i < NumVars; i++)
+ Args.push_back(Builder.getInt64Ty());
+
auto *FT = FunctionType::get(Builder.getVoidTy(), Args, false);
auto *FN = Function::Create(FT, Function::ExternalLinkage, Identifier,
GPUModule.get());
@@ -247,6 +252,14 @@ Function *GPUNodeBuilder::createKernelFu
Arg->setName(isl_id_get_name(Id));
IDToValue[Id] = &*Arg;
KernelIDs.insert(std::unique_ptr<isl_id, IslIdDeleter>(Id));
+ Arg++;
+ }
+
+ for (long i = 0; i < NumVars; i++) {
+ isl_id *Id = isl_space_get_dim_id(Kernel->space, isl_dim_param, i);
+ Arg->setName(isl_id_get_name(Id));
+ IDToValue[Id] = &*Arg;
+ KernelIDs.insert(std::unique_ptr<isl_id, IslIdDeleter>(Id));
Arg++;
}
Added: polly/trunk/test/GPGPU/kernel-params-scop-parameter.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/kernel-params-scop-parameter.ll?rev=275955&view=auto
==============================================================================
--- polly/trunk/test/GPGPU/kernel-params-scop-parameter.ll (added)
+++ polly/trunk/test/GPGPU/kernel-params-scop-parameter.ll Tue Jul 19 02:33:06 2016
@@ -0,0 +1,43 @@
+; RUN: opt %loadPolly -polly-codegen-ppcg -polly-acc-dump-kernel-ir \
+; RUN: -disable-output < %s | \
+; RUN: FileCheck -check-prefix=KERNEL-IR %s
+
+; void kernel_params_scop_parameter(float A[], long n) {
+; for (long i = 0; i < n; i++)
+; A[i] += 42;
+; }
+
+; KERNEL-IR: define ptx_kernel void @kernel_0(i8* %MemRef_A, i64 %n) {
+; KERNEL-IR-NEXT: entry:
+; KERNEL-IR-NEXT: %0 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
+; KERNEL-IR-NEXT: %b0 = zext i32 %0 to i64
+; KERNEL-IR-NEXT: %1 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+; KERNEL-IR-NEXT: %t0 = zext i32 %1 to i64
+; KERNEL-IR-NEXT: ret void
+; KERNEL-IR-NEXT: }
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @kernel_params_scop_parameter(float* %A, i64 %n) {
+bb:
+ br label %bb1
+
+bb1: ; preds = %bb6, %bb
+ %i.0 = phi i64 [ 0, %bb ], [ %tmp7, %bb6 ]
+ %tmp = icmp slt i64 %i.0, %n
+ br i1 %tmp, label %bb2, label %bb8
+
+bb2: ; preds = %bb1
+ %tmp3 = getelementptr inbounds float, float* %A, i64 %i.0
+ %tmp4 = load float, float* %tmp3, align 4
+ %tmp5 = fadd float %tmp4, 4.200000e+01
+ store float %tmp5, float* %tmp3, align 4
+ br label %bb6
+
+bb6: ; preds = %bb2
+ %tmp7 = add nuw nsw i64 %i.0, 1
+ br label %bb1
+
+bb8: ; preds = %bb1
+ ret void
+}
More information about the llvm-commits
mailing list