HIP managed variables need to be emitted as undefined symbols
since runtime needs to define them with managed memory
accessible by both device and host.
Let HIP toolchain allow that with lld.
Paths
| Differential D95970
[HIP] Allow undefined symbols AbandonedPublic Authored by yaxunl on Feb 3 2021, 1:18 PM.
Details
Summary HIP managed variables need to be emitted as undefined symbols Let HIP toolchain allow that with lld.
Diff Detail Event TimelineComment Actions What's going to happen if you do have an undefined reference that's *not* to a __managed__ variable? Comment Actions
By default HIP toolchain uses -fvisibility hidden -fapply-global-visibility-to-externs for device compilation. Undefined variable symbols have protected visibility. Undefined function symbols have hidden visibility. Since they are not allowed to be preempted, lld still emits error if they are undefined. __managed__ variables have default visibility, therefore they are allowed to go through. We can let HIP runtime emit an error if there are undefined symbols other than managed variables. Comment Actions
Is there a test that verifies/demonstrates how it's handled at compile time?
Detecting compilation errors at run-time is not very useful. The end user would likely have no idea what's going on. What if we actually resolve all __managed__ references and point them to some sort of placeholder. Comment Actions
Good point. I will try using indirection. This should avoid undefined symbols in device binary.
Revision Contents
Diff 321206 clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/hip-toolchain-device-only.hip
clang/test/Driver/hip-toolchain-no-rdc.hip
|