| 435 | } |
| 436 | |
| 437 | Status XlaDevice::Sync() { |
| 438 | VLOG(1) << "XlaDevice::Sync"; |
| 439 | profiler::TraceMe activity("XlaDevice::Sync", profiler::TraceMeLevel::kInfo); |
| 440 | std::shared_ptr<se::Stream> stream; |
| 441 | { |
| 442 | mutex_lock lock(mu_); |
| 443 | stream = stream_; |
| 444 | } |
| 445 | if (!stream) return Status::OK(); |
| 446 | |
| 447 | Status status = stream->BlockHostUntilDone(); |
| 448 | TF_RETURN_IF_ERROR(status); |
| 449 | if (!stream->ok()) { |
| 450 | return errors::Internal("XlaDevice::Sync() failed."); |
| 451 | } |
| 452 | VLOG(1) << "XlaDevice::Sync completed"; |
| 453 | return Status::OK(); |
| 454 | } |
| 455 | |
| 456 | // TODO(b/112409994): This is no longer necessary. Consolidate it with the |
| 457 | // synchronous version. |
no test coverage detected