cufinufft
cufinufft copied to clipboard
Non-destructive multi-gpu defaults
As it stands now, the way we are setting (and restoring) the gpu device id, we are always clobbering any local device contexts with the primary context. This is because cudaSetDevice
will always make the primary context active. This PR is a way to avoid this. I propose we set a hierarchy of defaults:
- if a context is already current to the device, use that -- this can save a substantial amount of resources, and make interoperability with PyCUDA easier
- if the user wants to force the primary context, let them by setting
opts.gpu_force_primary_ctx = 1
- if no context is currently bound to the device, use the primary context
TODO
- [x] Detect currently active contexts and implement 1-3
- [x] Finish implementing multi-gpu context policy on external functions:
makeplan
,setpoints
and memory-management functions - [ ] Test new implementation
- [ ] Document
- [ ] Update python example