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

Method ~ScopedActivateContext

tensorflow/stream_executor/rocm/rocm_driver.cc:209–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209ScopedActivateContext::~ScopedActivateContext() {
210 if (FLAGS_gpuexec_rocm_sync_around_driver_calls) {
211 SynchronizeOrDie();
212 }
213
214 auto* tls = &tls_data.get();
215
216 if (kVerifyGpuContext) {
217 CHECK_EQ(CurrentDeviceOrDie(), tls->current_device_ordinal);
218 }
219
220 tls->depth--;
221 DCHECK_GE(tls->depth, 0);
222
223 if (to_restore_->device_ordinal() == tls->current_device_ordinal) {
224 DCHECK_EQ(CurrentDeviceOrDie(), to_restore_->device_ordinal());
225 return;
226 }
227
228 VLOG(3) << "ScopedActivateContext switching device from "
229 << tls->current_device_ordinal << " to "
230 << to_restore_->device_ordinal();
231
232 // Set context and update thread local.
233 CHECK_EQ(hipSuccess,
234 tensorflow::wrap::hipSetDevice(to_restore_->device_ordinal()));
235 tls->current_device_ordinal = to_restore_->device_ordinal();
236}
237
238namespace {
239

Callers

nothing calls this directly

Calls 4

CurrentDeviceOrDieFunction · 0.85
SynchronizeOrDieFunction · 0.70
getMethod · 0.45
device_ordinalMethod · 0.45

Tested by

no test coverage detected