r/learnrust • u/Docredstone1 • 3d ago
How can you write vendor-independent gpu code ?
Hello !
I have a small question, i have a project where i need to write GPU code and I would like to support both AMD and NVIDIA cards. When browsing the web I found that rocm seems to have HIP which seems to fulfill this role but I cannot find any crate providing bindings for it, could you give me some pointers ?
have a nice day !
1
Upvotes
2
u/Discordbothost 3d ago
If you're writing your own kernels, wgpu can dispatch the same WGSL compute shader through Vulkan on both vendors. I'd port one representative kernel first and run it on both target cards. Check the adapter's features and limits before leaning on things like subgroups or 16-bit floats.
2
u/pdpi 3d ago
You could look at Vulkan or WGPU compute shaders.