ROCm / ROCm-CompilerSupport

The compiler support repository provides various Lightning Compiler related services.
45 stars 31 forks source link

libamd_comgr.so depends on opencl-c-base.h from LLVM build #29

Closed preda closed 2 years ago

preda commented 4 years ago

I build comgr based on an LLVM build, e.g.:

mkdir buildx && cd buildx && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$LLVM/bld;$DEVICE_LIBS/buildx" .. && make

and I obtain libamd_comgr.so that I intend to use. But the library somehow wants to access a file from the LLVM build tree: if I move or remove the LLVM build dir ($LLVM/bld/ above), the following error appears:

malformed or corrupted AST file: 'could not find file '/home/preda/llvm/bld/lib/clang/11.0.0/include/opencl-c-base.h' referenced by AST file '/tmp/comgr-45d910/include/opencl2.0-c.pch'

Expected: the libamd_comgr.so should be self-contained: once it's built, it should not require the LLVM build directory to be kept around for comgr to function correctly.

preda commented 4 years ago

A bit of delta between the rocm-3.3 opencl2.0-c.pch and the one produced by my comgr build show that my .pch references opencl-c-base.h while the rocm-3.3 one doesn't. Any idea what causes this difference?

13,17c13,15
<   <ORIGINAL_PCH_DIR abbrevid=6/> blob data = '/home/preda/ROCm-CompilerSupport/lib/comgr/buildx'
<   <INPUT_FILES_BLOCK NumWords=46 BlockCodeSize=4>
<     <INPUT_FILE abbrevid=4 op0=1 op1=817024 op2=0 op3=1 op4=0 op5=0/> blob data = '/home/preda/ROCm-CompilerSupport/lib/comgr/buildx/<stdin>'
<     <INPUT_FILE_HASH abbrevid=5 op0=4294967295 op1=4294967295/>
<     <INPUT_FILE abbrevid=4 op0=2 op1=21332 op2=1588986680 op3=0 op4=0 op5=0/> blob data = '/home/preda/llvm/bld/lib/clang/11.0.0/include/opencl-c-base.h'
---
>   <ORIGINAL_PCH_DIR abbrevid=6/> blob data = '/data/jenkins-workspace/compute-rocm-rel-3.3/out/ubuntu-16.04/16.04/build/amd_comgr'
>   <INPUT_FILES_BLOCK NumWords=33 BlockCodeSize=4>
>     <INPUT_FILE abbrevid=4 op0=1 op1=838200 op2=0 op3=1 op4=0 op5=0/> blob data = '/data/jenkins-workspace/compute-rocm-rel-3.3/out/ubuntu-16.04/16.04/build/amd_comgr/<stdin>'
scott-linder commented 4 years ago

Hi @preda sorry for the delay responding. What branch of llvm-project are you building Comgr against? Upstream is moving towards a TableGen-based OpenCL header, and as part of that they have broken out some bits into a separate header opencl-c-base.h that is shared between the old and new approach. Unfortunately PCH is not designed to nest/chain, so you get the unfortunate dependency on a build-time header. In the long term I think we will want to confirm there is no performance regression when moving to the new approach and just drop the build-time PCH generation altogether, but that work still needs to be done.

For now we have reverted this change in the amd-stg-open branch of the compiler. Can you make sure you are building against amd-stg-open and let me know if you still see the bug?

preda commented 2 years ago

I can't test this anymore, feel free to close it as assumed fixed.