sycl
sycl copied to clipboard
[SYCL] Support Split Device Compilation
Currently we only really support single step compilation of SYCL source code to end binary output. However, it's entirely possible to support two step compilation if we wish, this could allow generation of a SPIR binary or XCL binary (xocc output binary after compilation and linking).
I'm not sure how important the XCL binary use-case is, but the SPIR binary output is pretty useful e.g. SYCL offloading to POCL. It also lets you debug the SPIR output a little easier and run additional passes without needing to alter the compiler too much.
There was functionality in place for two step compilation originally in the SYCL up-streaming implementation e.g. in the Build and Test a simple SYCL program section: https://github.com/intel/llvm/blob/e7219557e61e03d59db89346cf43a53e103973ed/sycl/doc/GetStartedWithSYCLCompiler.md
It seems to still exist but it's no longer documented for the time being, so it may require some maintenance. The above device side step can be hooked into with an optional -fsycl-use-bitcode flag to generate LLVM-IR. Although, without the InSPIRation pass being ran on the output the LLVM-IR still contains SPIRV builtins.
To truly get some form of SPIR-df you would need to run the LLVM-IR through our InSPIRation pass at the moment. Having this done cleanly through a compiler invocation is the tricky part. With this final output it should be possible to use the SPIR-df output with a POCL runtime using the second command (I had some success with this in the past, although there are some issues with certain builtins at the moment: https://github.com/pocl/pocl/issues/698 this should be tackled in a separate issue however)
XCL binary support is probably a different beast, as it requires you to invoke just the xocc component of the SYCL ToolChain without any additional offloading and wrapping steps into a final binary.