-
Notifications
You must be signed in to change notification settings - Fork 60
Support Vulkan? #202
Comments
Currently the translator only supports OpenCL. |
After I'm done getting LDC to support OpenCL SPIR-V then if there is sufficient demand (principally within the D community, but other contributors are ofc welcome) I may consider making a fork of llvm off the latest version, updating this (OpenCL SPIR-V) to the latest llvm version and adding a Vulkan backend to it. Possibly also considering trying to integrate Microsoft's recently open-sourced DirectXShaderCompiler, although it's git history will definitely be bjorked. Will wait till development of it has matured a bit. If I get around to doing that I will be changing a few things: most noticeably using llvm intrinsics for the OpenCL/Vulkan intrinsics rather than "itanium with extensions" C++ mangling, making it far easier to use with other tools. |
@thewilsonator: while working on https://github.com/keryell/triSYCL/ I am looking at leveraging http://alphanew.net/index.php?section=alphanew&site=overview&lang=eng&newsID=111 |
@keryell Well, it doesn't have releases which makes doing CI difficult, see #201. It is also 105 commits behind KhronosGroup/SPIRV-LLVM 3.6.1 and is on LLVM 3.9.0 as opposed to the final release of that series 3.9.1. It also hasn't received any commits for 11 months. Hence why I am considering doing it myself. Also I will probably put the |
Please be aware that the dialect of SPIR-V accepted by Vulkan is significantly different from the dialect accepted by OpenCL. For starters, see the validation rules in the SPIR-V spec for "Shader" vs. "Kernel". Also, check extra restrictions in SPIR-V environment spec in the Vulkan spec: https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/html/vkspec.html#spirvenv |
Isn't it just SPIR-V core + Vulkan specific capabilities + Vulkan specific operations (a.k.a. "standard library functions")? |
Yes, but that's a big difference from SPIR-V for OpenCL. You're subtracting out a lot of assumptions made by SPIRV-LLVM assuming it's targeting OpenCL. Examples:
I urge you to consider all the details first before diving in by writing code. |
@thewilsonator: we always appreciate contributions. :-) |
My reorg ideas are
However I won't have any time to do this until August at the earliest. |
@dneto0 thanks for the pointers. Point 1 seems like a good candidate for an intrinsic function to mark the end. Point 2
Point 3 I'm less sure of, but it seems that metadata should work here. Point 4 It is the host language's problem to annotate everything with |
@thewilsonator: About storage classes. Yes, OpenCL has 5 (I forgot Generic). The validity rules are in two places:
There's a matching one for OpenCL. |
@keryell I have got a fork of llvm 5.0 with spir and spir64 proper targets (also made a |
I am OK with that. Thanks for the efforts. |
@thewilsonator For now I am busy on my SYCL device compiler with 3.9, SPIR and SPIR-V. |
Oh well. I'm sure it will be there when you decide you need to update your llvm version. |
Sorry to ask here, but this issue has been open for a while and seems to serve like a forum (given the project lacks an actual forum). I see the default branch is 3.6, but there is a 3.8 branch which is listed as active. The 3.8 branch does not pass continuous integration, though.
I need to work on fixing bugs on an LLVM related project for gaining familiarity with it and this seems a good place for me to pick up bugs. Thanks in advance. |
Ok, I think I figured out this question. The project is based on LLVM 3.6 and that is what the 3.6 branch contains. There was an attempt to upgrade to LLVM 3.8.1 but the tests are not passing with the new version, which is the reason why we are stuck on the 3.6 branch. Someone has to figure out why the tests are failing with the upgraded version. I could try to look at that then. Tell me if there is anything else you would like me to focus on. For any suggestions, feel free to contact me (abel.bernabeu@gmail.com). |
Just an update to all: there is reasonable interest from the LLVM people for upstreaming my work (see http://lists.llvm.org/pipermail/llvm-dev/2017-May/112538.html), which is an updated version of this, as well as some interest from the D community to support Vulkan as part of that. |
I can agree on most of your suggestions. However, suggesting that this project should be an LLVM backend is understimating the main attractive of the khronos branch: that it is a bidirectional translator. It can translate back and forth between LLVM IR and SPIRV because the library keeps the mapping bijective, and that property should be retained for the project to gain traction. For someone who has a pre-existing frontend and a pre-existing backend, the library allows to use SPIRV as a standard program exchange format.
Is there such a thing as an abstraction of a bidirectional LLVM IR translator on the LLVM framework? I do not think so, but I could be wrong. Having a SPIRV backend is just half of the whole picture. Ideally you want the concept of bidirectional translator abstracted on an LLVM interface, and then we would stop having SPIRV-LLVM as a library. |
It is that at the moment and it will remain one. In fact I hope to improve it by integrating it (not quite the right word) with the other backends i.e. translate the intrinsics.
The last functional commit to this repo was at the start of December...
Thats precisely why I am doing this, see my first post.
My changes integrate far better with the LLVM machinery and so opens this up to more backends, all that would be required would be to translate the intrinsics. No to mention with stay up to date with LLVM instead of falling 2 years and counting behind.
That's what |
Ok, if we still can translate back and forth I guess your fork deserves a try. I would never object to people forking open source stuff :) Am not an expert in LLVM and I have only started spending o couple hours a week on getting the 3.8 branch on a better shape than it is now. My modest short term goal is getting the continuous integration functional by fixing the current failures. From what I have seen so far some of the issues are due to the tests needing an update but others need fixing the translator. Apart from that, I did try to manually merge the functional changes from the 3.6 branch that where missing in my working copy of 3.8. The merged tree builds and seems to work, which tells me that, once the continuous integration works, we could start cherry picking from 3.6 into 3.8 trying to keep the history of who made what change. |
Neither am I :) My plan is to:
|
I currently have to translate a large codebase from C++11 to Vulkan compute. I am wondering whether the more sensible approach would be to rather have a transpiler from C++ to SPIRV for Vulkan The frontend could then:
The backend would have to:
That of course is a oversimplification. |
@abergmeier-dsfishlabs I think you would have better luck scripting clang to do the translations of C++ to Vulkan Compute source for you, rather than go via SPIR-V. If you do decide to go the SPIR-V route https://github.com/google/clspv may be of interest. |
C++ to Vulkan Spir-V compute shaders is something that I want as well. Vulkan was supposed to bring compute and graphics together no? |
Not sure if Vulkan is currently supported or not, but it seems only OpenCL is?
The text was updated successfully, but these errors were encountered: