[polly] r276962 - GPGPU: Pass host iterators to kernel

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 23:47:56 PDT 2016


Author: grosser
Date: Thu Jul 28 01:47:56 2016
New Revision: 276962

URL: http://llvm.org/viewvc/llvm-project?rev=276962&view=rev
Log:
GPGPU: Pass host iterators to kernel

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=276962&r1=276961&r2=276962&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Thu Jul 28 01:47:56 2016
@@ -911,6 +911,24 @@ Value *GPUNodeBuilder::createLaunchParam
     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);

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=276962&r1=276961&r2=276962&view=diff
==============================================================================
--- polly/trunk/test/GPGPU/host-control-flow.ll (original)
+++ polly/trunk/test/GPGPU/host-control-flow.ll Thu Jul 28 01:47:56 2016
@@ -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




More information about the llvm-commits mailing list