[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 29 12:31:14 PDT 2019


tra added a comment.

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.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62603





More information about the cfe-commits mailing list