Returns the current context and checks that it is in the set of CUDA contexts created by StreamExecutor (to ensure that the CUDA runtime didn't create a context behind our backs).
| 86 | // created by StreamExecutor (to ensure that the CUDA runtime didn't create a |
| 87 | // context behind our backs). |
| 88 | CUcontext CurrentContext() { |
| 89 | CUcontext current = cuda::CurrentContextOrDie(); |
| 90 | if (current != nullptr && !CreatedContexts::Has(current)) { |
| 91 | LOG(FATAL) << "current context was not created by the StreamExecutor " |
| 92 | "cuda_driver API: " |
| 93 | << current |
| 94 | << "; a CUDA runtime call " |
| 95 | "was likely performed without using a StreamExecutor context"; |
| 96 | } |
| 97 | return current; |
| 98 | } |
| 99 | |
| 100 | // CUDA driver routines may require a large amount of stack (particularly |
| 101 | // cuModuleLoadDataEx, in our experience). To avoid stack overflow when using |
no test coverage detected