38 #ifdef BUILD_CUDA_MODULE 41 #include <cuda_runtime.h> 48 #define OPEN3D_FORCE_INLINE __forceinline__ 49 #define OPEN3D_HOST_DEVICE __host__ __device__ 50 #define OPEN3D_DEVICE __device__ 51 #define OPEN3D_ASSERT_HOST_DEVICE_LAMBDA(type) \ 52 static_assert(__nv_is_extended_host_device_lambda_closure_type(type), \ 53 #type " must be a __host__ __device__ lambda") 54 #define OPEN3D_CUDA_CHECK(err) \ 55 open3d::core::__OPEN3D_CUDA_CHECK(err, __FILE__, __LINE__) 56 #define OPEN3D_GET_LAST_CUDA_ERROR(message) \ 57 __OPEN3D_GET_LAST_CUDA_ERROR(message, __FILE__, __LINE__) 58 #define CUDA_CALL(cuda_function, ...) cuda_function(__VA_ARGS__); 60 #else // #ifdef BUILD_CUDA_MODULE 62 #define OPEN3D_FORCE_INLINE inline 63 #define OPEN3D_HOST_DEVICE 65 #define OPEN3D_ASSERT_HOST_DEVICE_LAMBDA(type) 66 #define OPEN3D_CUDA_CHECK(err) 67 #define OPEN3D_GET_LAST_CUDA_ERROR(message) 68 #define CUDA_CALL(cuda_function, ...) \ 69 utility::LogError("Not built with CUDA, cannot call " #cuda_function); 71 #endif // #ifdef BUILD_CUDA_MODULE 76 #ifdef BUILD_CUDA_MODULE 101 class CUDAScopedDevice {
103 explicit CUDAScopedDevice(
int device_id);
105 explicit CUDAScopedDevice(
const Device& device);
109 CUDAScopedDevice(
const CUDAScopedDevice&) =
delete;
110 CUDAScopedDevice& operator=(
const CUDAScopedDevice&) =
delete;
155 class CUDAScopedStream {
157 struct CreateNewStreamTag {
158 CreateNewStreamTag(
const CreateNewStreamTag&) =
delete;
159 CreateNewStreamTag& operator=(
const CreateNewStreamTag&) =
delete;
160 CreateNewStreamTag(CreateNewStreamTag&&) =
delete;
161 CreateNewStreamTag& operator=(CreateNewStreamTag&&) =
delete;
165 constexpr
static CreateNewStreamTag CreateNewStream = {};
167 explicit CUDAScopedStream(
const CreateNewStreamTag&);
169 explicit CUDAScopedStream(cudaStream_t stream);
173 CUDAScopedStream(
const CUDAScopedStream&) =
delete;
174 CUDAScopedStream& operator=(
const CUDAScopedStream&) =
delete;
177 cudaStream_t prev_stream_;
178 cudaStream_t new_stream_;
179 bool owns_new_stream_ =
false;
197 static CUDAState& GetInstance();
199 CUDAState(
const CUDAState&) =
delete;
200 CUDAState& operator=(
const CUDAState&) =
delete;
204 bool IsP2PEnabled(
int src_id,
int tar_id)
const;
208 bool IsP2PEnabled(
const Device& src,
const Device& tar)
const;
212 void ForceDisableP2PForTesting();
217 std::vector<std::vector<bool>> p2p_enabled_;
221 int GetCUDACurrentWarpSize();
224 int GetCUDACurrentDeviceTextureAlignment();
261 #ifdef BUILD_CUDA_MODULE 264 cudaStream_t GetStream();
265 cudaStream_t GetDefaultStream();
274 #ifdef BUILD_CUDA_MODULE 279 void __OPEN3D_CUDA_CHECK(cudaError_t err,
const char* file,
const int line);
281 void __OPEN3D_GET_LAST_CUDA_ERROR(
const char* message,
void ReleaseCache()
Releases CUDA memory manager cache. This is typically used for debugging.
Definition: CUDAUtils.cpp:60
void Synchronize()
Definition: CUDAUtils.cpp:78
int DeviceCount()
Definition: CUDAUtils.cpp:40
bool IsAvailable()
Definition: CUDAUtils.cpp:58
void AssertCUDADeviceAvailable(int device_id)
Definition: CUDAUtils.cpp:95
Definition: PinholeCameraIntrinsic.cpp:35