CUDA Cleanup

* All Cuda* objects now take in a ContextImpl* during
  construction, and save the context instead of individual
  handles.
* Since we no longer use the legacy default stream, we need to
  explicitly synchronize the stream before performing GPU->CPU
  transfers, and CudaBuffer is responsible for such synchronization
  when asked to perform GPU to CPU transfers.
* Remove all manual syncs and relegate syncing to CudaBuffer
  before performing GPU to CPU transfers.

Change-Id: Ic73cb24174a1e09842827323280e90241716cc20
This commit is contained in:
Joydeep Biswas
2022-09-13 17:09:17 -05:00
parent 660af905fb
commit fc826c5780
10 changed files with 184 additions and 209 deletions
+7
View File
@@ -81,6 +81,13 @@ class CERES_NO_EXPORT ContextImpl final : public Context {
// 3. If the user explicitly selects a GPU in the host process before calling
// Ceres, Ceres will use that GPU.
// Note on Ceres' use of CUDA Streams:
// All operations on the GPU are performed using a single stream. This ensures
// that the order of operations are stream-ordered, but we do not need to
// explicitly synchronize the stream at the end of every operation. Stream
// synchronization occurs only before GPU to CPU transfers, and is handled by
// CudaBuffer.
// Initializes cuBLAS, cuSOLVER, and cuSPARSE contexts, creates an
// asynchronous CUDA stream, and associates the stream with the contexts.
// Returns true iff initialization was successful, else it returns false and a