KhronosGroup / SPIRV-Cross

SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.
Apache License 2.0
2.01k stars 556 forks source link

Request: extend SPIRV-Cross to accept OpenCL dialect of SPIR-V.. #984

Open oscarbg opened 5 years ago

oscarbg commented 5 years ago

Hi, just seeing IWOCL 2019 keynote presentation slides:(https://www.khronos.org/assets/uploads/developers/library/2019-iwocl/IWOCL%20Keynote%20May19.pdf) https://www.khronos.org/developers/library/2019-iwocl in page 31 we see talks about possible plans for "OpenCL portability initiative on Apple": image i.e. a OpenCL->Metal shim as Neil mentions that OpenCL maps to Metal better than to Vulkan (for CL->Vulkan we have clvk in progress) and with Apple deprecated OpenCL support maybe of interest.. for that, the slide mentions "SPIR-V Cross would need to be expanded to handle OpenCL dialect of SPIR-V) so just asking here.. I don't know why he doesn't mention using also clspv project which already maps OpenCL C source to SPIR-V Vulkan dialect.. Maybe because project is not mature enough or because maybe because is not enough as OpenCL 2.1 allows feeding directly SPIR-V OpenCL "binary" kernels for which clspv is of not use.. sorry, just random thoughts.. :-)

HansKristian-Work commented 5 years ago

SPIRV-Cross as-is does not support the "Kernel" execution mode as it supports various things which are impossible to express in GLSL/HLSL and I think MSL, non-structured control flow (goto) for one. I don't know what the scope of adding this is, and I have no plans to look into it until something materializes.

vchuravy commented 4 years ago

Any news on this? We are currently looking at producing SPIR-V Kernel for Intel and were hoping to re-use some of that work by using SPIR-V Cross to compile to MSL. The idea was mentioned in one of the last presentations https://images.anandtech.com/doci/15746/OpenCL%2030%20Press%20Deck_20.png

HansKristian-Work commented 4 years ago

Kernel is fundamentally incompatible with high level languages, since it supports unstructured control-flow. A subset of Kernel which uses structured control flow may or may not work, but this is not a priority for me any time soon.

Trass3r commented 3 years ago

fwiw: https://github.com/google/clspv

keithito commented 1 year ago

Hi, on this diagram from https://www.khronos.org/spir/, it looks like there's a path from: OpenCL C -> Clang -> LLVM -> SPIR-V LLVM IR Translator -> SPIR-V Tools -> SPIRV-Cross -> Metal Shading Language.

Is it possible to go from OpenCL to Metal via SPIRV-Cross, or am I misreading the diagram?

image

HansKristian-Work commented 1 year ago

SPIRV-Tools is marked with a red arrow to SPIRV-Cross, i.e. Vulkan (shading) model, not Kernel. OpenCL SPIR-V is not supported.