[PATCH] D77743: [HIP] Emit symbols with kernel name in host binary

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 8 10:18:54 PDT 2020


yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.

HIP provide host API to allow C/C++ programs to
launch kernel. A C/C++ program can declare a HIP
kernel as an external function and pass it to
the kernel launching API. When linked with object
files built from HIP programs. These external functions
will resolve to symbols with the same name in HIP
programs so that kernels with the same name can be
found and launched.

This requires clang to emit symbols with the same
name as kernels in object files and use them to
identify kernels, instead of using device stub
functions to identify kernels, since device stub
function has different names than kernels.

This patch lets clang emits a void* type global
variable for each kernel in host IR, which is
called kernel handle. The kernel handle has the
same mangled name as kernel by host ABI. It is
passed to __hipRegisterFunction and kernel launching
functions for identifying kernels.


https://reviews.llvm.org/D77743

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/test/CodeGenCUDA/Inputs/cuda.h
  clang/test/CodeGenCUDA/cxx-call-kernel.cpp
  clang/test/CodeGenCUDA/kernel-stub-name.cu
  clang/test/CodeGenCUDA/unnamed-types.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77743.256047.patch
Type: text/x-patch
Size: 7109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200408/6f62e4b1/attachment-0001.bin>


More information about the cfe-commits mailing list