I'm not an expert on the topic, and I was looking from some more experienced users what is the current state for Nim + GPU for generic computation.
I've just experimented with treeform/shady and treeform/vmath and I successfully created a GLSL compute shader out of nim code automatically. It is fantastic as it runs 20x faster than CPU multithreading (with weave) on same machine, but at the moment it lacks the automatic creation of structs and you have to rely on basic GLSL datatypes, so it's very easy to run, but hard to get rid of custom types and abstractions.
I know there's a lot more on this topic though: for example I know Vulkan, OpenCL and SPIR-V. I know all those can replace GLSL compute shaders, but I wonder which road Nim should take to get the best out of this.
What do you think?
What do you want to do? If it's part of a game, graphics/physics/sound you probably want shady or another shading language. If its compute for AI/mining/data-crunching you are after you probably want Cuda or OpenCL.
I wrote shady. Shady could support structs, I am focused on other things and did not have time to add them yet. Vulkan also uses GLSL language. SPIR-V is a binary intermediate language of GLSL... sort of "compiled GLSL" or "GLSL byte code". So it's the same thing to shady.
OpenCL is different though. It looks pretty much like C but ads new keywords and some restrictions. I have not investigated it that much as its more of AI/mining/data-crunching thing for when you are not doing graphics. Also you are forgetting CUDA. Almost all the big AI libs use CUDA for one reason or other. It's a proprietary Nvidia thing simmilar to OpenCL.
Re @treeform, i think you can reuse shady code-generator to generate OpenCL, see https://github.com/can-lehmann/exprgrad/blob/905752c/exprgrad/clgen.nim#L77-L176 vs https://github.com/treeform/shady/blob/42cf458/src/shady.nim#L196-L591
Bonus, when i look at Halide codegen (a language for array and image processing - https://halide-lang.org/), it seems like Apple Metal codegen is really similar to OpenGL: https://github.com/halide/Halide/blob/810bd0b/src/CodeGen_Metal_Dev.cpp#L185-L204
https://www.academia.edu/download/58876412/26-1-41-1-10-2017113020190412-99331-19jp49d.pdf
Thanks
Previous link to paper is not working anymore. Here is another one:
https://pdfs.semanticscholar.org/6dea/45f9b67c847e1f67116d8538a85757aad7c8.pdf
fixed link to paper. Beware, I've not double checked the the contained info is scientifically sound, as it is not published in well known journal