[FEATURE REQUEST]: ILGPU in Blazor using WebGPU would be awesome!
Is your feature request related to a problem? Please describe.
ILGPU is amazing for C# data processing. All major browsers are expected to support WebGPU by the end of 2025.
I am currently using ILGPU for pre/post processing image data for use with the ONNX Runtime in a .Net desktop app. It would be very useful to be able to use ILGPU in Blazor (primarily Blazor WebAssembly.)
What are the chances of getting ILGPU working in Blazor using the WebGPU API?
Describe the solution you'd like
Hoping to hear from someone who has knowledge on the backend system ILGPU uses.
Describe alternatives you've considered
No response
Additional context
No response
hi @LostBeard.
ILGPU is primarily a .NET/MSIL to Cuda PTX compiler. And it can also handle .NET/MSIL to OpenCL C.
ILGPU is able to perform this transformation with the help of .NET technologies such as Reflection, Runtime-Generated Code, and the ability to talk to the native Cuda/OpenCL drivers.
Providing support for WebGPU and Blazor WebAssembly is not a trivial change. ILGPU would need to be modified to target WebGPU (of course). It would also need to be able to perform these transformations at compile-time rather than runtime - Blazor WebAssembly has limited support for Reflection, and likely no support for Runtime-Generated Code. There are likely several other hurdles, but I hope you can appreciate that this would not be an easy change.
Having said that, it is possible to run Blazor on the server-side, where the existing .NET features are all readily available. Have you seen the Blazor sample project in ILGPU? https://github.com/m4rs-mt/ILGPU/tree/v1.5.3/Samples/BlazorSampleApp
I wrote (with help) SpawnDev.BLazorJS which brings the entire browser API, including WebGPU API support (WebGPU classes), to Blazor WASM. I just improved the performance of TypedArray marshalling to and from Blazor WASM to further aid in using it.
I have example Blazor WASM code that shows runtime compilation of Blazor WASM code inside Blazor WASM here: SpawnDev.BlazorJS.CodeRunner.
Yes, I saw the Blazor Server example. While Blazor Server can use ILGPU, it is not at all the same thing as running ILGPU in Blazor WASM on the user's browser. I appreciate your response. Thank you for taking the time to write it.
I have some experience with runtime code generation using System.Reflection.Emit, but not much. 🤷♂️ Thank you for ILGPU. I really like using it where I can.
I hope you can appreciate that this would not be an easy change.
I do. I am also very hopeful. I think ILGPU would work well in Blazor WASM. If I can help, I will. 👍
There is a major refactor underway, to lay the groundwork for the next generation of ILGPU. e.g. attempting to support AOT compilation, removing the runtime code generation, etc. It will take a while, but that should reduce the friction in supporting WebGPU.