GPGPU: Pass host iterators to kernel

llvm-svn: 276962
This commit is contained in:
Tobias Grosser 2016-07-28 06:47:56 +00:00
parent 44143bb927
commit a490147c90
2 changed files with 22 additions and 0 deletions

View File

@ -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);

View File

@ -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