HIP compiler: how to dump preprocessor macros
I can't seem to get hipcc when backed by clang to dump any preprocessor macros when compiling for the hip language.
When I invoke for c++ with hipcc -x c++ -E -dM - < /dev/null I get the expected c++ preprocessor defines.
When I invoke for hip with hipcc -x hip -E -dM --hip-device-lib-path=/opt/rocm/lib - < /dev/null I get zero output.
What is the supported way to dump the preprocessor defines for hip? Dumping the c++ defines is insufficient for my needs as it doesn't have any HIP related defines such as __HIP__.
HIP has separate compilation for host and device, therefore the preprocessor output is different for host and device. For host compilation, you can add --cuda-host-only For device compilation, you can add --cuda-device-only
@yxsamliu Thank you.
Executing hipcc -x hip -E -dM --cuda-host-only - < /dev/null gets me the hip language preprocesor macros.
I am surprised that the HIP compiler doesn't have an preprocessor macros that describe which version it is ( information that matches hipcc --version or ./bin/.hipVersion ).
-E -dM only output clang predefined macros. Since HIP is a separate package, the macro for its version is defined by hipcc, not clang.
Are you saying that HIP doesn't have the concept of compiler versions? That the compiler for HIP version X.Y.PATCH could change without any observable difference?
I am asking so I understand how HIP/ROCm wants to handle compiler versions for build-systems such as CMake. It looks like naive usage of the __clang_major__ / __clang_minor__ version isn't sufficient as the compilers shipped 3.5 and 3.7 report the same version (11.0) but aren't.
All the forks of clang I know ( Apple, IBM, ARM ) provide some collection of preprocessor macro that identify what vendor compiler version the compiler represents.