[PATCH] D144047: [CUDA][SPIRV] Match builtin types and __GCC_ATOMIC_XXX_LOCK_FREE macros on host/device

Shangwu Yao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 15 09:08:33 PST 2023


shangwuyao added a comment.

In D144047#4129247 <https://reviews.llvm.org/D144047#4129247>, @yaxunl wrote:

> In D144047#4129182 <https://reviews.llvm.org/D144047#4129182>, @shangwuyao wrote:
>
>> In D144047#4129154 <https://reviews.llvm.org/D144047#4129154>, @yaxunl wrote:
>>
>>> Making the builtin types consistent is necessary to keep struct layout consistent across host and device, but why do we need to make  __GCC_ATOMIC_XXX_LOCK_FREE macros the same between the host and device? Is there any concrete issue if they are not the same?
>>
>> The reason is the same as NVPTX, see https://github.com/llvm/llvm-project/blob/22882c39df71397cc6f9774d18e87d06e016c55f/clang/lib/Basic/Targets/NVPTX.cpp#L137-L141. Without it, we won't be able to use libraries that statically check the __atomic_always_lock_free. I could add the comments in the code if that makes things more clear.
>
> I see. Better add some comments about that.
>
> This also means backend needs to handle atomic operations not supported by hardware.

Yeah. It is probably the application developer's responsibility to not request atomics that are not supported by the hardware?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144047



More information about the cfe-commits mailing list