13 #ifdef BUILD_CUDA_MODULE
16 #include <cuda_runtime.h>
20 #define FMT_STRING_ALIAS 0
30 #ifdef BUILD_CUDA_MODULE
32 #define OPEN3D_ML_CUDA_DRIVER_CHECK(err) \
33 __OPEN3D_ML_CUDA_DRIVER_CHECK(err, __FILE__, __LINE__)
35 inline void __OPEN3D_ML_CUDA_DRIVER_CHECK(CUresult err,
39 if (err != CUDA_SUCCESS) {
40 const char *error_string;
41 CUresult err_get_string = cuGetErrorString(err, &error_string);
43 if (err_get_string == CUDA_SUCCESS) {
52 inline cudaStream_t GetDefaultStream() { (cudaStream_t)0; }
54 inline int GetDevice(cudaStream_t stream) {
55 if (stream == GetDefaultStream()) {
61 CUcontext current_context;
62 OPEN3D_ML_CUDA_DRIVER_CHECK(cuCtxGetCurrent(¤t_context));
66 OPEN3D_ML_CUDA_DRIVER_CHECK(cuStreamGetCtx(stream, &
context));
67 OPEN3D_ML_CUDA_DRIVER_CHECK(cuCtxSetCurrent(
context));
72 OPEN3D_ML_CUDA_DRIVER_CHECK(cuCtxGetDevice(&device));
75 OPEN3D_ML_CUDA_DRIVER_CHECK(cuCtxSetCurrent(current_context));
81 class CUDAScopedDeviceStream {
83 explicit CUDAScopedDeviceStream(cudaStream_t stream)
84 : scoped_device_(GetDevice(stream)), scoped_stream_(stream) {}
86 CUDAScopedDeviceStream(CUDAScopedDeviceStream
const &) =
delete;
87 void operator=(CUDAScopedDeviceStream
const &) =
delete;
90 core::CUDAScopedDevice scoped_device_;
91 core::CUDAScopedStream scoped_stream_;
#define LogError(...)
Definition: Logging.h:48
ImGuiContext * context
Definition: Window.cpp:76
Definition: PinholeCameraIntrinsic.cpp:16