Skip to content

Conversation

JBlaschke
Copy link
Contributor

@JBlaschke JBlaschke commented Feb 9, 2021

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. Detect currently active contexts and implement 1-3
  2. 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 JBlaschke marked this pull request as draft February 9, 2021 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant