Skip to content
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

Support running Opt on non default cudaStream #145

Open
gerwang opened this issue Apr 14, 2019 · 1 comment
Open

Support running Opt on non default cudaStream #145

gerwang opened this issue Apr 14, 2019 · 1 comment

Comments

@gerwang
Copy link

gerwang commented Apr 14, 2019

I want to launch another CPU thread (call it CPU thread B) and use Opt on that thread, and I don't want functions like Opt_ProblemSolve to block GPU execution invoked on CPU thread A.

Does Opt support running Opt_ProblemSolve on different cudaStream? If Opt can only run on default stream, then if I schedule all GPU tasks invoked by thread A on a non-default cudaStream, can two CPU threads run without blocking each other?

By the way, does Opt call cudaDeviceSynchronize internally? If so, I'm afraid those two threads will block each other.

@Mx7f
Copy link
Collaborator

Mx7f commented Apr 30, 2019

Opt does not currently support non-default cudaStreams. There are three levels of support we could offer:

  1. Internally create and use a non-default stream internally for all operations.
  2. Expose the stream parameter for reading via the C API,
  3. Expose the stream parameter for writing via the C API (probably in Opt_InitParams).

2 and 3 worry me because we'd need a portable way to expose the stream in the C API, which currently includes no headers, especially not cuda headers. We could probably be fine passing streams as (void*) though.

The first option is easier, and likely sufficient for your purposes. This will require non-trivial, but straightforward changes to API/src/solverGPUGaussNewton.t and API/src/util.t to use a stream when possible. This includes making many cudaMemcpy's into async to avoid unneccessary synchronization.

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

No branches or pull requests

2 participants