-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for target_feature atomics on wasm32 #239
base: main
Are you sure you want to change the base?
Added support for target_feature atomics on wasm32 #239
Conversation
The target_feature atomics enabled multithread on the wasm32. The devices in wgpu are not Send or Sync when the target_feature atmoics is enabled as they cannot be shared across threads. This PR enables cubecl to run wgpu on a dedicated thread and then communicate to this thread using channels.
…ache` is disabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My general comment is that there is a bit too much feature flags with wasm
around the codebase. I'm currently refactoring the wgpu server into components where it would be easier to add a new implementation tailor for wasm
.
Hiya! If I can barge in as well as I looked into this previously, some thoughts.
|
@ArthurBrussee Thank you for your review! I have been thinking more about this and I think a thread local approach would be better than creating a server with channels to it. I am running into a lot of issues in trying to wait for the response from the channel. I am thinking about creating a single instance of a server per thread per The big downside of doing this is that I would have relax the bounds on This approach would no longer require Rayon. |
Hey! Sorry for the late reply, see you're already getting somewhere with this implementation which is great :) Not having ComputeStorage::Resource be Send (at least on atomic WASM) makes sense, that's quite an inherent limitation until wgpu::Buffers are Send. Unfortunately though, the compute server read() future really needs to be Send, at least on native platforms. It's quite important to send the future to another thread where it can wait on results while otherwise still running. Maybe that could also only be !Send on atomic WASM, I don't know how annoying that would get. Last comment - you're relying on blocking on a future which I guess actually works now on a worker which is sick :D However, you still can't do so on the main thread afaik and I'm not sure if there's a good way to detect whether you're running in a worker or not. Still requiring people to manually call the async init function is annoying but might have to be like that. Hopefully also don't need to duplicate the initlialization function then! Very exciting though, would love to run my stuff in a web-worked and finally not worry about it messing with the UI haha. Though I will need to figure out how to update a canvas from a web worker... |
b695385
to
6172270
Compare
The target_feature atomics enabled multithreading on the wasm32. The devices in wgpu are not Send or Sync when the target_feature atmoics is enabled as they cannot be shared across threads.
This PR enables cubecl to run wgpu on a dedicated thread and then communicate to this thread using channels.
We are trying to use burn to run inference on wasm32 but we need atomics support to do multi threaded CPU bound compute as well.