[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.
Michael Liao via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 29 12:42:39 PDT 2019
hliao added a comment.
In D62603#1521832 <https://reviews.llvm.org/D62603#1521832>, @tra wrote:
> In D62603#1521792 <https://reviews.llvm.org/D62603#1521792>, @hliao wrote:
> > that should assume that variable is not declared with `static`. that's also the motivation of this patch.
> cppreference defines internal linkage as 'The name can be referred to from all scopes in the current translation unit.'
> The current translation unit in CUDA context gets a bit murky. On one hand host and device are compiled separately, and may conceivably be considered separate TUs. On the other hand, the fact that we mix host and device code in the same source file implies tight coupling and the users do expect them to be treated as if all host and device code in the source file is in the same TU. E.g. you may have a kernel in an anonymous namespace yet you do want to be able to launch it from the host side.
> I think `static __device__` globals would fall into the same category -- nominally they should not be visible outside of device-side object file, but in practice we do need to make them visible from the host side of the same TU.
That's true if there's a reference on the host side. E.g, if I modify `foo` function as both __host__ and __device, that host-side shadow could be generated (with 'undef` initializer as expected.)
CHANGES SINCE LAST ACTION
More information about the cfe-commits