4 ms·
This is cool, but I wonder if compiled C# code will be too branchy to run fast on the GPU. So many bounds checks, exceptions, ...
by blt 13y ago
This is cool, but I wonder if compiled C# code will be too branchy to run fast on the GPU. So many bounds checks, exceptions, ...
- khyperia 13y agoRight now, not a lot of C# code can actually be compiled to run on the GPU. It's using a custom JIT compiler that I made, I've only spent about two days working on it so far, so naturally it's nowhere near feature-complete. Examples of things that it doesn't support are exceptions, dynamic allocation of memory, the like. Essentially, you are writing CUDA kernel code, but in C# instead. Whatever CUDA C can't do, you can't do (even if normal C# can) - for example, exceptions aren't in CUDA C, so "throw" (and try/catch) won't ever be supported. Actually on topic to your point, it's being compiled through LLVM, which is a very awesome compiler backend that does a bunch of optimizations on code.
- taspeotis 13y agoI don't think that the C# compiler does much optimization, so the MSIL won't be that optimized (therefore if you were literally translating that your output would be not that optimized) but you can always do what the CLR does and take advantage of the platform and/or guarantees in the code. For example http://blogs.msdn.com/b/oldnewthing/archive/2013/08/09/10440495.aspx http://blogs.msdn.com/b/oldnewthing/archive/2013/08/09/10440...