diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2018-07-20 22:45:24 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2018-07-20 22:45:24 +0000 |
commit | f99752b66b43a29e4ade199831f9e3f14d873090 (patch) | |
tree | 0ec4df0d9b823f089578482e5120ca4bb8927e88 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 32f7fb57138ad72190abd579732d70103c5b0f52 (diff) | |
download | bcm5719-llvm-f99752b66b43a29e4ade199831f9e3f14d873090.tar.gz bcm5719-llvm-f99752b66b43a29e4ade199831f9e3f14d873090.zip |
[HIP] Register/unregister device fat binary only once
HIP generates one fat binary for all devices after linking. However, for each compilation
unit a ctor function is emitted which register the same fat binary. Measures need to be
taken to make sure the fat binary is only registered once.
Currently each ctor function calls __hipRegisterFatBinary and stores the returned value
to __hip_gpubin_handle. This patch changes the linkage of __hip_gpubin_handle to be linkonce
so that they are shared between LLVM modules. Then this patch adds check of value of
__hip_gpubin_handle to make sure __hipRegisterFatBinary is only called once. The code
is equivalent to
void *_gpubin_handle;
void ctor() {
if (__hip_gpubin_handle == 0) {
__hip_gpubin_handle = __hipRegisterFatBinary(...);
}
// register kernels and variables.
}
The patch also does similar change to dtors so that __hipUnregisterFatBinary
is called once.
Differential Revision: https://reviews.llvm.org/D49083
llvm-svn: 337631
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions