[PATCH] D110337: [AMDGPU] Use "amdgpu-hostcalls" attribute to detect if a kernel function hostcall for GPU printf.

Yaxun Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 30 08:08:45 PDT 2021


yaxunl added a comment.

In D110337#3032804 <https://reviews.llvm.org/D110337#3032804>, @JonChesterfield wrote:

> In D110337#3032494 <https://reviews.llvm.org/D110337#3032494>, @yaxunl wrote:
>
>> We need to check the IR to know whether host call is needed since backend depends on that to determine whether to emit implicit kernel arg runtime metadata. How do we check IR for your approach? Are you suggesting to convey the host call information by symbol instead of runtime metadata? That would be an ABI change.
>
> I suppose you'd look for the asm block instead of the function or tag the whole IR module with some metadata. It hadn't occurred to me that hostcall would need any special support in the back end. What runtime metadata stuff does it require?

Then you have to check the text of asm block. It does not seem to be a stable way. A module flag seems better way to convey that info in IR.

For the reason why backend needs to know whether a kernel needs hostcall buffer, search "hidden_hostcall_buffer" at https://llvm.org/docs/AMDGPUUsage.html#code-object-v3-metadata . It is a per kernel metadata which runtime uses to decide whether to allocate hostcall buffer for a kernel. Changing that would change ABI. I don't think we want to do that.



================
Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:69
+  assert(Bb && Bb->getParent());
+  Bb->getParent()->addFnAttr("amdgpu-hostcalls");
+  return Call;
----------------
Instead of emit a function attr, we can emit a module flag, then we can avoid checking func attr for every function later.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110337/new/

https://reviews.llvm.org/D110337



More information about the llvm-commits mailing list