5 ms·
Show HN: A Minimal Code Example of Using Vulkan for Computations on the GPU
- erkaman 9y agoOP here. This is a small code example of how to use Vulkan for compute operations. Only ~400LOC. It's pretty short, and has plenty of comments, so it should be useful for people learning Vulkan, I hope.
- TheAceOfHearts 9y agoMight wanna open a PR to add your sample to the list of Vulkan resources too, under samples and demos [0]. [0] https://github.com/KhronosGroup/Khronosdotorg/blob/master/api/vulkan/resources.md https://github.com/KhronosGroup/Khronosdotorg/blob/master/ap...
- erkaman 9y agoAh, thanks for the tip :-)
- sorenjan 9y agoI haven't used GPGPU in a while. Is Vulkan expected to take over from OpenCL?
- deleted 9y ago[deleted]
- slavik81 9y agoYes. https://www.pcper.com/reviews/Graphics-Cards/Follow-Neil-Trevett-and-Tom-Olson-Khronos-Group-Discuss-OpenCL-and-Vulkan-Roa https://www.pcper.com/reviews/Graphics-Cards/Follow-Neil-Tre...
- mangix 9y agocurrently OpenCL supports more devices.
- nicwilson 9y agoOpenCL (the API) will merge into Vulkan, but OpenCL C/C++/DCompute/compute shaders (the kernel languages) will remain separate as they compile to SPIRV, which is compiled into the native binary format.
- ktta 9y agoCan you explain this a bit more clearly? As I understood it, OpenCL's compute API will look like Vulkan's functions and nothing from Vulkan side will change (interpreting this from the fact that Vulkan group apparently won't be involved in this merge -- according to the interview) How will everything possibly work? Is it just that OpenCL's API will change and the libraries for OpenCL will remain the same or will the library be merged into Vulkan too? I'm just confused since the programming models are so different.
- nicwilson 9y ago>nothing from Vulkan side will change AFAIU Vulkan will continue in the direction it is going. I imagine that the OpenCL API will replace the directly comparable parts of the APIs (e.g. contexts queues images/buffers) so that OpenCL will use the Vulkan "definition". OpenCL kernels would go next to compute shaders in terms of the pipeline. There of course would be some additional things added to the combined API to support OpenCL specific things (like pipes). But alas, I am no more privy to these things than you, and the above is pure speculation.
- ilaksh 9y agoHas someone created a wrapper or higher-level API that takes care of some of the details for common use-cases? For example, say I don't need to optimize my command submittal, or I just want the main device. Or maybe my common use case is a compute shader just like the program submitted in this Hacker News post. I would want a class that just exposed a simple API like runComputeShader() or something.
- sandGorgon 9y agoIt would be great to contribute some of this to https://github.com/hughperkins/tf-coriander https://github.com/hughperkins/tf-coriander (which is a port of tensorflow to opencl). Mainline TF is not moving to opencl because of various issues - https://github.com/tensorflow/tensorflow/issues/22#issuecomment-305836597 https://github.com/tensorflow/tensorflow/issues/22#issuecomm... It would be great to see a tensorflow-vulkan