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
والد 59b1799f1e
کامیت 2813579db6
3فایلهای تغییر یافته به همراه73 افزوده شده و 18 حذف شده
@@ -111,6 +111,9 @@ class CommandQueue : public RuntimeObject {
//! Returns the CU mask array
const std::vector<uint32_t>& cuMask() const { return cuMask_; }
//! Returns the queue lock
Monitor& lock() { return queueLock_; }
protected:
//! CommandQueue constructor is protected
//! to keep the CommandQueue class as a virtual interface
@@ -241,6 +244,43 @@ class HostQueue : public CommandQueue {
//! Get last enqueued command
Command* getLastQueuedCommand(bool retain);
//! Get the submitted batch
Command* GetSubmittionBatch() const { return head_; }
//! Insert a command into the linked list of submitted commands
void FormSubmissionBatch(Command* command) {
// Insert the command to the linked list.
if (nullptr == head_) { // if the list is empty
head_ = tail_ = command;
} else {
tail_->setNext(command);
tail_ = command;
}
command->setStatus(CL_SUBMITTED);
command->retain();
// @note: runtime needs double retain in order to maintain the batch,
// because setStatus(COMPLETE) releases command and batch update may have
// an invalid access
command->retain();
// Release the last command in the batch
if (lastEnqueueCommand_ != nullptr) {
lastEnqueueCommand_->release();
}
// Extra retain for the last command
command->retain();
lastEnqueueCommand_ = command;
}
//! Reset the command batch list
void ResetSubmissionBatch() { head_ = nullptr; }
private:
Command* head_; //!< Head of the batch list
Command* tail_; //!< Tail of the batch list
};
@@ -271,9 +311,6 @@ class DeviceQueue : public CommandQueue {
//! Returns virtual device for this device queue
device::VirtualDevice* vDev() const { return virtualDevice_; }
//! Returns the queue lock
Monitor& lock() { return queueLock_; }
private:
uint size_; //!< Device queue size
device::VirtualDevice* virtualDevice_; //!< Virtual device for this queue