# AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels.ClosedPublicActions

Authored by nhaustov on Jun 15 2016, 3:42 AM.

# Details

Summary

Summary:
Change Clang calling convention SpirKernel to OpenCLKernel.
Set calling convention OpenCLKernel for amdgcn as well.
Add virtual method .getOpenCLKernelCallingConv() to TargetCodeGenInfo
and use it to set target calling convention for AMDGPU and SPIR.
Update tests.

# Diff Detail

### Event Timeline

nhaustov updated this revision to Diff 60805.Jun 15 2016, 3:42 AM
nhaustov retitled this revision from to AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels..
nhaustov updated this object.
Herald added a subscriber: kzhuravl. Jun 15 2016, 3:42 AM

Does this new patch fix the OpenCL regression?

Does this new patch fix the OpenCL regression?

Yes, it fixes the problem with calling kernel from kernel. I'll add a test too.

nhaustov updated this revision to Diff 61247.Jun 20 2016, 4:26 AM

Add test for calling OpenCL kernel from kernel.

This seems OK to me.

yaxunl edited edge metadata.Jun 27 2016, 7:51 AM

I am wondering what's the difference between this calling convention and spir_kernel.

I am wondering what's the difference between this calling convention and spir_kernel.

spir_kernel has only effect and was created only for SPIR target. In theory it could perhaps be reused for AMDGPU target, however it seems not very clear to me.

I am wondering what's the difference between this calling convention and spir_kernel.

spir_kernel has only effect and was created only for SPIR target. In theory it could perhaps be reused for AMDGPU target, however it seems not very clear to me.

If the new calling convention is to indicate a function is an OpenCL kernel, then it has exactly the same meaning as spir_kernel. Can we just use it in AMDGPU target?

I am wondering what's the difference between this calling convention and spir_kernel.

spir_kernel has only effect and was created only for SPIR target. In theory it could perhaps be reused for AMDGPU target, however it seems not very clear to me.

I am wondering what's the difference between this calling convention and spir_kernel.

spir_kernel has only effect and was created only for SPIR target. In theory it could perhaps be reused for AMDGPU target, however it seems not very clear to me.

If the new calling convention is to indicate a function is an OpenCL kernel, then it has exactly the same meaning as spir_kernel. Can we just use it in AMDGPU target?

This looks like a hack to me. Calling conventions in LLVM IR are really target specific. spir_kernel really doesn't make sense for anything other than SPIR.

Maybe we can use the fact that calling conventions are separate in AST and in LLVM IR. So in AST maybe we can have opencl_kernel and in LLVM it can map to spir_kernel for SPIR and amdgpu_kernel for AMDGPU.

lib/Basic/Targets.cpp
2141

One extra line?

Maybe we can use the fact that calling conventions are separate in AST and in LLVM IR. So in AST maybe we can have opencl_kernel and in LLVM it can map to spir_kernel for SPIR and amdgpu_kernel for AMDGPU.

This approach looks good to me. Thanks.

nhaustov updated this revision to Diff 62198.Jun 29 2016, 3:17 AM