[PATCH] D94337: Add cuda header type for cuh files
Artem Belevich via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 13 13:25:57 PST 2021
tra added a comment.
In D94337#2496627 <https://reviews.llvm.org/D94337#2496627>, @rgreenblatt wrote:
>> `...` The goal of `__clang_cuda_standalone_defs.h` is to make it possible to parse CUDA sources at all w/o having to rely on CUDA SDK. `...`
>
> Should `__clang_cuda_standalone_defs.h` depend on the arch? For example, `__match_all_sync` doesn't exist in sm_35 but does exist in sm_75.
> For tooling this might not matter because the host cuda includes don't depend on the arch.
It's open for discussion.
At the very minimum we need the standard CUDA macros, builtin variables, and, maybe, few decls for things compiler expects from CUDA runtime.
This would be a good starting point: https://github.com/llvm/llvm-project/blob/master/clang/test/SemaCUDA/Inputs/cuda.h
It will allow stand-alone CUDA parsing in general.
Arch-dependent things in CUDA headers are largely dealing with compiler builtins, so if they are missing, it should not be a very big deal. I believe tooling can deal with missing function declarations.
Missing types, if there are any may cause more issues, but I can't think of anything interesting types in CUDA headers that are type-dependent. Maybe bfloat16/tfloat32 for sm_8x+. It should not be a showstopper either.
In any case, stand-alone mode is unlikely to be very useful for a real CUDA compilation, so I'm not too worried about some missing pieces.
Tooling can then pass `-x cuda[-header] -nocudainc --cuda-host-only -include __clang_cuda_standalone_defs.h` when it processes CUDA files.
Then we'll need to test this stand-alone header and see if we need anything else to extract for reasonably complete and correct AST from CUDA sources & headers. Augment the stand-alone wrapper as necessary and repeat.
If standalone mode turns out to be useful beyond tooling, we may consider how to expose it to the end-users. Maybe a `--cuda-path=none` or some other flag to tell it to pre-include the stand-alone variant of the wrapper.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94337/new/
https://reviews.llvm.org/D94337
More information about the cfe-commits
mailing list