ROCm / HIPIFY

HIPIFY: Convert CUDA to Portable C++ Code
https://rocm.docs.amd.com/projects/HIPIFY/en/latest/
MIT License
524 stars 75 forks source link

[HIPIFY] hipify-clang ignoring `#if-#else-#endif` preprocessor directives? #348

Closed rosenrodt closed 3 years ago

rosenrodt commented 3 years ago

I have code snippet like this:

// platform.h
#if defined(__CUDACC_RTC__) || (!defined(_MSC_VER) && (__cplusplus < 201103L)) || (defined(_MSC_VER) && (_MSC_VER < 1600))
  #pragma message( ">>>>>>>>>>>>C Preprocessor got here (1)!" )
#else
  #pragma message( ">>>>>>>>>>>>C Preprocessor got here (2)!" )
#endif

And when I feed that into hipify-clang:

$ hipify-clang platform.h --cuda-path=/usr/local/cuda-11.3 --cuda-gpu-arch=sm_75 -- -std=c++17 -x cuda
/tmp/platform.h-734707.hip:316:9: warning: >>>>>>>>>>>>C Preprocessor got here (1)! [-W#pragma-messages]
#pragma message( ">>>>>>>>>>>>C Preprocessor got here (1)!" )
        ^
/tmp/platform.h-734707.hip:340:9: warning: >>>>>>>>>>>>C Preprocessor got here (2)! [-W#pragma-messages]
#pragma message( ">>>>>>>>>>>>C Preprocessor got here (2)!" )
        ^

Is this an expected behavior for hipify-clang to ignore the if-else-endif preprocessor directives? This code is meant to define the missing structs if there's lack of compiler support. If hipify-clang ignores those directives, a declaration conflict would occur therefore it fails to hipify. Hence I wonder if this is by design or I overlooked something?

emankov commented 3 years ago

Duplicate of #281.

rosenrodt commented 3 years ago

Duplicate of #281.

Looks worthy or trying. Thanks!

Closing issue