[PATCH] D85223: [CUDA][HIP] Support accessing static device variable in host code for -fgpu-rdc

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 19 13:07:09 PST 2021


yaxunl added a comment.

In D85223#2507518 <https://reviews.llvm.org/D85223#2507518>, @tra wrote:

> I'd propose splitting the patch into two. One with the addition of CUID and the other that changes the way we havdle static vars.
> CUID is useful on its own and is relatively uncontroversial.
>
> Externalizing static vars is a more interesting issue and I'm not sure what's the best way to handle it yet. On one hand it is necessary for visibility across host/device, on the other, externalizing all static vars will almost always have negative effect as very few of the static vars actually need this. As already pointed out in the `#if 0` section of the patch, ideally we should externalize only the vars that need it. Generally speaking, I do not think we will be able to do that, because with `-fgpu-rdc` it may be used from the host code in some other TU.
>
> We may need to explicitly annotate such the static variables that need to be visible on both sides and only apply externalization to the variables annotated this way. E.g. require them to be `__host__ __device__`.
>
> WDYT?

Agree that CUID may be useful for other situations. Will separate it to another review.


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

https://reviews.llvm.org/D85223



More information about the cfe-commits mailing list