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

Method QueueThread

tensorflow/compiler/xrt/client/xrt_tf_client.cc:153–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153void XrtTfContext::QueueThread() {
154 auto should_flush_queue = [this]() {
155 mu_.AssertHeld(); // For annotalysis.
156 return enqueue_request_->queue_size() > options_.max_queue_size ||
157 flush_requested_ || shutting_down_;
158 };
159 while (true) {
160 auto request = absl::make_unique<eager::EnqueueRequest>();
161 {
162 absl::MutexLock lock(&mu_);
163 // To keep the connection alive, make sure we send an EnqueueRequest
164 // regularly, currently every 5 seconds.
165 mu_.AwaitWithTimeout(absl::Condition(&should_flush_queue),
166 absl::Seconds(5));
167 if (shutting_down_) break;
168 std::swap(request, enqueue_request_);
169 flush_requested_ = false;
170 }
171
172 std::vector<OperationId> op_ids;
173 for (const auto& item : request->queue()) {
174 if (item.has_operation()) {
175 op_ids.push_back(item.operation().id());
176 }
177 }
178 request->set_context_id(context_id_);
179
180 VLOG(10) << "Enqueue:\n" << request->DebugString();
181 eager::EnqueueResponse response;
182 Status status;
183 absl::Notification done;
184 eager_client_->EnqueueAsync(request.get(), &response, [&](Status s) {
185 status = s;
186 done.Notify();
187 });
188
189 done.WaitForNotification();
190
191 VLOG(10) << "EnqueueResponse: " << status << "\n" << response.DebugString();
192 {
193 absl::MutexLock lock(&mu_);
194 if (status.ok()) {
195 for (OperationId op_id : op_ids) {
196 DeleteOperation(op_id);
197 }
198 } else {
199 ReportError(op_ids, status);
200 }
201 }
202 }
203}
204
205void XrtTfContext::ReportError(absl::Span<const OperationId> op_ids,
206 Status status) {

Callers

nothing calls this directly

Calls 13

ConditionClass · 0.85
queue_sizeMethod · 0.80
operationMethod · 0.80
ReportErrorFunction · 0.50
AwaitWithTimeoutMethod · 0.45
queueMethod · 0.45
push_backMethod · 0.45
idMethod · 0.45
DebugStringMethod · 0.45
getMethod · 0.45
NotifyMethod · 0.45
WaitForNotificationMethod · 0.45

Tested by

no test coverage detected