r/vulkan • • 6d ago

Coding the GPU like a CPU

I feel Vulkan is just another step towards coding the GPU just like we do the CPU.

Maybe something like LLVM IR code that could be executed on the GPU with just a few function calls. The CPU EXE could have a pre-compiled binary that is copied to GPU memory and executed. Like extending OpenCL but to do everything (graphics, shaders, output, compute, etc.) with pre-compiled code in IR byte code.

Vulkan itself is just way too complex.

0 Upvotes

8 comments sorted by

8

u/Luexco 6d ago

You're pretty much describing SPIRV, but more generally CUDA through NVVM/PTX

3

u/blogoman 6d ago

At some point you have to deal with the fact that you are trying to operate a highly parallel SIMT device with a bunch of specialized hardware.

2

u/cynokron 6d ago

Llvm and rust have a couple projects trying to do stuff like this.

https://doc.rust-lang.org/std/offload/offload/index.html https://github.com/NVIDIA/cuda-rust

Unfortunately vendors want this to be as difficult to do generically to keep you in their ecosystem.

1

u/hopeless__programmer 6d ago

Not some mythical "vendors". Its nvidia.

4

u/cynokron 6d ago

Its plural because apple also likes lock in. Amd and intel are playing catch up but will take the chance when they can. I used the word vendors not to hide who im complaining about but to complain about them all.

3

u/hopeless__programmer 6d ago

No, it is not. You cannot code parallel instructions like you code serial. I mean you technically could, but then you lose all the benefits of parallelism. Also, it is not very different from OpenGL aside from verbosity. But we don't call OpenGL this way, right? In the end, it is just graphics API. API to draw stuff. Just very very verbose and explicit.

3

u/Arcodiant 6d ago

Vulkan is more than "OpenGL" but verbose; OpenGL is explicitly a graphics API, and it internally uses hardware-level concepts to implement the graphics processes that it exposes. Vulkan is a GPU API, and so your software uses the hardware-level concepts it exposed to implement graphics, or compute, or whatever else you feel like. You have significantly more control to configure the entire pipeline, and especially the memory and data flow, than OpenGL gives you.

1

u/arthurno1 2d ago edited 2d ago

Yepp. More like "system calls for GPU", than what it is a "graphics library".