-
Notifications
You must be signed in to change notification settings - Fork 146
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
CUDA Thrust cannot access Device #24
Comments
In Legion, we are very particular about data is managed. In particular, we want all data to be stored in logical regions and not in any third-party data structures like thrust vectors. Once it's out of our control, we can't reason about it and that can lead to problems. In this specific case, there is another issue: we actually don't allow Legion GPU tasks to do anything other than launch kernels (all data movement to and from the GPU should be done via the placement of physical instances in GPU memories through the mapping interface). You may have noticed that the Legion build system only links against '-lcuda' and not '-lcudart'. We do this intentionally, so we can scope exactly the set of CUDA functions that users are permitted to invoke without interfering with the Legion programming model. I'm actually not sure how you managed to get thrust to link with our Legion build system since thrust requires '-lcudart'. |
Does this mean that you do not plan to support Thrust and other similar libraries? |
We will support a specific subset of thrust that plays nice with Legion. For example, once you've got a physical instance of a logical region in framebuffer memory, Legion can provide you a raw device pointer to that instance. You can then wrap this device pointer in a thrust vector and use thrust calls to launch kernels on the vector (be sure the vector doesn't have an allocator associated with it so thrust doesn't try to reclaim the memory after the handle goes out of scope or bad things will happen). Legion will actually modify the kernel launches underneath of the CUDA runtime API to properly defer them on the right streams so you don't have to synchronize before exiting your GPU task. There is a good example of that here: https://github.com/StanfordLegion/legion/blob/stable/examples/full_circuit/circuit_gpu.cu#L390-L401 Notice we don't need to synchronize with the GPU after the kernel launch; Legion handles that automatically while allowing the GPU processor to continue executing and launching more kernels. |
I've added some missing CUDA functions that thrust needs for most of its kernel calls. There is now an example program showing how to use thrust with Legion. https://github.com/StanfordLegion/legion/tree/master/examples/thrust_interop |
CUDA Thrust calls such as the following:
give the error (generated with -DREALM_BACKTRACE):
A simple test of this failure is:
The text was updated successfully, but these errors were encountered: