-
Notifications
You must be signed in to change notification settings - Fork 41
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
Dealing with blocking. #22
Comments
If you can make this work with pipes, that's the way to go. The last time I measured, the overhead of sending pipe messages was very small, and this is the desired mechanism in Rust for synchronizing tasks. Along these lines, it seems like we should be careful to make sure the Rust OpenCL context only runs from one task or thread. We make this happen now by using |
I think the I think the best route might be to just use ownership via |
One difficulty is still making sure only one task tries to create an OpenCL On Mon, Nov 4, 2013 at 6:05 PM, Colin Sherratt notifications@github.comwrote:
|
I played with adding a spinlock to work around this issue earlier this week. https://github.com/csherratt/rust-opencl/commit/a6258024bf76ca6001db73d52d971515e736bb1c I'd rather not push these changes up because the fix is pretty ugly. If rust-lang/rust#9105 is resolved I think this could work. |
With the new libgreen/libnative split and the fact that #9105 is complete it should be possible to resolve this issue with a little work. I might investigate this later this week. It'd be nice to remove the RUST_THREADS=1 for the make check. |
Is this issue still active? I notice we have most things protected by mutexes, and |
This is actually no longer relevant. Rust no longer supports light weight threads so what opencl does by default is the correct behavior. |
I was doing a few experiments with running hundreds of tasks each enqueueing and waiting on kernels before sending data back to the main task. And this ran head first into an expected problem with light weight threads. You can't block them and expect things to work correctly.
OpenCL has one way of working around this, The use of a callbacks. If you can setup a callback to do a message send when an event completes there is no need to do a event wait.
This would look something like this:
I would not be writing this as an issue if that worked. The rust scheduler relies on some thread local storage to be set for it to work. So as soon as the trampoline fires an abort() occurs.
OpenCL does not offer a callback to initialize it's threads, so I can't see an easy way to set this thread local storage.
There are probably a few alternatives that could work instead of using channels. Using a pipe could work, the callback writes a byte to it, and the waiting function uses the native rust runtime read on the pipe. That sounds like an extremely round about and slow mechanise.
The text was updated successfully, but these errors were encountered: