4 ms·
Is there a transpiler / compiler that can take basic Python / Rust / C code and run it exclusively on GPU (I'm assuming GPUs support some sort of branching thes
by rao-v 2y ago
Is there a transpiler / compiler that can take basic Python / Rust / C code and run it exclusively on GPU (I'm assuming GPUs support some sort of branching these days)?
It would be nice to be able to take random bits of code and actually look at what you win / lose by running (unoptimized) on GPU vs. CPU.
Hummm various models seem to think the problem is nobody has done the work of figuring out how stuff like memory allocation and function control flow would work.
I'm surprised there isn't a fun github with a minimalist proof of concept or that none of the big players have implemented (even very inefficient) instructions in their GPU to allow general purpose computing.
- porcoda 2y agoThis is basically a problem of automatic vectorization and parallelization. This is not a new area: if you’re curious about it there is literature about this in the compilers and high performance computing world going back to the 70s. Short answer: it’s quite hard, especially for generic code. It’s achievable to some degree for array-oriented, loop heavy code, but even then with severe limitations often related to the regularity of the logic in the loop bodies, the iteration space, and the use of pointers. There has been some work for Python to do this (eg, numba), but it is largely for array heavy code instead of general Python.
- rao-v 2y agoIs the thought that it can't be done efficiently or that GPUs are missing instructions to make it possible at all?
- junon 2y agoYes, SPIRV does pretty much exactly this. Not for Python I'd imagine, maybe someone has leveraged the ast package for it though. There's nothing particularly special about graphics programs. It's just that until Vulkan and Metal, the pipelines were more or less defined for you (with OpenGL, DX, etc).
- fooker 2y agoThere are several research efforts that do this, none you can reliably use in production.
- MobiusHorizons 2y agoNo one has done it because it’s a comically bad idea. It’s like trying to build taxis with only rail infrastructure. GPUs are only fast because they do the same thing across multiple pieces of data at the same time. Branching is possible but incredibly expensive. You would end up with terrible performance and poor power efficiency. And you would still need a cpu to load programs on the GPU and handle io.