cufinufft icon indicating copy to clipboard operation
cufinufft copied to clipboard

Non-destructive multi-gpu defaults

Open JBlaschke opened this issue 4 years ago • 0 comments

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:

  1. 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
  2. if the user wants to force the primary context, let them by setting opts.gpu_force_primary_ctx = 1
  3. if no context is currently bound to the device, use the primary context

TODO

  1. [x] Detect currently active contexts and implement 1-3
  2. [x] Finish implementing multi-gpu context policy on external functions: makeplan, setpoints and memory-management functions
  3. [ ] Test new implementation
  4. [ ] Document
  5. [ ] Update python example

JBlaschke avatar Feb 09 '21 06:02 JBlaschke