[PATCH] D86376: [HIP] Emit kernel symbol
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 9 14:19:53 PST 2021
yaxunl added a comment.
In D86376#2552066 <https://reviews.llvm.org/D86376#2552066>, @tra wrote:
> In D86376#2551298 <https://reviews.llvm.org/D86376#2551298>, @yaxunl wrote:
>
>> Actually there is one issue with this approach.
>>
>> HIP have API's to launch kernels, which accept kernel as function pointer argument. Currently when taking address of kernel, we get the stub function. These kernel launching API's will not work if we use kernel symbol to register the kernel. A solution is to return the kernel symbol instead of stub function when taking address of the kernel in host compilation, i.e. if a function pointer is assigned to a kernel in host code, it gets the kernel symbol instead of the stub function. This will make the kernel launching API work.
>>
>> To keep the triple chevron working, the kernel symbol will be initialized with the address of the stub function. For triple chevron call, the address of the stub function is loaded from the kernel symbol and invoked.
>
> This could work.
> Do we really need an indirection? If we know the stub address when we initialize the symbol with it, we should be able to use that address for `<<<>>>`.
For triple chevron with kernel name, it is not needed. We only need indirection for a triple chevron with a function pointer, in which case we do not know its stub function at compile time. This is allowed by CUDA/HIP.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86376/new/
https://reviews.llvm.org/D86376
More information about the cfe-commits
mailing list