123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #ifndef CERES_INTERNAL_CONTEXT_IMPL_H_
- #define CERES_INTERNAL_CONTEXT_IMPL_H_
- #include "ceres/internal/config.h"
- #include <string>
- #include "ceres/context.h"
- #include "ceres/internal/disable_warnings.h"
- #include "ceres/internal/export.h"
- #ifndef CERES_NO_CUDA
- #include "cublas_v2.h"
- #include "cuda_runtime.h"
- #include "cusolverDn.h"
- #include "cusparse.h"
- #endif
- #include "ceres/thread_pool.h"
- namespace ceres::internal {
- class CERES_NO_EXPORT ContextImpl final : public Context {
- public:
- ContextImpl();
- ~ContextImpl() override;
- ContextImpl(const ContextImpl&) = delete;
- void operator=(const ContextImpl&) = delete;
-
-
-
- void EnsureMinimumThreads(int num_threads);
- ThreadPool thread_pool;
- #ifndef CERES_NO_CUDA
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool InitCuda(std::string* message);
- void TearDown();
- inline bool IsCudaInitialized() const { return is_cuda_initialized_; }
-
-
-
- std::string CudaConfigAsString() const;
-
-
- size_t GpuMemoryAvailable() const;
- cusolverDnHandle_t cusolver_handle_ = nullptr;
- cublasHandle_t cublas_handle_ = nullptr;
-
-
-
- cudaStream_t DefaultStream() { return streams_[0]; }
- static constexpr int kNumCudaStreams = 2;
- cudaStream_t streams_[kNumCudaStreams] = {0};
- cusparseHandle_t cusparse_handle_ = nullptr;
- bool is_cuda_initialized_ = false;
- int gpu_device_id_in_use_ = -1;
- cudaDeviceProp gpu_device_properties_;
- bool is_cuda_memory_pools_supported_ = false;
- int cuda_version_major_ = 0;
- int cuda_version_minor_ = 0;
- #endif
- };
- }
- #include "ceres/internal/reenable_warnings.h"
- #endif
|