[HIPIFY][#2340][feature] Add implicit CUDA header inclusion to mimic nvcc behavior#2349
Conversation
1852012 to
805b7d3
Compare
|
Hi @ranapratap55, Perhaps the last question here. Have you had a chance to try this change on the examples that were going to be "fixed" by your previous PR #2275? |
Hi @emankov, Yes, I have tested this change against the examples from #2275 and changes from the #2349(this PR) alone did not fix that issue.
Additionally, I also tested cuda-samples in 0_Introduction (46 samples, 66 source files), 1_Utilities (3 samples), and 5_Domain_Specific. The implicit cuda_runtime.h inclusion is working on all of them and no existing passing test is broken. In summary: PR #2275 solves the non-self-contained headers that depend on project-specific includes (like helper_math.h, helper_cuda.h). These are provided by the specific project. The --local-headers header injection addresses this by injecting the preceding system includes from the main source file when hipifying individual local headers. |
|
Thank you, @ranapratap55 , for your research and explanations. So let's ship this one. |
emankov
left a comment
There was a problem hiding this comment.
LGTM, Thanks! Please add a couple of (synthetic) tests on this feature in a separate PR.
Purpose
Add implicit CUDA header pre-inclusion to hipify-clang to mimic nvcc's automatic header inclusion behavior.
Problem Statement
nvcc automatically pre-includes
cuda_runtime.hat the beginning of any CUDA compilation unit. This allows CUDA code to compile without explicit#includedirectives.hipify-clang uses clang for parsing, which does not perform this implicit inclusion. This causes hipification to fail for some of the source files that rely on nvcc's implicit behavior.
Solution
Introduce implicit CUDA header inclusion by adding
-include cuda_runtime.hto clang's argument list during hipification.cuda_runtime.his nvcc's single implicit entry point which transitively includes all necessary headers such asFixes #2340