ROCm / HIPIFY

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

[HIPIFY] we need the conditional compilation #621

Closed ZenggangLiu closed 2 years ago

ZenggangLiu commented 2 years ago

i am hipifying a test kernel, which has the following layout:

if !defined(PRODUCTION)

error XXXX

endif

extern "C" global void vecAdd(float a, float b, float c, int n) { // Get our global thread ID int id = blockIdx.xblockDim.x+threadIdx.x;

// Make sure we do not go out of bounds
if (id < n)
    c[id] = a[id] + b[id];

}

but the hipifiy can not handle this. it just splits out "Error while processing..." then exits. not hip file has been generated. In this case, we also need preprocessor support during the hipifying. but it just using the raw lexer.

emankov commented 2 years ago

hipify-clang processes the undefined preprocessor conditional blocks. The reason for this is to try to hipify AMAP. If you need the default C/C++ compiler behaviour use the --skip-excluded-preprocessor-conditional-blocks option. For the list of available options use the --help option.

Moreover, your code has a syntactical error here: int id = blockIdx.xblockDim.x+threadIdx.x;

If you need further assistance, please, provide an exact source code as an attachment.

ZenggangLiu commented 2 years ago

thanks a lot emankov, that option fixes my issue