How to use extract_ir.py to get SPIR-V binary
lixiaoquan opened this issue · 2 comments
lixiaoquan commented
This is what I did:
# Generate a sycl integration header
/usr/local/computecpp/bin/compute++ -sycl -c example-sycl-application.cpp -o ~/a.hpp.sycl -I /usr/local/computecpp/include/ -I /usr/local/cuda/include
# Extract spir-v IR
tools/extract_ir/extract_ir.py -i ~/a.hpp.sycl -o ~/a.spt
#Try to disassemble spir-v binary with spriv-dis
~/SPIRV-Tools_build/tools/spirv-dis ~/a.spt
error: Invalid SPIR-V magic number 'dec04342'.
I just wonder which spriv-dis should I use? Is it correct way to check generated spir-v code?
lixiaoquan commented
I figured it out that I should use llvm-dis, it seems a llvm bytecode file. How can I get SPIR-V binary?
DuncanMcBain commented
When you call compute++
, you need to tell it to compile to SPIR-V - the option for that is -sycl-target spirv64
.
Actually, the thought occurs that you can just tell compute++
to output the bitcode or SPIR-V directly, like compute++ -sycl-target spirv64 -o mybitcode.spv -sycl-ih myintegrationheader.sycl
. If you use the CMake for this project, you'll get this for free.