This change matches the CUDA/SPIRV behavior with CUDA/NVPTX, and makes some builtin types
and __GCC_ATOMIC_XXX_LOCK_FREE macros the same between the host and device. This is only
done when host triple is provided and known, otherwise the behavior is unchanged.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
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?