Resources for computing non-graphics processes on the GPU

I'm working on a project that involves a lot of "embarrassingly parallel" computations, and I was interested in trying to make it use the GPU rather than the CPU in order to speed the calculations up significantly (especially for large datasets). I've been trying to figure out the best resource for doing this in Rust, but everything I've been able to find seems to force you into the pre-built graphics pipeline. Is there any API, crate, or other resource that allows you to post custom calculations/processes to the GPU? It's possible that the shading languages I've seen have that ability, but I've been hard-pressed to find any direct examples of what I'm looking for. Ideally it would be something that is not manufacturer-specific (so not CUDA, for instance).

Do any of you have recommendations for resources to look into or experience with this sort of project? Thanks so much.

The concept you should be looking for is “compute shaders”. Despite having “shader” in the name, these are not tied to graphics at all, and are just executed in parallel and can read and write input and output buffers as you see fit — no vertices, no textures (unless you want them), no rasterization.

Rust's flagship graphics abstraction library, wgpu, supports compute shaders.

2 Likes

I'll look into it, thanks so much!