Add batch tracking for direct dispatch

Make sure the logic updates the command status when it's done in
HW, but not on submission.
Add the last command tracking, otherwise queue sync logic in the HIP
upper layer may skip synchronization, assuming the queue is empty.

Change-Id: I2d046792553e74df090a10f7d7a78914610f6df2


[ROCm/clr commit: 5b31c69a95]
This commit is contained in:
German Andryeyev
2020-11-26 15:49:25 -05:00
parent 59b1799f1e
commit 2813579db6
3 changed files with 73 additions and 18 deletions
+11 -7
View File
@@ -258,17 +258,21 @@ void Command::enqueue() {
}
ClPrint(LOG_DEBUG, LOG_CMD, "command is enqueued: %p", this);
// Direct dispatch logic below will submit the command immediately, but the command status
// update will occur later after flush() with a wait
if (AMD_DIRECT_DISPATCH) {
// The batch update must be lock protected to avoid a race condition
// when multiple threads submit/flush/update the batch at the same time
ScopedLock sl(queue_->lock());
queue_->FormSubmissionBatch(this);
if (type() == CL_COMMAND_MARKER || type() == 0) {
setStatus(CL_SUBMITTED);
queue_->vdev()->flush();
retain();
setStatus(CL_COMPLETE);
// Flush the current batch and wait for the results, since it's a marker.
// @todo: The condition requires a reevaluation to determine if any marker needs a wait.
queue_->vdev()->flush(queue_->GetSubmittionBatch());
queue_->ResetSubmissionBatch();
} else {
setStatus(CL_SUBMITTED);
submit(*queue_->vdev());
retain();
setStatus(CL_COMPLETE);
}
} else {
queue_->append(*this);