[polly] r275954 - GPGPU: add host iterators to kernel arguments
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 19 00:33:02 PDT 2016
Author: grosser
Date: Tue Jul 19 02:32:55 2016
New Revision: 275954
URL: http://llvm.org/viewvc/llvm-project?rev=275954&view=rev
Log:
GPGPU: add host iterators to kernel arguments
Modified:
polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
polly/trunk/test/GPGPU/host-control-flow.ll
Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=275954&r1=275953&r2=275954&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Tue Jul 19 02:32:55 2016
@@ -140,7 +140,7 @@ private:
/// The kernel function takes as arguments:
///
/// - One i8 pointer for each external array reference used in the kernel.
- /// - Host iterators (TODO)
+ /// - Host iterators
/// - Parameters (TODO)
/// - Other LLVM Value references (TODO)
///
@@ -223,6 +223,11 @@ Function *GPUNodeBuilder::createKernelFu
Args.push_back(Builder.getInt8PtrTy());
}
+ int NumHostIters = isl_space_dim(Kernel->space, isl_dim_set);
+
+ for (long i = 0; i < NumHostIters; i++)
+ Args.push_back(Builder.getInt64Ty());
+
auto *FT = FunctionType::get(Builder.getVoidTy(), Args, false);
auto *FN = Function::Create(FT, Function::ExternalLinkage, Identifier,
GPUModule.get());
@@ -237,6 +242,14 @@ Function *GPUNodeBuilder::createKernelFu
Arg++;
}
+ for (long i = 0; i < NumHostIters; i++) {
+ isl_id *Id = isl_space_get_dim_id(Kernel->space, isl_dim_set, i);
+ Arg->setName(isl_id_get_name(Id));
+ IDToValue[Id] = &*Arg;
+ KernelIDs.insert(std::unique_ptr<isl_id, IslIdDeleter>(Id));
+ Arg++;
+ }
+
return FN;
}
Modified: polly/trunk/test/GPGPU/host-control-flow.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/host-control-flow.ll?rev=275954&r1=275953&r2=275954&view=diff
==============================================================================
--- polly/trunk/test/GPGPU/host-control-flow.ll (original)
+++ polly/trunk/test/GPGPU/host-control-flow.ll Tue Jul 19 02:32:55 2016
@@ -1,6 +1,9 @@
; RUN: opt %loadPolly -polly-codegen-ppcg -disable-output \
; RUN: -polly-acc-dump-code < %s | FileCheck %s -check-prefix=CODE
+; RUN: opt %loadPolly -polly-codegen-ppcg -disable-output \
+; RUN: -polly-acc-dump-kernel-ir < %s | FileCheck %s -check-prefix=KERNEL-IR
+
; RUN: opt %loadPolly -polly-codegen-ppcg \
; RUN: -S < %s | FileCheck %s -check-prefix=IR
; void foo(float A[2][100]) {
@@ -31,6 +34,15 @@
; IR-NEXT: %polly.loop_cond = icmp sle i64 %polly.indvar, 98
; IR-NEXT: br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit
+; KERNEL-IR: define ptx_kernel void @kernel_0(i8* %MemRef_A, i64 %c0) {
+; 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 @foo([100 x float]* %A) {
More information about the llvm-commits
mailing list