ROCm / HIPIFY

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

[HIPIFY] hipify-clang picks up system LLVM, which can be incompatible #57

Closed davidrohr closed 4 years ago

davidrohr commented 5 years ago

Building HIP from sources with cmake option DBUILD_HIPIFY_CLANG=ON picks up LLVM from the system. Instead, I think it should pick what comes delivered with HCC. At least in my case, the system LLVM is not compatible, and the hipify-clang tool fails to build due to changes in llvm functions.

emankov commented 5 years ago

hipify-clang shouldn't pick HCC's LLVM; it is a standalone tool and should be built with the vanilla LLVM release or trunk. Please specify your LLVM folder by a cmake flag: -DCMAKE_PREFIX_PATH=.

hipify-clang#dependencies

Btw, you may try to build with HCC's LLVM without any guarantee.

davidrohr commented 5 years ago

Sorry, probably I was not really clear. I set -DHCC_HOME=... in the cmake. I would have expected, this will make HIP pick up the correct LLVM.

But the hipify-clang cmake just runs "find_package(LLVM REQUIRED)", which picks up any LLVM, in my case the system one.

Also, it is not clear to me how -DCMAKE_PREFIX_PATH= would help. HCC does not bring an llvm cmake file, "find_package(LLVM " will thus always pick the system llvm, not the hcc one.

emankov commented 5 years ago

HCC does not bring an llvm cmake file...

It's a surprise, at least for me. Well, anyway, why do you think that system LLVM "can be incompatible"? hipify-clang supports all LLVM versions from 3.8.0 up to trunk's 9.0.0.

Btw, you may always build hipify-clang separately with the needed versions of LLVM/CUDA/cuDNN.

As for building hipify-clang with HIP (-DBUILD_HIPIFY_CLANG=ON) I will have a look, thanks!

davidrohr commented 5 years ago

FYI: I have the clang trunk on my system. The error I get is: hip-2.4.0/hipify-clang/src/LLVMCompat.cpp:62:7: error: no matching member function for call to 'EnterTokenStream' _pp.EnterTokenStream(clang::ArrayRef{start, len}, DisableMacroExpansion);

For the cmake file: I also built hcc from sources, and the cmake files it installed are: AMDDeviceLibsConfig.cmake hcc-config.cmake hcc-config-version.cmake hcc-targets.cmake hcc-targets-release.cmake ImportedTargets.cmake

Should it also install the clang / llvm cmake config files? If so, I'll have a look what went wrong for me.

emankov commented 5 years ago

_pp.EnterTokenStream(clang::ArrayRefclang::Token{start, len}, DisableMacroExpansion);

It is already fixed: #1137. Please pull the latest hipify-clang from https://github.com/ROCm-Developer-Tools/HIP/tree/master/hipify-clang in order to work with trunk LLVM 9.0.0.

Should it also install the clang / llvm cmake config files? If so, I'll have a look what went wrong for me.

Maybe HIP should; I do not have an answer right now. Anyway, hipify-clang is not tested with HCC's LLVM; you should use one of the official LLVM releases, listed here: https://github.com/ROCm-Developer-Tools/HIP/tree/master/hipify-clang#dependencies, where you can see, btw, that trunk is not officially supported.

davidrohr commented 5 years ago

OK, thx. Works for me know.

I just opened the issue since I thought it would make sense to make HIP build hipify-clang with HCC's llvm, as that should be guaranteed to work. For a standalone build, it indeed makes sense to pick up the system clang.

Closing this.