| 598 | std::unique_ptr<CudaDeviceManager> CudaDeviceManager::instance_ = nullptr; |
| 599 | |
| 600 | Result<CudaDeviceManager*> CudaDeviceManager::Instance() { |
| 601 | static std::mutex mutex; |
| 602 | static std::atomic<bool> init_end(false); |
| 603 | |
| 604 | if (!init_end) { |
| 605 | std::lock_guard<std::mutex> lock(mutex); |
| 606 | if (!init_end) { |
| 607 | instance_.reset(new CudaDeviceManager()); |
| 608 | RETURN_NOT_OK(instance_->impl_->Init()); |
| 609 | init_end = true; |
| 610 | } |
| 611 | } |
| 612 | return instance_.get(); |
| 613 | } |
| 614 | |
| 615 | Result<std::shared_ptr<CudaDevice>> CudaDeviceManager::GetDevice(int device_number) { |
| 616 | return impl_->GetDevice(device_number); |