From a490147c908272a85285a658850ca47949773b9d Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Thu, 28 Jul 2016 06:47:56 +0000 Subject: [PATCH] GPGPU: Pass host iterators to kernel llvm-svn: 276962 --- polly/lib/CodeGen/PPCGCodeGeneration.cpp | 18 ++++++++++++++++++ polly/test/GPGPU/host-control-flow.ll | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index 3a6b80b75a39..f8cf3b78515d 100644 --- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp +++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp @@ -911,6 +911,24 @@ Value *GPUNodeBuilder::createLaunchParameters(ppcg_kernel *Kernel, Index++; } + int NumHostIters = isl_space_dim(Kernel->space, isl_dim_set); + + for (long i = 0; i < NumHostIters; i++) { + isl_id *Id = isl_space_get_dim_id(Kernel->space, isl_dim_set, i); + Value *Val = IDToValue[Id]; + isl_id_free(Id); + Instruction *Param = new AllocaInst( + Val->getType(), Launch + "_param_" + std::to_string(Index), + EntryBlock->getTerminator()); + Builder.CreateStore(Val, Param); + Value *Slot = Builder.CreateGEP( + Parameters, {Builder.getInt64(0), Builder.getInt64(Index)}); + Value *ParamTyped = + Builder.CreatePointerCast(Param, Builder.getInt8PtrTy()); + Builder.CreateStore(ParamTyped, Slot); + Index++; + } + auto Location = EntryBlock->getTerminator(); return new BitCastInst(Parameters, Builder.getInt8PtrTy(), Launch + "_params_i8ptr", Location); diff --git a/polly/test/GPGPU/host-control-flow.ll b/polly/test/GPGPU/host-control-flow.ll index 7f41a11bb0ae..19f37b636ea2 100644 --- a/polly/test/GPGPU/host-control-flow.ll +++ b/polly/test/GPGPU/host-control-flow.ll @@ -31,6 +31,10 @@ ; IR-LABEL: polly.loop_header: ; preds = %polly.loop_header, %polly.loop_preheader ; IR-NEXT: %polly.indvar = phi i64 [ 0, %polly.loop_preheader ], [ %polly.indvar_next, %polly.loop_header ] ; ... +; IR: store i64 %polly.indvar, i64* %polly_launch_0_param_1 +; IR-NEXT: %6 = getelementptr [2 x i8*], [2 x i8*]* %polly_launch_0_params, i64 0, i64 1 +; IR-NEXT: %7 = bitcast i64* %polly_launch_0_param_1 to i8* +; IR-NEXT: store i8* %7, i8** %6 ; IR: call i8* @polly_getKernel ; ... ; IR: call void @polly_freeKernel