Actually performs the work of CUDA initialization. Wrapped up in one-time execution guard.
| 268 | // Actually performs the work of CUDA initialization. Wrapped up in one-time |
| 269 | // execution guard. |
| 270 | static port::Status InternalInit() { |
| 271 | CUresult res = CUDA_ERROR_NO_DEVICE; |
| 272 | if (FLAGS_gpuexec_cuda_driver_inject_init_error) { |
| 273 | LOG(ERROR) << "injecting CUDA init error; initialization will fail"; |
| 274 | } else { |
| 275 | res = cuInit(0 /* = flags */); |
| 276 | } |
| 277 | |
| 278 | if (res == CUDA_SUCCESS) { |
| 279 | return port::Status::OK(); |
| 280 | } |
| 281 | |
| 282 | LOG(ERROR) << "failed call to cuInit: " << ToString(res); |
| 283 | Diagnostician::LogDiagnosticInformation(); |
| 284 | return port::Status(port::error::ABORTED, |
| 285 | absl::StrCat("failed call to cuInit: ", ToString(res))); |
| 286 | } |
| 287 | |
| 288 | class CudaPrimaryContextsMgr { |
| 289 | public: |