[PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 23 07:42:44 PDT 2020


yaxunl added a comment.

In D80858#2169295 <https://reviews.llvm.org/D80858#2169295>, @hliao wrote:

> I don't that's proper way to support file-scope static device variables. As we discuss APIs like cudaMemcpyToSymol, that's a runtime API instead of driver API. The later needs to specify the module (or code object) id in addition to a symbol name and won't have the conflict issues. For the runtime API, all named device variables (static or not) are identified at the host side by their host stub variables. That stub variable is used to register the corresponding device variables associated with a module id to unique identify that variables across all TUs. As long as we look up device variables using their host stub variable pointers, they are uniquely identified already. The runtime implementation needs to find the module id and the variable symbol from the pointer of its host stub variable. It's not the compiler job to fabricate name uniquely across TUs.


The problem is that even though the static variable is registered through `__hipRigisterVariable`, the runtime still relies on looking up symbol name to get the address of the device variable. That's why we need to externalize the static variable.


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

https://reviews.llvm.org/D80858





More information about the cfe-commits mailing list