MCPcopy Create free account
hub / github.com/ROCm/clr / loop

Method loop

rocclr/platform/commandqueue.cpp:243–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243void HostQueue::loop(device::VirtualDevice* virtualDevice) {
244 // Notify the caller that the queue is ready to accept commands.
245 {
246 ScopedLock sl(queueLock_);
247 // Notify HostQueue() that acceptingCommands_ is updated to true
248 thread_.acceptingCommands_ = true;
249 queueLock_.notify();
250 }
251 // Create a command batch with all the commands present in the queue.
252 Command* head = NULL;
253 Command* tail = NULL;
254 while (true) {
255 // Get one command from the queue
256 Command* command = queue_.dequeue();
257 if (command == NULL) {
258 ScopedLock sl(queueLock_);
259 while ((command = queue_.dequeue()) == NULL) {
260 if (!thread_.acceptingCommands_) {
261 return;
262 }
263 queueLock_.wait();
264 }
265 }
266
267 command->retain();
268
269 // Process the command's event wait list.
270 const Command::EventWaitList& events = command->eventWaitList();
271 bool dependencyFailed = false;
272 ClPrint(LOG_DETAIL_DEBUG, LOG_CMD, "Command (%s) processing: %p ,events.size(): %d",
273 amd::activity_prof::getOclCommandKindString(command->type()), command, events.size());
274 for (const auto& it : events) {
275 // Only wait if the command is enqueued into another queue.
276 if (it->command().queue() != this) {
277 // Runtime has to flush the current batch only if the dependent wait is blocking
278 if (it->command().status() != CL_COMPLETE) {
279 ClPrint(LOG_DETAIL_DEBUG, LOG_CMD, "Command (%s) %p awaiting event: %p",
280 amd::activity_prof::getOclCommandKindString(command->type()), command, it);
281 virtualDevice->flush(head, true);
282 tail = head = NULL;
283 dependencyFailed |= !it->awaitCompletion();
284 }
285 }
286 }
287
288 // Insert the command to the linked list.
289 if (NULL == head) { // if the list is empty
290 head = tail = command;
291 } else {
292 tail->setNext(command);
293 tail = command;
294 }
295
296 if (dependencyFailed) {
297 command->setStatus(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST);
298 continue;
299 }
300

Callers 1

runMethod · 0.80

Calls 15

getOclCommandKindStringFunction · 0.85
notifyMethod · 0.80
dequeueMethod · 0.80
queueMethod · 0.80
commandMethod · 0.80
statusMethod · 0.80
setNextMethod · 0.80
waitMethod · 0.45
retainMethod · 0.45
typeMethod · 0.45
sizeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected