yaxunl added a comment.

In D115039#3174154 <https://reviews.llvm.org/D115039#3174154>, @tra wrote:

>> Put __hip_gpubin_handle in comdat when it has linkonce_odr linkage.
>
> I wonder when would this happen? I'm not sure we ever want gpubin handles 
> from different TUs merged.  I think it may result in different TUs attempting 
> to load/init the same GPU binary multiple times.

For -fgpu-rdc case, `__hip_gpubin_handle` is a global variable shared by all 
TU. This is because in the global ctor function for each TU there is logic like

  void init_fun() {
    if (__hip_gpubin_handle)
       __hip_gpubin_handle = __hipRegisterFatbinary(__hip_fatbin);
  }

Since all TU share the same `__hip_fatbin`, we need this to avoid duplicate 
registration of `__hip_fatbin`. Since `__hip_gpubin_handle` needs to be defined 
in each TU, we let them have linkonce_odr linkage to force them merged. On 
Windows, this also requires comdat.


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

https://reviews.llvm.org/D115039

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to