MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ~ScopedActivateContext

Method ~ScopedActivateContext

tensorflow/stream_executor/cuda/cuda_driver.cc:193–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193ScopedActivateContext::~ScopedActivateContext() {
194 if (FLAGS_gpuexec_cuda_sync_around_driver_calls) SynchronizeOrDie();
195
196 auto* tls = &tls_data.get();
197
198 if (kVerifyGpuContext) {
199 // Note that if kVerifyGpuContext is used, and contexts are deleted, it's
200 // possible this could fail in the CurrentContext() call.
201 CHECK_EQ(CurrentContext(),
202 tls->context == nullptr ? nullptr : tls->context->context());
203 }
204
205 tls->depth--;
206 DCHECK_GE(tls->depth, 0);
207 if (to_restore_ == nullptr) {
208 // Leave context, tls->id, and tls->context set.
209 return;
210 }
211
212 // Set context and update thread local.
213 FAIL_IF_CUDA_RES_ERROR(cuCtxSetCurrent(to_restore_->context()),
214 "Failed setting context");
215 tls->id = to_restore_->id();
216 tls->context = to_restore_;
217}
218
219namespace {
220

Callers

nothing calls this directly

Calls 5

CurrentContextFunction · 0.85
SynchronizeOrDieFunction · 0.70
getMethod · 0.45
contextMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected