[HIPIFY][feature] Implicit hipification of local header files#2402
[HIPIFY][feature] Implicit hipification of local header files#2402ranapratap55 wants to merge 3 commits intoROCm:amd-developfrom
Conversation
|
Can we say that the main purpose of this PR is to allow hipifying header files individually as main translation units? |
Yes, correct. The main purpose is to allow hipifying local header files as main translation units. We are doing it by injecting their preceding includes from the parent source file using Clang's This feature is enabled via |
How do we guarantee finding the parent source(s) for a particular header file so we can hipify it as the main translation unit? |
…jection via ArgumentsAdjusters
We don't need to discover/guess the parent source file. The user provides it explicitly while hipifying. The main source file passed to hipify-clang is always the parent. For example: |
That is what worries me most.
Technically, the main problem is that we are trying to treat a file, a header file, which is not self-contained, as a source file for hipification (actually, compilation). I want us to think about other approaches here.
|
5e6249f to
353ebef
Compare
As per our discussions/suggestions, I've reworked this PR to implement suggestion 2. I will raise 2 separate PRs as a follow up for:
Updated PR title and description to reflect the changes. |
Problem Statement
hipify-clangcurrently only transforms the main source file passed as input. Local (quoted) headers included in the main file remain same as CUDA code. These headers often cannot be hipified individually because they are not self-contained headers which requires types, operators, and definitions from preceding includes in the parent source.Example: dxtc.cu includes
CudaMath.h, which usesfloat3operators (+=,*,-) defined inhelper_math.h. HipifyingCudaMath.halone fails because these operators are unavailable. Similar cases:Purpose
When
hipify-clang sample.cuis run, the tool now implicitly detects and hipifies all local headers. No additional flags required.#2402 (comment)
This redesign is based on feedback from #2275 and earlier iterations of this PR(#2402):
--local-headers/--local-headers-recursiveflags--skip-local-headerswhen header processing is not desiredWith #2349, we addressed nvcc's implicit
cuda_runtime.h. Now, with this PR(#2402) we are implicitly transforming project-level header dependencies.Solution
Local quoted headers hipified automatically, no flags needed.
hipify-clang sample.cu -I ../../../Common/Skip header processing if not desired
hipify-clang --skip-local-headers sample.cu -I ../../../Common/Supersedes #2275