Revert "Avoid lock for last queued command"

This reverts commit dc4e09a63a.

Reason for revert: <INSERT REASONING HERE>

Change-Id: Ie10442c9447f010bb90c679b6cffca5b48b8d054
This commit is contained in:
German Andryeyev
2020-06-04 15:17:45 -04:00
والد d8ca3c632c
کامیت 44bc0cb35d
2فایلهای تغییر یافته به همراه13 افزوده شده و 13 حذف شده
@@ -192,27 +192,25 @@ bool HostQueue::isEmpty() {
void HostQueue::setLastQueuedCommand(Command* lastCommand) {
// Set last submitted command
Command* lastEnqueueCommand =
lastEnqueueCommand_.exchange(lastCommand, std::memory_order_acq_rel);
if (lastEnqueueCommand != nullptr) {
lastEnqueueCommand->release();
ScopedLock l(lastCmdLock_);
if (lastEnqueueCommand_ != nullptr) {
lastEnqueueCommand_->release();
}
lastEnqueueCommand_ = lastCommand;
if (lastCommand != nullptr) {
lastCommand->retain();
lastEnqueueCommand_->retain();
}
}
Command* HostQueue::getLastQueuedCommand(bool retain) {
// Get last submitted command
Command* lastEnqueueCommand = lastEnqueueCommand_.load(std::memory_order_acquire);
if (lastEnqueueCommand == nullptr) {
return nullptr;
ScopedLock l(lastCmdLock_);
if (retain && lastEnqueueCommand_ != nullptr) {
lastEnqueueCommand_->retain();
}
if (retain) {
lastEnqueueCommand->retain();
}
return lastEnqueueCommand;
return lastEnqueueCommand_;
}
DeviceQueue::~DeviceQueue() {
@@ -126,6 +126,7 @@ class CommandQueue : public RuntimeObject {
rtCUs_(rtCUs),
priority_(priority),
queueLock_("CommandQueue::queueLock"),
lastCmdLock_("LastQueuedCommand"),
device_(device),
context_(context),
cuMask_(cuMask){}
@@ -134,6 +135,7 @@ class CommandQueue : public RuntimeObject {
uint rtCUs_; //!< The number of used RT compute units
Priority priority_; //!< Queue priority
Monitor queueLock_; //!< Lock protecting the queue
Monitor lastCmdLock_; //!< Lock protecting the last queued command
Device& device_; //!< The device
SharedReference<Context> context_; //!< The context of this command queue
const std::vector<uint32_t>& cuMask_; //!< The CU mask
@@ -185,7 +187,7 @@ class HostQueue : public CommandQueue {
private:
ConcurrentLinkedQueue<Command*> queue_; //!< The queue.
std::atomic<Command*> lastEnqueueCommand_; //!< The last submitted command
Command* lastEnqueueCommand_; //!< The last submitted command
//! Await commands and execute them as they become ready.
void loop(device::VirtualDevice* virtualDevice);